Some corrections with egl attribs
This commit is contained in:
parent
3961a9a3b7
commit
635ea89cd0
@ -61,111 +61,122 @@ ContextEGL::ContextEGL(const SIrrlichtCreationParameters& params,
|
||||
os::Printer::log(text);
|
||||
}
|
||||
|
||||
EGLint attribs[] =
|
||||
EGLint EglOpenGLBIT = 0;
|
||||
|
||||
// We need proper OpenGL BIT.
|
||||
switch (params.DriverType)
|
||||
{
|
||||
case EDT_OGLES2:
|
||||
EglOpenGLBIT = EGL_OPENGL_ES2_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
EGLint Attribs[] =
|
||||
{
|
||||
#if defined( _IRR_COMPILE_WITH_ANDROID_DEVICE_ )
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_NONE
|
||||
#else
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, params.WithAlphaChannel ? 1 : 0,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, params.WithAlphaChannel ? 1:0,
|
||||
EGL_BUFFER_SIZE, params.Bits,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
//EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||
EGL_DEPTH_SIZE, params.ZBufferBits,
|
||||
EGL_STENCIL_SIZE, params.Stencilbuffer,
|
||||
EGL_SAMPLE_BUFFERS, params.AntiAlias ? 1 : 0,
|
||||
EGL_SAMPLE_BUFFERS, params.AntiAlias ? 1:0,
|
||||
EGL_SAMPLES, params.AntiAlias,
|
||||
#ifdef EGL_VERSION_1_3
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RENDERABLE_TYPE, EglOpenGLBIT,
|
||||
#endif
|
||||
EGL_NONE, 0
|
||||
#endif
|
||||
};
|
||||
|
||||
EGLint num_configs;
|
||||
u32 steps=5;
|
||||
while (!eglChooseConfig(EglDisplay, attribs, &EglConfig, 1, &num_configs) || !num_configs)
|
||||
EglConfig = 0;
|
||||
EGLint NumConfigs = 0;
|
||||
u32 Steps = 5;
|
||||
|
||||
// Choose the best EGL config.
|
||||
while (!eglChooseConfig(EglDisplay, Attribs, &EglConfig, 1, &NumConfigs) || !NumConfigs)
|
||||
{
|
||||
switch (steps)
|
||||
switch (Steps)
|
||||
{
|
||||
case 5: // samples
|
||||
if (attribs[19]>2)
|
||||
{
|
||||
--attribs[19];
|
||||
}
|
||||
if (Attribs[19] > 2)
|
||||
--Attribs[19];
|
||||
else
|
||||
{
|
||||
attribs[17]=0;
|
||||
attribs[19]=0;
|
||||
--steps;
|
||||
Attribs[17] = 0;
|
||||
Attribs[19] = 0;
|
||||
--Steps;
|
||||
}
|
||||
break;
|
||||
case 4: // alpha
|
||||
if (attribs[7])
|
||||
if (Attribs[7])
|
||||
{
|
||||
attribs[7]=0;
|
||||
Attribs[7] = 0;
|
||||
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
Attribs[17] = 1;
|
||||
Attribs[19] = params.AntiAlias;
|
||||
Steps = 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
--Steps;
|
||||
break;
|
||||
case 3: // stencil
|
||||
if (attribs[15])
|
||||
if (Attribs[15])
|
||||
{
|
||||
attribs[15]=0;
|
||||
Attribs[15] = 0;
|
||||
|
||||
if (params.AntiAlias)
|
||||
{
|
||||
attribs[17]=1;
|
||||
attribs[19]=params.AntiAlias;
|
||||
steps=5;
|
||||
Attribs[17] = 1;
|
||||
Attribs[19] = params.AntiAlias;
|
||||
Steps = 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
--Steps;
|
||||
break;
|
||||
case 2: // depth size
|
||||
if (attribs[13]>16)
|
||||
if (Attribs[13] > 16)
|
||||
{
|
||||
attribs[13]-=8;
|
||||
Attribs[13] -= 8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
--Steps;
|
||||
break;
|
||||
case 1: // buffer size
|
||||
if (attribs[9]>16)
|
||||
if (Attribs[9] > 16)
|
||||
{
|
||||
attribs[9]-=8;
|
||||
Attribs[9] -= 8;
|
||||
}
|
||||
else
|
||||
--steps;
|
||||
--Steps;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("Could not get config for OpenGL-ES2 display.");
|
||||
os::Printer::log("Could not get config for EGL display.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (params.AntiAlias && !attribs[17])
|
||||
|
||||
if (params.AntiAlias && !Attribs[17])
|
||||
os::Printer::log("No multisampling.");
|
||||
if (params.WithAlphaChannel && !attribs[7])
|
||||
|
||||
if (params.WithAlphaChannel && !Attribs[7])
|
||||
os::Printer::log("No alpha.");
|
||||
if (params.Stencilbuffer && !attribs[15])
|
||||
|
||||
if (params.Stencilbuffer && !Attribs[15])
|
||||
os::Printer::log("No stencil buffer.");
|
||||
if (params.ZBufferBits > attribs[13])
|
||||
|
||||
if (params.ZBufferBits > Attribs[13])
|
||||
os::Printer::log("No full depth buffer.");
|
||||
if (params.Bits > attribs[9])
|
||||
|
||||
if (params.Bits > Attribs[9])
|
||||
os::Printer::log("No full color buffer.");
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
|
||||
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
|
||||
|
Loading…
Reference in New Issue
Block a user