-1

I am trying to create a window with freeglut and then use glew to create a 3.2 context in order to use modern OpenGL functions (using c++ and a Windows pc). My Problem is that the context creation (which i tried to do both before and after the freeglut init) does not seem to work and I get an Access Violation every time i try to use a function like glCreateShader.

The code I use Looks like this (it is located right at the start of the int main(int argc, char **argv) method):

glutInit(&argc, argv);
glutInitWindowPosition(-1, -1);
glutInitWindowSize(640, 480);
glutInitDisplayMode(GLUT_RGBA || GLUT_DOUBLE || GLUT_DEPTH);

glutCreateWindow("some title");


glewExperimental = GL_TRUE;
GLenum err = glewInit();

 if (GLEW_OK != err)
 {
   fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
 }
 fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
 if (GLEW_VERSION_3_2)
 {
    fprintf(stdout, "OpenGL 3.2 ready", glewGetString(GLEW_VERSION));
 }
...
vertexShader;
vertexShader = glCreateShader(GL_VERTEX_SHADER); //<-- Access Violation

Also, the glew init code is copied 1:1 from their Website. I hope that my mistake is not too obvious and that someone finds the time to help me.

4

1 回答 1

2

你有一个问题:

glutInitDisplayMode(GLUT_RGBA || GLUT_DOUBLE || GLUT_DEPTH);

Boolean OR||与 bit OR 不同|。您想要OR 位掩码|,而不是布尔值或它们。除此之外,通过这种方式,您将获得 OpenGL-3 兼容性配置文件上下文,而不是核心上下文。

于 2013-05-24T18:31:23.967 回答