Good day, i 'd like to switch from glfw to sdl3, i have created an app and set the opengl version to 3.1 , everything works fine. But when i set the major and minor version to 4.5 , or anything else which is not 3.1 , i cannot see any longer the vertex array being drawn. I am sure its something related to vertex arrays rendering becasue the glclear screen still works.
What am I doing wrong ?
thanks
- show a MRE
- what platform is being used? (Windows, Linux, etc.)
- how do you fill OpenGL function pointers? (glew, glad etc.)
show a MRE
1 Like
void InitSDL(uint32_t flags)
{
// Initialize SDL
if (!SDL_Init(SDL_INIT_VIDEO))
{
vml::os::Message::Error("SDL could not initialize! SDL Error : ", SDL_GetError());
}
else
{
// get flags
Flags = flags;
vml::utils::Logger::GetInstance()->Info("SDL API", "Initting SDL : In progress...");
// Use OpenGL 3.1 core
// SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
// Also request a depth buffer
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
// Create window
GlWindow = SDL_CreateWindow("SDL Tutorial", ScreenWidth, ScreenHeight, SDL_WINDOW_OPENGL );
if (!GlWindow)
vml::os::Message::Error("SDL : ", "couldn't set up video mode");
// check if window is at fullscreen or not
bool maximized = vml::utils::bits32::Get(Flags, MAXIMIZED);
bool fullscreen = vml::utils::bits32::Get(Flags, FULLSCREEN);
if (maximized && fullscreen)
vml::os::Message::Error("SDL : ", "couldn't set up screen mode choose fullscreen or windowed");
if ( maximized && !fullscreen )
{
SDL_SetWindowResizable(GlWindow, true);
SDL_MaximizeWindow(GlWindow);
}
if (fullscreen && !maximized)
{
SDL_SetWindowResizable(GlWindow, true);
SDL_SetWindowFullscreen(GlWindow, true);
}
// exit on esc pressed ?
ExitOnEsc = false;
if (vml::utils::bits32::Get(Flags, EXIT_ON_ESC))
ExitOnEsc = true;
// create opengl window
//Create context
GlContext = SDL_GL_CreateContext(GlWindow);
if (!GlContext)
{
vml::os::Message::Error("OpenGL context could not be created! SDL Error: %s\n", SDL_GetError());
}
else
{
//Initialize GLEW
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if (glewError != GLEW_OK)
vml::os::Message::Error("Error initializing GLEW! %s\n", glewGetErrorString(glewError));
//Use Vsync
if (!SDL_GL_SetSwapInterval(1))
vml::os::Message::Error("Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError());
//Initialize OpenGL
if (!initGL())
vml::os::Message::Error("Unable to initialize OpenGL!\n");
}
vml::utils::Logger::GetInstance()->Info("SDL API", "Initting SDL : Done");
}
}
This is the initialisation part, windows 10 paltform, opengl pointers are filled trhough glew ( yes they work )
according to lazyfoo’s tutorials
"Also, I get e-mails of how this code is broken because if you set the version to 3.2+ it won’t work because it doesn’t use vertex array objects (or VAOs). The thing is this code works fine for version 3.1 core, which it is designed to be. However, OpenGL 3.2+ requires you create a VAO. Fortunately I cover VAOs in the OpenGL tutorial. "