0

I'm writing an app using SDL2 / OpenGL, and doing some stencil operations.

Everything works as expected on Mac, however on PC the stenciling doesn't work.

Upon closer inspection I realized that the following code provides different outcomes on my Mac and PC:

SDL_Init(SDL_INIT_VIDEO);

SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );

SDL_CreateWindow( ... );

SDL_CreateRenderer( ... )

... do stuff ...

When I print out the stencil bits ( SDL_GL_STENCIL_SIZE ) on Mac I get 8. When I do the same on PC, I get 0.

The same happens whether I run it on an actual PC, or on a PC emulator on the Mac.

What am I missing? How can I force SDL2 to request a context with a stencil buffer?

It looks to me like the Mac's OpenGL implementation has different defaults than the PC one, so I'm probably forgetting to do something to specifically request a stencil buffer, but I can't find any good information online ...

Help ^_^' ?

genpfault
  • 51,148
  • 11
  • 85
  • 139
benitosub
  • 123
  • 1
  • 8
  • So it turns out on PC SDL2 is defaulting to direct3d even though opengl is available and I used SDL_WINDOW_OPENGL when creating the window. Any other way to force SDL to use OpenGL ? – benitosub Aug 16 '15 at 13:27

1 Answers1

0

Never mind, I found the answer:

On PC SDL2 was defaulting to Direct3D (which I guess would explain why my opengl stencil buffer was not there ^_^').

To force SDL2 to use a specific driver, you can use the second parameter in SDL_CreateRenderer.

Problem solved :D

StackOverflow, the biggest rubber duck available... ^-^'

benitosub
  • 123
  • 1
  • 8