I'm using wxWidgets and Irrlicht for a multiple graphic window aplication, concretely I'm using 2 Irrlicht Scene Managers in 2 different wxWindows. Everything works fine in Direct3D, but textures (using driver->draw2DImage) and fonts are not shown in OpenGL mode. Textures used in geometry objects are displayed perfectly.
I guess it's an initialization problem, but I can't solve it. Please, could you help me? This is the initialization of the context:
Code: Select all
if (driver->getDriverType () == EDT_OPENGL){
if (this->hwnd != hwnd){
// Libera la memoria del anterior contexto
if (this->hwnd && hdc)
ReleaseDC ((HWND)this->hwnd, (HDC)hdc);
// Crea un nuevo contexto
hdc = GetDC ((HWND)hwnd);
DWORD flags = PFD_SUPPORT_COMPOSITION | PFD_SWAP_EXCHANGE | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;
// Descriptor
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
flags,
PFD_TYPE_RGBA, // Request An RGBA Format
16, // Select Our Color Depth
0,0,0,0,0,0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // Z-Buffer (Depth Buffer)
0, // Stencil Buffer Depth
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
bool arb_init = false;
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (wglChoosePixelFormat_ARB){
// This value determines the number of samples used for antialiasing
// My experience is that 8 does not show a big
// improvement over 4, but 4 shows a big improvement
// over 2.
int antialias = ((GraphicDeviceIrr*)GraphicDevice::getGraphicDevice ())->getAntialias ();
f32 fAttributes[] = {0.0, 0.0};
s32 iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, 24,
WGL_ALPHA_BITS_ARB, 0,
WGL_DEPTH_BITS_ARB, 16,
WGL_STENCIL_BITS_ARB, 0,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_STEREO_ARB, GL_FALSE,
#ifdef WGL_ARB_multisample
WGL_SAMPLE_BUFFERS_ARB, 1,
WGL_SAMPLES_ARB, antialias,
#elif defined(WGL_EXT_multisample)
WGL_SAMPLE_BUFFERS_EXT, 1,
WGL_SAMPLES_EXT,AntiAlias, // 20,21
#elif defined(WGL_3DFX_multisample)
WGL_SAMPLE_BUFFERS_3DFX, 1,
WGL_SAMPLES_3DFX,AntiAlias, // 20,21
#endif
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
// other possible values:
// WGL_ARB_pixel_format_float: WGL_TYPE_RGBA_FLOAT_ARB
// WGL_EXT_pixel_format_packed_float: WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
0,0
};
s32 pixelFormat=0;
u32 numFormats=0;
const s32 valid = wglChoosePixelFormat_ARB ((HDC)hdc, iAttributes, fAttributes, 1, &pixelFormat, &numFormats);
BOOL res = SetPixelFormat((HDC)hdc, pixelFormat, &pfd);
if (valid && res){
#ifdef WGL_ARB_create_context
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (wglCreateContextAttribs_ARB)
{
int iAttribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
0
};
// Crea el contexto de renderizado si no existe ninguno
if (((GraphicDeviceIrr*)GraphicDevice::getGraphicDevice ())->hrc == NULL)
((GraphicDeviceIrr*)GraphicDevice::getGraphicDevice ())->hrc = wglCreateContextAttribs_ARB((HDC)hdc, 0, iAttribs);
arb_init = true;
}
#endif
}
}
if (!arb_init){
int pf = GetPixelFormat ((HDC)hdc);
DescribePixelFormat((HDC)hdc, pf, sizeof (PIXELFORMATDESCRIPTOR), &pfd);
pf = ChoosePixelFormat((HDC)hdc, &pfd);
SetPixelFormat((HDC)hdc, pf, &pfd);
// Crea el contexto de renderizado si no existe ninguno
if (((GraphicDeviceIrr*)GraphicDevice::getGraphicDevice ())->hrc == NULL)
((GraphicDeviceIrr*)GraphicDevice::getGraphicDevice ())->hrc = wglCreateContext ((HDC)hdc);
}
}
}