Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid GL context with GLFW and Unofficial OpenGL SDK/GLEW
    text
    copied!<p>I have started work on a new project with OpenGL 3.3. I was using GLFW and GLEW for window setup and loading of GL functions, but switched to the Unofficial OpenGL SDK instead of GLEW. The problem remained, though:</p> <p>I was getting a segmentation fault when calling glCreateShader(G_VERTEX_SHADER), and it turned out, that the function pointer was NULL. I later found out that it was caused by an invalid GL Context.</p> <p>This is the setup code:</p> <pre><code>#include &lt;glload/gl_3_3.h&gt; #include &lt;glload/gll.h&gt; #include &lt;GL/glfw.h&gt; #include &lt;glm.hpp&gt; #include &lt;gtc/matrix_transform.hpp&gt; #include "Cube.h" template &lt;class T&gt; int arraySize(T *a) { return (sizeof(a) / sizeof(*a)); } int main() { if(!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); return -1; } glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); // Open a window and create its OpenGL context if(!glfwOpenWindow(1024, 768, 0,0,0,0, 0,0, GLFW_WINDOW)) { fprintf(stderr, "Failed to open GLFW window\n"); glfwTerminate(); return -1; } if(LoadFunctions() == LS_LOAD_FAILED) { fprintf(stderr, "Failed to load GL functions.\n"); return -1; } </code></pre> <p>I have searched for answers on Google, and on here, but haven't been able to find anything. I also asked in the OpenGL IRC channel on Freenode, and they told me to try the Unofficial SDK instead of GLEW, because GLEW with the core profile is bad. This didn't work, though.</p> <p>The most weird thing is, that it worked previously, with the <strong><em>exact</em></strong> same setup as now.</p> <p>By the way, I am using Windows 7 x64 with the newest available drivers.</p> <p><strong>SOLUTION</strong>: I was being dumb, and calling glCreateShader() before glewInit(). Sorry for being dumb :(</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload