Project now crashing on Linux, working on Mac


#1

Our project developed on Mac but ultimately destined to be run on Linux has been working quite well up until now.

The exact same version of the application which was running absolutely fine on my Mac is now crashing on Linux with the following error:

OpenGL ERROR: file: /home/cklosters/dev/nap/modules/naprender/src/renderstate.cpp, line: 10, Unknown error (OpenGL error code: 0x502)
j12-grand-salon: /home/cklosters/dev/nap/modules/naprender/src/renderstate.cpp:10: void nap::RenderState::force(): Assertion `!opengl::printErrorMessage((char*)__FILE__, __LINE__)' failed.

(Also, /home/cklosters…? Cute?)


#2

According to https://www.khronos.org/opengl/wiki/OpenGL_Error, this apparently refers to

GL_INVALID_OPERATION, 0x0502:
Given when the set of state for a command is not legal for the parameters given to that command. It is also given for commands where combinations of parameters define what the legal parameters are.

Why would something that is valid on the Mac cause an invalid OpenGL state on the Linux machine?


#3

I’ve narrowed down the place where it crashes (on Linux, not on Mac):

renderService->clearRenderTarget(mRenderTarget->getTarget());

Why would that cause an OpenGL error on one platform and not the other?


#4

What are you clearing? The back-buffer associated with a window or an actual render target. It is important to activate the main window before clearing a target, so:

make sure to call:

renderService->getPrimaryWindow().makeCurrent();

after that:

renderService->clearRenderTarget(mRenderTarget->getTarget());

All opengl operations applied at a given point in time must be associated with a given context. Since render targets render to textures that are shared you must always enable the primary window before rendering into a render target. It could be that the OpenGL implementation on OSX is more lenient.

Up to this point I have developed cross-platform for windows and linux (same app) and only encountered this problem when the right context is not activated.

When you clear a window you need to activate that before clearing. render targets are always associated with the primary context (therefore primary window)


#5

Thanks, this sounds reasonable.