Wait up!
I was sure it's not going to be as easy as I thought.
It seems the code I was using needs to set another kind of pixel format
http://www.jose.it-berater.org/smfforum/index.php?topic=2844.0 (see part 3)
If I do this after creating the RenderWindow and getting its inner WindowHandle, SetPixelFormat will return me an error 2000 which is "the pixel format is invalid".
Well I'm sure the pixel format is valid since the code is working in case I don't draw on the RenderWindow but just with the former full-native code.
I guess the problem is that the openGL is again already created through SFML and that I've no chance to change the pixel format once the openGL context's been created.
Am I right?
What would be a good workaround here according to you (guys)?
Here's the culprit!
bool InitGL()
{
// Even though we aren't going to be rendering the scene to the window
// we still need to create a dummy rendering context in order to load the
// pbuffer extensions and to create our pbuffer.
PIXELFORMATDESCRIPTOR pfd = {0};
// Don't bother with anything fancy here. This is just a dummy rendering
// context so just ask for the bare minimum.
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
if (!(g_hDC = GetDC(g_hWnd)))
return false;
int pf = ChoosePixelFormat(g_hDC, &pfd);
if (!SetPixelFormat(g_hDC, pf, &pfd))
return false;
if (!(g_hRC = wglCreateContext(g_hDC)))
return false;
if (!wglMakeCurrent(g_hDC, g_hRC))
return false;
if (!InitGLExtensions())
return false;
if (!InitPBuffer())
return false;
// Deactivate the dummy rendering context now that the pbuffer is created.
wglMakeCurrent(g_hDC, 0);
ReleaseDC(g_hWnd, g_hDC);
g_hDC = 0;
// We are only doing off-screen rendering. So activate our pbuffer once.
wglMakeCurrent(g_hPBufferDC, g_hPBufferRC);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_TEXTURE_2D);
// Create and bind the texture to the pbuffer's rendering context.
InitCheckerPatternTexture();
glBindTexture(GL_TEXTURE_2D, g_textureId);
return true;
}
Cheers!