#include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #include #include #include #include #include #include #include int main() { LOG("Howdy!"); auto window = nb::OGLWindow::CreateWindow( 400, 400, "Howdy!", {{GLFW_CONTEXT_VERSION_MAJOR, 3}, {GLFW_CONTEXT_VERSION_MINOR, 3}} ); nb::OGLWindow::MakeCurrent(window); auto vert = std::make_shared( GL_VERTEX_SHADER, "#version 330 core\n" "layout (location = 0) in vec2 aPos;\n" "out vec4 vColor;\n" "void main()\n" "{\n" " gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0);\n" " vec2 tmp = (aPos+vec2(1.0, 1.0))*0.5;\n" " vColor = vec4(tmp.x, 0, tmp.y, 1.0);\n" "}\0" ); LOG(vert->log()); auto frag = std::make_shared( GL_FRAGMENT_SHADER, "#version 330 core\n" "in vec4 vColor;\n" "out vec4 FragColor;\n" "void main()\n" "{\n" " FragColor = vColor;\n" "}\n\0" ); LOG(frag->log()); nb::ByteVector data = nb::vectorToBytes({ -0.5, -0.5, 0, 0.5, 0.5, -0.5 }); nb::Program prog({vert, frag}); prog.bind(); std::vector indxs = {0, 1, 2}; nb::IndexedMesh tri(GL_TRIANGLES, data, {nb::VertexAttribute{ 2, nb::TypeCodes::FLOAT32, false, {0, 8} }}, indxs); LOG(prog.log()); using nb::WindowCallbacks; window->setCallback( [](nb::OGLWindow* w, int key, int, int, int)->void{ if (key == GLFW_KEY_Q) { w->shouldClose(true); } }); window->setCallback( [](nb::OGLWindow* w, double x, double y)->void{ nb::logger.msg("Pos in x is " + std::to_string(x)); } ); while(!window->shouldClose()) { OPENGL_CALL(glClearColor(0.2f, 0.3f, 0.3f, 1.0f)); OPENGL_CALL(glClear(GL_COLOR_BUFFER_BIT)); tri.draw(); window->pollEvents(); window->swapBuffers(); } return 0; }