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