OGLES2 without EGL through SDL help need it and questions

Discussion about everything. New games, 3d math, development tips...
Post Reply
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

OGLES2 without EGL through SDL help need it and questions

Post by kas1e »

@All

I do have OS which do not have EGL, but do have OGLES2 and SDL1/2 , so to use OGLES2 driver i had to remove EGL support and use SDL1 one instead.

So far, that what i do :

1). in the CirrDeviceSDL.cpp and in COGLES2Driver.cpp all parts with "IContextManager* contextManager" on just "CIrrDeviceSDL* device
So like:

So for COGLES2Driver.cpp:

Code: Select all

//COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) :
COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device) :
...
ColorFormat(ECF_R8G8B8), ContextManager(0) //ContextManager(contextManager)
and

Code: Select all

//IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io,CIrrDeviceSDL* device)

and for CirrDeviceSDL.cpp:

Code: Select all

		#if defined(_IRR_COMPILE_WITH_OGLES2_) //&& defined(_IRR_EMSCRIPTEN_PLATFORM_)
		//IVideoDriver* createOGLES2Driver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
		IVideoDriver* createOGLES2Driver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);
		#endif

Code: Select all

	case video::EDT_OGLES2:
#if defined(_IRR_COMPILE_WITH_OGLES2_) //&& defined(_IRR_EMSCRIPTEN_PLATFORM_)
		{
			#ifndef __amigaos4__
			video::SExposedVideoData data;

			ContextManager = new video::CEGLManager();
			ContextManager->initialize(CreationParams, data);
	#endif
	
			//VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
			VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, this);
		}
#else

2). In open window add creating of ogles2 context so it will works in SDL window:

Code: Select all

	ULONG errCode = 0; 

	SDL_SysWMinfo wmi = { 0 };
	SDL_GetWMInfo(&wmi);
				
	struct TagItem contextparams[] =
	{
			{OGLES2_CCT_WINDOW,(ULONG)wmi.window},
			{OGLES2_CCT_DEPTH,16},
			{OGLES2_CCT_STENCIL,8},
			{OGLES2_CCT_VSYNC,0},
			{OGLES2_CCT_SINGLE_GET_ERROR_MODE,1},
			{OGLES2_CCT_RESIZE_VIEWPORT, TRUE},
			{TAG_DONE,0}
	};
		
	void *ogles_context = IOGLES2->aglCreateContext2(&errCode,contextparams);

  	if (ogles_context)
	{
		IOGLES2->aglMakeCurrent(ogles_context);
		
	}

So, no questions : when i compile Helloword example to use OGLES2 driver, everything is black (while all working, etc) i just can't see anything rendered.

All i can see in the console output is few strings of this kind:

GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GLSL shader programm failed to link
GL_INVALID_OPERATION: 176
Load mesh: ../../media/sydney.md2
Loaded texture: /Work/irrlicht-1.8.4/media/sydney.bmp



So cleary it tried to use ogles2 driver (as tried to load up shaders) , but something goes wrong.

Is there any way how i can check if driver works, in easy terms ? Like maybe, comment out everything inside of the "shaders" in the media ?

Ie just to see if Irrliht with ogles2 works for me, to draw something simple, which need no shaders , etc.

Any help/ideas very welcome , thanks !
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: OGLES2 without EGL through SDL help need it and questions

Post by kas1e »

After some tests find out that some shaders fail to compiles on my side due to bugs and unimplemented features in our drivers.

So question now is: can i somehow disable some shaders for tests, and still draw things via ogles2, or, whole OGLES2 in Irrlicht can only works with all shaders from the media/shaders/ ? I mean , for OGLES2 it necessary always to have directory "shaders" with all shaders inside for every project coming with, or, they can be inbuild inside of the binary , etc ?

In other words, can someone explain how whole OGLES2 in Irrlicht works.

Thanks!
CuteAlien
Admin
Posts: 9644
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: OGLES2 without EGL through SDL help need it and questions

Post by CuteAlien »

It does need shaders, there is no fixed function pipeline anymore in OpenGL ES2 (main difference to ES1). Right now the shaders we already have in there basically simulate the old fixed function pipeline - bit horrible, but allows to have old Irrlicht code mostly work on ES2 without changes (aside from missing features, for example I think texture matrices are not coded yet in those shaders).

Options:
1. You can change them by rewriting any shader in media - just be careful to use same uniform names - those are passed from code.
1b) You copy them first and use your own folder. SIrrlichtCreationParameters::OGLES2ShaderPath is where it looks for them.
2. You can create your own shader materials and use those in your models.
3. You can create your own shader materials and use IVideoDriver::swapMaterialRenderers to swap them with the default materials.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: OGLES2 without EGL through SDL help need it and questions

Post by kas1e »

Ok, so .. It mean that OGLES2 in irrlicht is not OGLES2 special code, but emulator of fixed pipeline, just like in GL4ES: https://github.com/ptitSeb/gl4es

But what about speed of this emulation ? Is it slower in compare with pure OpenGL on the same hardware ? I.e. on your test machines, the same example from the same trunk, running over OpenGL and over OpenGLES2 are the same by speed, or something slower/faster than other one ?
CuteAlien
Admin
Posts: 9644
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: OGLES2 without EGL through SDL help need it and questions

Post by CuteAlien »

The advantage of ES2 is that you generally can optimize it a lot once you know what you need in your game. So in many cases you can kick out some stuff from shaders which you do not need. Aka you don't need the full fixed pipeline emulated.

But really depends on the hardware. With Irrlicht and ES1&2 on Android I had completely different results on different devices. I assume generally ES2 is going to get better and ES1 worse.

GL4ES sounds cool. We only emulate the features needed by old Irrlicht materials - not full OpenGL2.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: OGLES2 without EGL through SDL help need it and questions

Post by kas1e »

I just use GL4ES for Irrlicht 1.8.4 port and want to try to get rid of GL4ES in favor of pure OGLES2 port of Irrlicht (to see if there will be speed differences, maybe with Irrlicht version i can get more speed)
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: OGLES2 without EGL through SDL help need it and questions

Post by kas1e »

Btw, i think in OGLES2Driver.cpp we do have missing some check on return result when call glCreateShader() and glCompileShader(). For example for now i found some shaders which fail to compiles on our drivers due to bug in drivers, but, instead of "can't compile shader" we do have error much later, with words "GLSL shader programm failed to link", like, it compiles fine, but just fail to link. But IMHO we need to check also if shaders compiles at all, and then throw a necessary error.

Probabaly this error check should be added there for both glCreateShader() and for glCompileShader():

https://sourceforge.net/p/irrlicht/code ... r.cpp#l222

As said in docs, glCreateShader() returns 0 if an error occurs creating the shader object and GL_INVALID_ENUM is generated if shaderType is not an accepted value. And glCompileShader() return GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL and/or GL_INVALID_OPERATION is generated if shader is not a shader object.

So probabaly good idea to add error checking there, just to have error output to be more close to realms.
Post Reply