diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 38 |
1 files changed, 12 insertions, 26 deletions
@@ -3,44 +3,30 @@ #include <GL/glew.h> #include <GLFW/glfw3.h> +const uint32_t fill_vert[] = #include "fill_vert.h" +; +const uint32_t visuals_frag[] = #include "visuals_frag.h" +; int main(int argc, char** argv) { // initialize window glfwInit(); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); GLFWwindow* window = glfwCreateWindow(800, 600, "test", NULL, NULL); glfwMakeContextCurrent(window); glewInit(); - // initialize triangle - const float vertices[] = { - 0, 1, 0, - 1, -1, 0, - -1, -1, 0, - }; - GLuint VBO, VAO; - glGenBuffers(1, &VBO); - glBindBuffer(GL_ARRAY_BUFFER, VBO); - glGenVertexArrays(1, &VAO); - glBindVertexArray(VAO); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); - glEnableVertexAttribArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(VAO); - // initialize shaders GLuint vert = glCreateShader(GL_VERTEX_SHADER); - glShaderBinary(1, &vert, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, fill_vert, fill_vert_size); - glSpecializeShaderARB(vert, "main", 0, NULL, NULL); + glShaderBinary(1, &vert, GL_SHADER_BINARY_FORMAT_SPIR_V, fill_vert, sizeof(fill_vert)); + glSpecializeShader(vert, "main", 0, NULL, NULL); + GLuint frag = glCreateShader(GL_FRAGMENT_SHADER); - glShaderBinary(1, &frag, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, visuals_frag, visuals_frag_size); - glSpecializeShaderARB(frag, "main", 0, NULL, NULL); + glShaderBinary(1, &frag, GL_SHADER_BINARY_FORMAT_SPIR_V, visuals_frag, sizeof(visuals_frag)); + glSpecializeShader(frag, "main", 0, NULL, NULL); + GLuint shader = glCreateProgram(); glAttachShader(shader, vert); glAttachShader(shader, frag); @@ -58,10 +44,10 @@ int main(int argc, char** argv) { // list all ACTIVE uniforms in shader: GLint count; - GLchar name[80]; - GLsizei length; glGetProgramiv(shader, GL_ACTIVE_UNIFORMS, &count); for (unsigned i = 0; i < count; i++) { + GLchar name[80]; + GLsizei length; glGetActiveUniformName(shader, i, 80, &length, name); printf("[%u] = \"%.*s\"\n", i, length, name); } |