?
Also ich selbst flippe nur in meiner Main-Loop. Was SDL macht, weiss ich natürlich nicht. Aber ich vermute dass das evtl davon kommt.
// Code der fenster Erstellung:
void NLWindowGL::create(const NLWindowSettings& s)
{
// Copy settings
m_settings = s;
// Start SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER ) == -1)
{
NLTrace("[NLWindowGL] Cannot initialize SDL!");
throw NLException("Cannot initialize SDL!", true);
}
// Prepare Flags for SDL
long flags = NLWindowGL::NIGHTLIGHT_SDL_VIDEO_FLAG;
if (m_settings.fullscreen)
{
flags |= SDL_FULLSCREEN;
}
// 3.2 Context
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
// Create Window
m_window = SDL_CreateWindow(m_settings.caption.c_str(), 50, 50, m_settings.width, m_settings.height, flags);
// Create Context
m_context = SDL_GL_CreateContext(m_window);
// VSync
SDL_GL_SetSwapInterval(1);
// Check Window
if (m_window == NULL)
{
NLTrace("[NLWindowGL] Cannot create SDL-Window!");
throw NLException("[NLWindowGL] Cannot create SDL-Window!", true);
}
// Bring mouse to the middle of the screen.
SDL_WarpMouse(m_settings.width / 2, m_settings.height / 2);
// Choose perspective
if (m_settings.mode == NightLight::OpenGL2D)
{
this->initGL2D(m_settings.width, m_settings.height);
}
// Init Glew
glewInit();
// Dump infos about renderDevice to the log.
this->dumpInfos();
}
Render-Loop, SDL Event handling hab ich mal rausgenommen:
void NLWindowGL::enterLoop()
{
u32 lastTick = 0;
u32 ticks = 0;
u32 delta = 0;
bool mouseBState = false;
// Infinite Loop!
while (true)
{
/************************************************************************/
/* Timing */
/************************************************************************/
ticks = SDL_GetTicks();
delta = ticks-lastTick;
lastTick = ticks;
// [..] SDL Event Handling abgeschnitten.
/************************************************************************/
/* Clear Buffers */
/************************************************************************/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
/************************************************************************/
/* Frame-limiter */
/************************************************************************/
if ( m_hasFrameLimit)
{
while ( m_tmNext > SDL_GetTicks() )
{
SDL_Delay(1);
}
m_tmNext += (1000 / m_fps_limit);
}
/************************************************************************/
/* Render-Event */
/************************************************************************/
m_renderEvent.emit(delta);
/************************************************************************/
/* OpenGL-Debugging */
/************************************************************************/
# if defined(_DEBUG) && NL_PERFORM_OPENGLCHECK == 1
u32 err = glGetError();
while (err != GL_NO_ERROR && err != m_prevGLError)
{
m_prevGLError = err;
std::stringstream ss;
ss << "[OpenGL] " << gluErrorString(err);
NLError(ss.str().c_str());
err = glGetError();
}
# endif
/************************************************************************/
/* Framecounter */
/************************************************************************/
m_frameCounter.update(delta);
/************************************************************************/
/* Timers */
/************************************************************************/
SystemController().getTimerController().update(delta);
/************************************************************************/
/* Swapping the buffers */
/************************************************************************/
SDL_GL_SwapWindow(m_window);
}
}
Es wird sowohl von gDEBug ein Fehler angezeigt als auch von OpenGL gemeldet. Beide mit ungültiger Enumerant. Leider steht nicht dabei welcher ungültig wäre.