#include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #include #include #include #include #include #include int main() { LOG("Howdy!"); nb::Window window(400, 400, "Hello!"); window.setWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); window.setWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); window.init(); 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::VertexGroup tri(data, { nb::VertexAttribute{ 2, GL_FLOAT, false, {0, 8} }, }, indxs); LOG(prog.log()); GLFWwindow* window_ptr = window.getWindow(); while(!glfwWindowShouldClose(window_ptr)) { OPENGL_CALL(glClearColor(0.2f, 0.3f, 0.3f, 1.0f)); OPENGL_CALL(glClear(GL_COLOR_BUFFER_BIT)); tri.draw(); glfwPollEvents(); glfwSwapBuffers(window_ptr); } return 0; }