1

我假设这是一个上下文问题,但我无法弄清楚问题是什么......

SDL_Window *window = SDL_CreateWindow("Default", 0, 0, 480, 320, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
Assert(window, "Could not create window");

SDL_GLContext context = SDL_GL_CreateContext(window);
Assert(context, "Could not create context");


glViewport(0, 0, 480, 320);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
  Assert(0, "Failure with framebuffer generation");
}

glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0);
if(glGetError() != GL_NO_ERROR){
  Assert(0, "Could not set clear color");
}
glClear(GL_COLOR_BUFFER_BIT);


GLuint shaderHandle = glCreateShader(GL_VERTEX_SHADER);
Assert(shaderHandle, "Could not create shader handle");
Assert(glGetString(GL_SHADING_LANGUAGE_VERSION), "Cant get glstring, somethings wrong");

着色器句柄为 0,这意味着它不起作用,从我读到的内容来看,当 glGetString 返回 NULL 时,这是一个坏信号。怎么了?

4

1 回答 1

4

forums.libsdl.org 的优秀人员给了我答案。给双方打电话

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);

有必要的。

于 2013-06-15T10:34:50.540 回答