Exposing opengl to a 3rd pary lib

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
raytaller
Posts: 17
Joined: Wed Feb 07, 2007 11:28 am

Exposing opengl to a 3rd pary lib

Post by raytaller »

I am evaluating the use of some third parties to display my ingame GUI.
One of my potential choices is gameswf, which is able to run and display basic swf flash files using several hardware acceleration layers (in particular, opengl).
How difficult would it be to integrate such 3rd party with Irrlicht so that they use the same opengl context ?
I was thinking about recompiling Irrlicht and the 3dr party lib to make them link with the same opengl library (for example, GLEW).
Has this kind of stuff been done before ?

Since the rendering module of gameswf is quite well decoupled, the other option is to implement a full Irrlicht renderer, which would be great.
After all, there are only 1200 lines of opengl code to implement the whole thing. Still, I guess it would take some time to make it work properly.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can get the undrlying devices via ExposedVideoData from the driver. This should be suffiecient to render your own stuff in the same context. Replacing the whole render code depends on how well you can wrap the render data into Irrlicht structures.
raytaller
Posts: 17
Joined: Wed Feb 07, 2007 11:28 am

Post by raytaller »

Thanks for the fast reply.
I didn't know this class ! So as long as an opengl device is running, I can just include some gl headers and call glWhatIWant between beginScene() and endScene() ?
Can't be so easy, is it ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You should be careful with altering states, because Irrlicht relies on a consistent state at teh beginning. So if you change some things, either set them back, or expect some render state bugs.
raytaller
Posts: 17
Joined: Wed Feb 07, 2007 11:28 am

Post by raytaller »

Thanks, I tried and it worked, didn't know it was possible to call opengl directly.
I hope I am able to make gameswf work with Irrlicht. I'll publish my work here if so.
raytaller
Posts: 17
Joined: Wed Feb 07, 2007 11:28 am

Post by raytaller »

It definitely works ! Sincerely, working with light, efficient, well written libraries is something I like (namely Irrlicht, Lua, and now gameswf).

I replaced the SDL-opengl code with glew and it worked like a charm. Once this is done, the rendering loop is basically :

Code: Select all

glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushMatrix();

// Some GL setup
{
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glEnable(GL_LINE_SMOOTH);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);	// GL_NICEST, GL_FASTEST, GL_DONT_CARE

	glMatrixMode(GL_PROJECTION);
	glOrtho(-1, 1, 1, -1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glDisable(GL_LIGHTING);

	glDisable(GL_DEPTH_TEST);	// Disable depth testing.
	glDrawBuffer(GL_BACK);
}

m_root = m_player->get_root();
m_root->set_display_viewport(0, 0, 800, 600);
m_root->set_background_alpha(0);

m_root->advance(20); // in ms
m_root->display();

glPopMatrix();
glPopAttrib();

I still can't realize how much time this tiny thing is going to save me.
Thanks !
Post Reply