Drawing into the viewport with modern OpenGL

I made 13 examples which are showing how to draw with OpenGL directly into the Blender viewport.


It was very tricky to get the drawing working in Blender.
Because if you make an fault the Blender UI can be overdrawn or Blender will crash instantly.

The last two examples can be used to rebuild an existing mesh.

22.12.2015 Added mesh optimisation and texturing example.

Download:
https://www.dropbox.com/s/znigzwuxoqjt2m1/BlenderOpenGL.zip?dl=0dsddfdf
HG1

Wow, this is really nice! I tested on my Intel HD Graphics and I got 80 fps on the high-poly mesh.
I had to modify the shaders a little bit, my graphics card only supports OpenGL 1.2

What can it be used for?

It can be used to implement mesh like things that actually not supported by the BGE.
Like tessellation shades or adjacency geometry.

Can it be used to make marching cubes algorithm work?Have you heard of it?

Wow nice Resource. I think that can be usefull for lot of things in glsl shaders.
Thanks for your awesome work! :slight_smile:

Basically yes. But you don’t get any collision from the generated mesh because the mesh will not be transferred to Bullet engine this way.
If you need collision you need the add a plan (subdivided Blender plane), under the player, that will be moved and distorted the same way as your environment is.

Thanks very much for your new openGL ressources, as awsome as usual :slight_smile:

I updated my examples.
I implemented a mesh optimizing code which will reduce the amount mesh vertices.
I also added an example with texturing. There is a little known bug. The texture will not correctly freed.

Do i need to free it myself or it will take care of itself?When i press esc.

When you press ESC the textureID will not be freed. Every start of the BGE it will count up.
It will be only freed if you close Blender.
I actually don’t found a good way to free it. Maybe I can fix this in the future.

The framerate for the textured land is in the hundreds.What is the real framerate?

The framerate that is displayed should be the correct one.
On my old GTX 460 it runs with between 970 and 1070 Fps. But actually there is no lighting and shadowing.
With one light and no shadows it will run approximate with 860Fps.

I love your exampls because they prove what is possible,

is there any way to make addon though? to take advantage of things like this?

encapsulate them for the user in some kind of function?

like a terrain system, or???

I think a addon is not necessary. Because actually you only need to copy and paste the code.

Which one can I draw over existing geometry with?

I will take a crack at replacing physics objects with high poly imposters,

The last four examples (OpenGLMesh to OpenGLMesh4, layer 5) grabs the original mesh data.
So the original physic mesh is still exiting.

So this is a true path to fast instancing of geometry in the bge?
Can we batch ourselves? How hard would that be to impliment static mesh batching with a atlas?

Thank you again,
Happy Holidays.

Yes. You can do this this way.
I don’t know how long it will take to get it working. But if you also want that LOD working too, it will get much more complicated.

Let me know if you want a kit to test it with,
(wrectified level assembly kit)

This makes me so happy!

All that is left for wrectified is to be able to generate a unique compound object shape per instance that is a root or a compound…

Can you save a matrix of static instances as a pickle file? I have a system that I can use to build levels in game, and I pickle the data, but I doubt this is a format that GLSL can grab… :expressionless: