// This only works with opengl!!!! #include "TestTriangle.h" TestTriangle::TestTriangle(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { name = "TestTriangle"; WindowModule* wm = new WindowModule(a, h); deps[*wm] = wm; } TestTriangle::~TestTriangle() { if(app) { WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; } /* #if WINDOW == 2 wm->removeEventFn(ecmd_it); #endif */ wm->releaseWindow(window); } } void TestTriangle::onLoad() { // get window WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; } if(!wm) { std::cout << "No WindowModule TestTriangle!\n"; std::abort(); } window = wm->aquireWindow(); window->getRenderer()->clearColor = { 0.2, 0.2, 0.4, 0.7 }; shader = Archimedes::Shader(vertexShaderSource, fragmentShaderSource, Archimedes::Shader::LoadType::FromSource); window->getRenderer()->useShader(shader); rt = Archimedes::RenderTarget( Archimedes::VertexBuffer(vertices, 9 * sizeof(float)), Archimedes::IndexArray(indices, 3), Archimedes::VertexLayout(), shader ); window->getRenderer()->useRenderTarget(rt); } void TestTriangle::run() { window->getRenderer()->draw(rt); } bool TestTriangle::onEvent(const Archimedes::Event& e) { return false; }