#include #include #include #include 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_VISIBLE, GLFW_FALSE); GLFWwindow* window = glfwCreateWindow(800, 600, "test", NULL, NULL); glfwMakeContextCurrent(window); glewInit(); // initialize shaders GLuint vert = glCreateShader(GL_VERTEX_SHADER); 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, visuals_frag, sizeof(visuals_frag)); glSpecializeShader(frag, "main", 0, NULL, NULL); GLuint shader = glCreateProgram(); glAttachShader(shader, vert); glAttachShader(shader, frag); glLinkProgram(shader); glUseProgram(shader); // <- used the program before getting uniform name glDeleteShader(vert); glDeleteShader(frag); // print driver info printf("vendor: %s\n", glGetString(GL_VENDOR)); printf("renderer: %s\n", glGetString(GL_RENDERER)); printf("version: %s\n", glGetString(GL_VERSION)); printf("glsl version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); printf("------------------------------\n"); // list all ACTIVE uniforms in shader: GLint count; 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); } // directly get uniform location GLint uniform_location = glGetUniformLocation(shader, "test"); printf("`test` uniform location = %d\n", uniform_location); return 0; }