My trick for have OpenGL rendering

414 views
Skip to first unread message

Prompt

unread,
Feb 7, 2011, 3:09:06 PM2/7/11
to firebreath-dev
Hi there! I read many strange messages for to make a OpenGL context
and render. I have a game engine and I'm recently using FireBreath
like cross platform plugin SDK but have no examples for rendering.

My fast-trick to show how to render is:
- include gl.h and opengl32.lib
- In PluginWindowWin::PluginWindowWin add a call EnableOpenGL, that
function make correct OGL context with double buffering and so on...
- Call SetTimer for make your desired framerate
- When WM_TIMER is called, call to WM_PAINT
- In WM_PAINT put your source code for render a triangle (for example)

Thats all. This is not the best idea but is easy to understand all in
one file. My plugin have render code outside of PluginWindowWin. I
need to adapt this trick to Mac but I want a response of our project
owner if there is a common way to make that for all platform.


Path: C:\SVN\FireBreath\firebreath-FireBreath-031de0c\src\PluginAuto
\Win
Modified PluginWindowWin.cpp: http://www.megaupload.com/?d=HKG126A3

I hope this help you!

Richard Bateman

unread,
Feb 7, 2011, 4:34:58 PM2/7/11
to firebre...@googlegroups.com

Thanks for sharing; there is no reason that you'd need to modify PluginWindowWin.cpp to do this, however. Instead, handle the AttachedEvent and DetachedEvent firebreath events in your plugin class and call EnableOpenGL from AttachedEvent using an HWND that you can get from casting the PluginWindow* to a PluginWindowWin*. Obviously additional steps should be taken for cross-platform compatibility.

I also recommend against using SetTimer for drawing; instead, do your OGL drawing on a thread that you create and control. Make sure *all* ogl calls occur on that thread. This seems to solve a lot of weird browser inconsistencies.

Remember that FireBreath is designed so that you should never need to modify its base classes directly... if you want, you can actually provide your own PluginWindowWin derived class and return it from a method on your Factory class (see FactoryBase.h)

Hope this helps!

Richard

Reply all
Reply to author
Forward
0 new messages