Native OpenGL code inside Ogre
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
Native OpenGL code inside Ogre
It's my first post inside this forum, so Hello to all the community!
I'm a totally newbye of Ogre, and I'm getting crazy because of this problem.
Is there the possibility of making use of the native OpenGL functions (glVertex, glColor, and so on) inside an Ogre application? I searched deeply inside the documentation and the wiki, and I've found out that using the ManualObject class is possibile to draw an object in a GL-like way.
What if I need to insert some native OpenGL code?
I'm sorry if similar questions has arisen in the past, but I was not able to find anything related.
Thanks a lot
Giuseppe
I'm a totally newbye of Ogre, and I'm getting crazy because of this problem.
Is there the possibility of making use of the native OpenGL functions (glVertex, glColor, and so on) inside an Ogre application? I searched deeply inside the documentation and the wiki, and I've found out that using the ManualObject class is possibile to draw an object in a GL-like way.
What if I need to insert some native OpenGL code?
I'm sorry if similar questions has arisen in the past, but I was not able to find anything related.
Thanks a lot
Giuseppe
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
The reason is that I'developed a DLL capable of receiving, via network, an OpenGL command stream (generated by an OpenGL application) and execute it. So I'd like to import the dll from the Ogre application, in order to draw a mix of what my dll is receiving and what I'm drawing using ogre. My dll's functions execute the native OpenGL commands, and I cannot change this feature.
- JamesKilton
- Halfling
- Posts: 87
- Joined: Tue Jun 14, 2005 8:21 pm
- x 1
Highly doubtful you'll be able to have that work with Ogre.
When you say "command stream", do you mean glVertex, glColor, glBegin / glEnd type commands?
Of course the other questions is: why do you want to send drawing commands over the network? That's going to make things even slower than GL immediate mode.
When you say "command stream", do you mean glVertex, glColor, glBegin / glEnd type commands?
Of course the other questions is: why do you want to send drawing commands over the network? That's going to make things even slower than GL immediate mode.
Ogre.rb Project Lead
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
Yes, I mean glVertex, glColor, glBegin / glEnd, and so on...
I'd like to visualize part fo the geometry drawn by a generic openGL application, using a tool that intercept and sends the opengl commands performed by that application.
Of course it's slower, but since I don't know a priori how the openGL stream is composed, I'm afraid I cannot act in a different way.
As an idea, is it possible to set a callback on the draw function of an entity, and to perform the native openGL calls inside that callback?
Thanks a lot
Giuseppe
I'd like to visualize part fo the geometry drawn by a generic openGL application, using a tool that intercept and sends the opengl commands performed by that application.
Of course it's slower, but since I don't know a priori how the openGL stream is composed, I'm afraid I cannot act in a different way.
As an idea, is it possible to set a callback on the draw function of an entity, and to perform the native openGL calls inside that callback?
Thanks a lot
Giuseppe
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
@marinogiuse: This can be done.
I will create a simple demo for you this weekend.
I will create a simple demo for you this weekend.
Watch out for my OGRE related tweets here.
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
The trick is how to integrate your openGL code into an existing scene.
You need to add a "Render Queue Listener" to the "Scene Manager".
At the end of the "Render Queue" - you can draw with your own native code.
You need to make sure that the "Render Queue" is not empty - else nothing will be drawn.
I wanted to create a sample for you that demonstrate how to integrate to an existing scene. I inherited the SkyDome demo and added some native openGL code.
I used a "Manual Object" as a reference point to place the native drawing in the scene.
here is my code: NativeRenderSystemCommands.zip. To compile - add to the samples folder like the other samples and add to the ogre solution.
Here is how it looks:
As you can see - the openGL code draws quads.
Hope it helps you.
Post a replay if you need any more help.
If anyone has a better way to do this - I will be happy for comments.
I didn't create the d3d9 and d3d10 part of the sample - does anyone need them also?
You need to add a "Render Queue Listener" to the "Scene Manager".
At the end of the "Render Queue" - you can draw with your own native code.
You need to make sure that the "Render Queue" is not empty - else nothing will be drawn.
I wanted to create a sample for you that demonstrate how to integrate to an existing scene. I inherited the SkyDome demo and added some native openGL code.
I used a "Manual Object" as a reference point to place the native drawing in the scene.
here is my code: NativeRenderSystemCommands.zip. To compile - add to the samples folder like the other samples and add to the ogre solution.
Here is how it looks:
As you can see - the openGL code draws quads.
Hope it helps you.
Post a replay if you need any more help.
If anyone has a better way to do this - I will be happy for comments.
I didn't create the d3d9 and d3d10 part of the sample - does anyone need them also?
Watch out for my OGRE related tweets here.
- PolyVox
- OGRE Contributor
- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
- Contact:
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Personally I don’t like code in wiki – I always prefer to have a project + h + cpp files.PolyVox wrote:Maybe it belongs on the wiki?
But – if anyone wants to turn this into a wiki page – you are welcome.
Watch out for my OGRE related tweets here.
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
too many samples - I don't remember the last time we added a sample to the sdk.
even my Stencil Glow Demo hasn't made it in.
even my Stencil Glow Demo hasn't made it in.
Watch out for my OGRE related tweets here.
- SunSailor
- Gnoll
- Posts: 699
- Joined: Sun Jan 02, 2005 5:45 pm
- Location: Velbert, Germany
- x 2
- Contact:
- DanielSefton
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
- Contact:
We should create a whole new area for storing and accessing demos. There's dozens of demos all over the place that aren't included with Ogre -- which, you can't expect them to be. It would be a nice idea to have them all in one place. Just an idea.
Great job btw, I always wondered how Ogre could be used with native code.
Great job btw, I always wondered how Ogre could be used with native code.
- madmarx
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
This is extremely interesting (I mean the code from M Assaf Raman). I thougt an inherited scenemanager would have been needed. And I realise I was wrong.
Concerning the wiki / codesnippet thing, my suggestion would be to only add link to the corresponding forum thread in the wiki.
Example could be :
wiki -> code snippet -> how to do opengl calls -> put the link to this thread in the page.
Concerning the wiki / codesnippet thing, my suggestion would be to only add link to the corresponding forum thread in the wiki.
Example could be :
wiki -> code snippet -> how to do opengl calls -> put the link to this thread in the page.
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
-
- Ogre Magi
- Posts: 1120
- Joined: Wed Nov 15, 2006 7:41 pm
- Location: Finland
- x 5
There could be separate sample packages.
You only include the most important samples in the Ogre3D package.
Then you can have
- Extra Samples I
- Extra Samples II
- Extra Samples III
et cetera. These would not be buried into the Wiki or into the forums but they would be directly accessible from the Ogre3D download page.
You could group the samples so that the samples that are closely related to each other are in the same package. Like "Lighting samples in package I" and "Animation samples in package II" etc. One package could have different types of samples of course.
You can have a rule that only the samples that come in the Ogre3D package are 'officially' supported and maintained, and the rest of the samples are not so actively maintained. It should probably be a community effort to keep the extra sample packages maintained. So that when compatibility is broken, then a call is made on the forums that "someone needs to fix this, please help to test where the problems are and submit patches" to reduce the burden on the Ogre3D team.
These extra samples should have a "do whatever you want with them" license.
You only include the most important samples in the Ogre3D package.
Then you can have
- Extra Samples I
- Extra Samples II
- Extra Samples III
et cetera. These would not be buried into the Wiki or into the forums but they would be directly accessible from the Ogre3D download page.
You could group the samples so that the samples that are closely related to each other are in the same package. Like "Lighting samples in package I" and "Animation samples in package II" etc. One package could have different types of samples of course.
You can have a rule that only the samples that come in the Ogre3D package are 'officially' supported and maintained, and the rest of the samples are not so actively maintained. It should probably be a community effort to keep the extra sample packages maintained. So that when compatibility is broken, then a call is made on the forums that "someone needs to fix this, please help to test where the problems are and submit patches" to reduce the burden on the Ogre3D team.
These extra samples should have a "do whatever you want with them" license.
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
@Marinogiuse:I was happy to help; your nice screenshot made my day, I always love to see new ways you can use OGRE.marinogiuse wrote:It works perfectly!
Many thanks Assaf Raman!
Here's a screenshot of what I've done!
...
Watch out for my OGRE related tweets here.
- syedhs
- Silver Sponsor
- Posts: 2703
- Joined: Mon Aug 29, 2005 3:24 pm
- Location: Kuala Lumpur, Malaysia
- x 51
I think this deserves a place in Ogre demos. It demonstrates a totally different aspect of using Ogre, as what many existing Ogre demos already do.
Well maybe few existing demos need to be removed as well - what do you say Sinbad?
Well maybe few existing demos need to be removed as well - what do you say Sinbad?
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
Just another question...if I swich focus on a different window than the Ogre's one, the Ogre appilication stops rendering. There's a way to disable this "optimization"?
Do I have to open a different thread for this question?
Thanks in advance
Giuseppe
EDIT: lurking into the forum I've seen that this problem has been solved earlier. I've tried to adopt suggested solution, but following the indications, I'm not able to give the focus again to my application...
What I've done is substuting, into the exampleapplication.h file, the line:
with
did I make something wrong?
Do I have to open a different thread for this question?
Thanks in advance
Giuseppe
EDIT: lurking into the forum I've seen that this problem has been solved earlier. I've tried to adopt suggested solution, but following the indications, I'm not able to give the focus again to my application...
What I've done is substuting, into the exampleapplication.h file, the line:
Code: Select all
mRoot->startRendering(); //inside the virtual void go(void) function
Code: Select all
for(;;){
mRoot->_fireFrameStarted();
mRoot->_updateAllRenderTargets();
mWindow->update();
mRoot->_fireFrameEnded();
}
- DanielSefton
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
- Contact:
Code: Select all
if (RenderWindow->isActive()) {
mRoot->startRendering();
}
else if (RenderWindow->isVisible()) {
mRoot->startRendering();
}
-
- Gnoblar
- Posts: 9
- Joined: Fri Jul 25, 2008 11:53 am
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
I was surprised to discover this much interest in a single demo, so I decided to extend it to also include native d3d9 code in the hope it will help someone in the future.
Here it is: NativeRenderGLAndD3d9.zip
Here it is: NativeRenderGLAndD3d9.zip
Watch out for my OGRE related tweets here.