photo

OpenGL Example

Recommended Posts

Hi !

My team and I are trying to write pure OpenGL code for textures. 

We could see that there are multiple examples for DirectX but none for OpenGL.

So our question is :

Could you provide us some examples that use OpenGL code for textures please ? We would be really grateful.

Best regards,

Antoine YVAN

Share this post


Link to post

Hello Antonie,

Are you interested in some particular sample rewritten for OpenGL?

Thanks.

Share this post


Link to post

Hello Morbid,

Sorry my question wasn't really accurate for what we need.

We use Unigine to simulate 3D avionics panels.

We have a 3D simulated screen in which will be implemented native OpenGL instructions.

So we would need an example of code where native OpenGL is used in Unigine.

Thanks for your answer,

Antoine

Share this post


Link to post

If I understood everything right, you just can include GL and call the required functions, for instance:

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);

Please let me know if you're looking for some specific sample.

Share this post


Link to post

Hi Morbid thanks for your reply.

Can you show us how it would look like with a complete texture render sample ?

Thanks,

Antoine

Share this post


Link to post

Okay, we'll be back with this in 1 or 2 days.

Thanks,

Share this post


Link to post

Antonie, I'm sorry for being a fool regarding OpenGL, couldn't come with a proper questions. Finally, consulted a render developer, and she'd like to clarify a couple of things:

  1. Which DirectX samples you're referring to?
  2. Are you looking for a way to create a texture with OpenGL
  3. or to render to a texture something?
  4. What stopped you from using API (Render, RenderState or Texture classes)

Thanks.

Share this post


Link to post

Hello Morbid,

I'm sorry for not being clear enough, I'll try to be more accurate.

1. I misunderstood my manager when I said this, we did not see any DirectX samples. (sorry for that)

2-3. We are looking for a way to render a texture.

4. We have the OpenGL code delivered to us and we just need to integrate it to Unigine. We can't work with Unigine dedicated classes for this part.

I hope our need is more understandable.

Thanks!

Share this post


Link to post

Hello to all,

The directX samples are these ones, but they may not demonstrate the good approach for what we would like to implement..

Basically the need is to render OpenGL stuff into a Unigine Texture.

An simple example would help because we are not sure how to go with the UNIGINE Api (Render, RenderState or Texture classes)

On other engine,  we are using a Camera Node that create the RTT context and attach to it an external node that contains the the opengl code.

We were wondering the best way to achieve that with UNIGINE.

That simple video may help to illustrate our need:

 * https://www.youtube.com/watch?v=HXOsPrvkOa8

Best regards,

Roland

 

Share this post


Link to post

Hi,

Meanwhile, we prepared an example of rendering a texture in a screen space color.

Please, see attached files. Other thing that might help you is C++ GBuffer Read/Write samples. Are you familiar with them? These ones available in the SDK Browser -> C++ API -> Render.

18 hours ago, Touati.Roland said:

Basically the need is to render OpenGL stuff into a Unigine Texture.

Maybe all you need is Texture::fromGLtexture2D?

Thanks.

opnegl_sample.zip

Share this post


Link to post

Hello Morbid,

Thank you for the sample. I is a good start.

I've a question regarding the opengl context.

Our need would be to render opengl stuff that rely on fixed function pipeline. (the opengl code is issued from code generator for that rely on an subset of opengl 1.0 and 1.1)

So for my tests,  I've modified the Wrapper to add the LoadIdentity() opengl function. When I call this function in the opengl callback I get the following  error:

OpenGL error: invalid operation

That leads to my question. Does UNIGINE address only a strict opengl context that does no support the fixed function pipeline ? and if Yes, is there a possibility to use a Compatible opengl context in my main appilcation, in order to enable the fixed function pipeline for our rendering to texture need. 

(I've attached my modified GLWrapper in case it can help)

Thanks 

Roland.

GLWrapper.tgz

Share this post


Link to post

Thanks Roland,

We tried to find a way to make code from OpenGL 1.x work, but, unfortunately, it wouldn't. UNIGINE uses Core Profile which is incompatible with these instructions. There are two possible ways to solve this:

  • Rewrite your code using Ffp
  • Experiment with CustomApp plugin and create your own OpenGL context. I'd like to remind you that engine can use only one App plugin at a time.

We plan to deprecate OpenGL in the near future (2021 I guess), so maybe, it's better to look at some newer solutions.

Thanks.

Share this post


Link to post

Hi Morbid,

Thanks for your answer.

We will try the CustomApp approach on a first step.

But now, we are concerned about the OpenGL deprecation. FYI, we have several projects using Unigne and we are currently trying to addressing a Virtual Reality environment for simulation.

In our simulation(s), when available, the equipment code is recompiled on simulation target platform. The OpenGL codes I was referring to, comes from embedded airborne software and cannot be modified. (simulation must be fully representative of the real equipment, use for validation etc, and even during development phase of the equipment )

It fear a increasing complexity on simulation side. (for example streaming/encoding the opengl apps as video content could be a solution, but will require move power from simulation PCs and some design change)

We will come back to you to discuss about UNIGINE roadmap and how to manage that information from our (industry) point of view.

Thank you for your time.

best regards,

Roland

Share this post


Link to post
On 9/11/2020 at 7:23 PM, Touati.Roland said:

We will come back to you to discuss about UNIGINE roadmap and how to manage that information from our (industry) point of view.

Roland, I'd like to know how exactly you see this integration to understand what features will be required on the Engine side. All details regarding this solution are welcome :)

Thanks!

Share this post


Link to post

Hello Morbid.

We are coming back to you regarding OpenGL context in Unigine.

You advised us before that we should try to experiment and create our own OpenGL context using CustomApp plugin.

After checking every CustomApp’s samples, we found out they all run CustomApp::InitGLContext() which  create an OpenGL 4.5 Core Profile context.

This leads to our questions :

Can we create our own Compatible Context and initialize Unigine Engine with it ?

If yes, can you explain us how to do it ?

If no, did you mean that we have to create a second context and perform the texture data exchange manually between these two contexts ?

Thanks

Antoine
 

Share this post


Link to post

Antoine,

Quote

Can we create our own Compatible Context and initialize Unigine Engine with it ?
they all run CustomApp::InitGLContext() which  create an OpenGL 4.5 Core Profile context.

You can pass pointer to the context that is created by user via CustomApp::initGL(). I've also sent you sources for that method. Hope that helps.

Thanks!

Share this post


Link to post