gladLoadGL(); 编译没有问题了,不过运行起来就崩掉了。调试时发现 glGetString(GL_VERSION) 返回 NULL,这个简单的函数居然会失败!后来在 google 搜索 到 glGetString(GL_VERSION) 失败的原因:gladLoadGL 需要放在 SDL_GL_CreateContext 之后调用。而我把它放在了 SDL_Init 和 SDL_GL_CreateContext 之间了。
SDL_GLContext gl_context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, gl_context); SDL_GL_SetSwapInterval(1); // Enable vsync // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; io.ConfigFlags |= Im...
qDebug()<<"Failed to create SDL window: "<<SDL_GetError(); return; } // Create an OpenGL context for the window SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_P...
Fixed the usage of Cocoa_GLES_LoadLibrary in Cocoa_GL_CreateContext(). It was still using the old SDL2 style of return success/failure. Fixes issue #11175
When using the SDL3 preview 3.1.3 with the Mesa Gallium driver, a GL Context is no longer created when running on Xbox One. The same setup is successful on SDL2 version 2.20.3. Here’s a quick test case for SDL3: #include <SDL3/SDL_main.h...
device->GL_CreateContext =WIN_GL_CreateContext; device->GL_MakeCurrent =WIN_GL_MakeCurrent; device->GL_SetSwapInterval =WIN_GL_SetSwapInterval; device->GL_GetSwapInterval =WIN_GL_GetSwapInterval; device->GL_SwapWindow =WIN_GL_SwapWindow; ...
maincontext = SDL_GL_CreateContext(mainwindow); checkSDLError(__LINE__); /* This makes our buffer swap syncronized with the monitor's vertical refresh */ SDL_GL_SetSwapInterval(1); } voidrenderGL() { // Clear the color and depth buffers. ...
SDL_Init(): 初始化SDL。 SDL_CreateWindow(): 创建窗体(Window)。 SDL_CreateRenderer(): 基于窗体创建渲染器(Render)。 SDL_CreateTexture(): 创建纹理(Texture)。 循环渲染数据: SDL_UpdateTexture(): 设置纹理的数据。 SDL_RenderCopy(): 纹理复制给渲染器。 SDL_RenderPresent(): 显示。
m_glcontext = SDL_GL_CreateContext(m_screen_window); int oglIdx = -1; int nRD = SDL_GetNumRenderDrivers(); for(int i=0; i<nRD; i++) { SDL_RendererInfo info; if(!SDL_GetRenderDriverInfo(i, &info)) { if(!strcmp(info.name, "opengl")) ...
sdldie("Unable to create window"); checkSDLError(__LINE__); /* Create our opengl context and attach it to our window */ maincontext = SDL_GL_CreateContext(mainwindow); checkSDLError(__LINE__); /* This makes our buffer swap syncronized with the monitor's vertical refresh */ ...