c++ - glCreateShader causes EXC_BAD_ACCESS -


i have project in opengl , i'm trying load shaders. use gluint shader=glcreateshader(shadertype); that. problem is, when tries run line exc_bad_access (code=1, address=0x0) error (in xcode).

i found answers might not have initialized glfw, or glew. seems works fine. initialization code:

if (!glfwinit()) {         fprintf(stderr, "couldn't initialize glfw.\n");         exit(exit_failure);     }      glfwwindowhint(glfw_context_version_major, 3);     glfwwindowhint(glfw_context_version_minor, 3);     glfwwindowhint(glfw_opengl_profile, glfw_opengl_core_profile);     glfwwindowhint(glfw_opengl_forward_compat, gl_true);     glfwseterrorcallback(errorcallback);     glfwwindow* window = glfwcreatewindow(width, height, "opengl test", nullptr, nullptr);      if (!window) {         fprintf(stderr, "couldn't create window.\n");         glfwterminate();         exit(exit_failure);     }      glfwmakecontextcurrent(window);     glfwswapinterval(1);      if (glewinit() != glew_ok) {         fprintf(stderr, (char*)"couldn't initialize glew library.\n");         exit(exit_failure);     }      initopenglprogram(window); 

in initopenglprogram():

glclearcolor(0, 0, 0, 1); glenable(gl_depth_test); glfwsetkeycallback(window, keycallback);  shaderprogram = new shaderprogram((char*)"shaders/vshader.glsl", null, (char*)"shaders/fshader.glsl"); 

in new shaderprogram:

printf("loading vertex shader...\n"); vertexshader=loadshader(gl_vertex_shader,vertexshaderfile); 

and in loadshader method (this line throws error):

gluint shader=glcreateshader(shadertype); 

also have question. need project in opengl 3.3, when check version glgetstring(gl_version) 4.1 version. there problem?

the error 1 of memory. check return value of glcreateshader().this says, "a null pointer returned if there no tokens left retrieve.." this says:

  • the pointer have never been initialized.
  • the pointer have been accidentally written on because overstepped bounds of array.
  • the pointer part of object casted incorrectly, , written to.
  • any of above have corrupted different pointer points @ or near pointer, , using 1 corrupts 1 (and on).

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -