jonwright / pyopengltk

OpenGL frame for Python/Tkinter via ctypes and pyopengl
MIT License
54 stars 13 forks source link

Adding sprites #19

Closed ShaunKulesa closed 3 years ago

ShaunKulesa commented 3 years ago

What technique should i use for adding a sprite image?

ShaunKulesa commented 3 years ago

I found how to do it with pygame, is it possible to use pygame and opengl using your module?

einarf commented 3 years ago

It is technically possible to render to an pygame surface, copy that data into a texture and display it using OpenGL. That is the only way you could display anything from pygame in OpenGL.

ShaunKulesa commented 3 years ago

@einarf would I have to make a variable that equals the sprite data, then load that variable using opengl? And if so how?

einarf commented 3 years ago

There is an example here using moderngl : https://github.com/moderngl/moderngl-window/blob/820b7d7c6d4faea3cff2637a150c91582096557b/examples/advanced/pygame2_simple.py#L55-L73

You would have to figure out on your own how to use plain opengl functions to write to your own texture and display it.

ShaunKulesa commented 3 years ago

I did find this texture mapping

def OnInit( self ): """Load the image on initial load of the application""" self.imageID = self.loadImage ()

http://pyopengl.sourceforge.net/context/tutorials/nehe6.html