Evaluate more device creation parameters in emscripten.

We can now use hardware antialiasing in emscripten.
Print some info about used SDL flags to log.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5551 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2017-10-23 22:03:18 +00:00
parent c376454941
commit 70363e0819
3 changed files with 60 additions and 3 deletions

View File

@ -103,6 +103,7 @@ void one_iter()
*/
int main()
{
SIrrlichtCreationParameters parameters;
/*
Create device flags for emscripten are still experimental
and might not all work.
@ -112,12 +113,16 @@ int main()
EDT_OGLES2 needs -s FULL_ES2=1 as linker flag in the Makefile.
*/
#ifndef __EMSCRIPTEN__
video::E_DRIVER_TYPE deviceType = EDT_OGLES2;
parameters.DriverType = EDT_OGLES2;
#else //__EMSCRIPTEN__
video::E_DRIVER_TYPE deviceType = EDT_WEBGL1;
parameters.DriverType = EDT_WEBGL1;
#endif //__EMSCRIPTEN__
device = createDevice(deviceType, screenSize, 16, false, false, false, 0);
parameters.WindowSize = screenSize;
parameters.Stencilbuffer = false;
parameters.AntiAlias = 4;
device = createDeviceEx(parameters);
if (!device)
return 1;

View File

@ -273,6 +273,32 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
SDL_Quit();
}
void CIrrDeviceSDL::logAttributes()
{
core::stringc sdl_attr("SDL attribs:");
int value = 0;
if ( SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value ) == 0 )
sdl_attr += core::stringc(" r:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value ) == 0 )
sdl_attr += core::stringc(" g:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value ) == 0 )
sdl_attr += core::stringc(" b:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE, &value ) == 0 )
sdl_attr += core::stringc(" a:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value) == 0 )
sdl_attr += core::stringc(" depth:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value ) == 0 )
sdl_attr += core::stringc(" stencil:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ) == 0 )
sdl_attr += core::stringc(" doublebuf:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ) == 0 )
sdl_attr += core::stringc(" aa:") + core::stringc(value);
if ( SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ) == 0 )
sdl_attr += core::stringc(" aa-samples:") + core::stringc(value);
os::Printer::log(sdl_attr.c_str());
}
bool CIrrDeviceSDL::createWindow()
{
@ -286,8 +312,31 @@ bool CIrrDeviceSDL::createWindow()
Width = w;
Height = h;
}
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer ? 1 : 0);
if (CreationParams.AntiAlias>1)
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
}
else
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
Screen = SDL_SetVideoMode( 0, 0, 32, SDL_Flags); // 0,0 will use the canvas size
logAttributes();
// "#canvas" is for the opengl context
emscripten_set_mousedown_callback("#canvas", (void*)this, true, MouseUpDownCallback);
emscripten_set_mouseup_callback("#canvas", (void*)this, true, MouseUpDownCallback);
@ -318,6 +367,7 @@ bool CIrrDeviceSDL::createWindow()
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
if (CreationParams.Doublebuffer)
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);
if (CreationParams.Stereobuffer)
SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
if (CreationParams.AntiAlias>1)

View File

@ -233,6 +233,8 @@ namespace irr
void createKeyMap();
void logAttributes();
SDL_Surface* Screen;
int SDL_Flags;
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)