Does pyGame do 3d?


Does pyGame do 3d?



I can't seem to find the answer to this question anywhere. I realise that you have to use pyOpenGL or something similar to do openGL stuff, but I was wondering if its possible to do very basic 3d graphics without any other dependencies.




9 Answers
9



No, Pygame is a wrapper for SDL, which is a 2D api. Pygame doesn't provide any 3D capability and probably never will.



3D libraries for Python include Panda3D and DirectPython, although they are probably quite complex to use, especially the latter.





What is wrong about this? Pygame does not do 3d. PyOpenGL does 3d. Re-read his question.
– Kylotan
Sep 23 '11 at 12:06





Yes it does I am currently writing a 3D game. And I'm not even using OpenGL. I am using a method like the one Horst JENS posted.
– Cnorwood7641
Apr 11 '14 at 20:04




Well, if you can do 2d you can always do 3d. All 3d really is is skewed 2 dimensional surfaces giving the impression you're looking at something with depth. The real question is can it do it well, and would you even want to. After browsing the pyGame documentation for a while, it looks like it's just an SDL wrapper. SDL is not intended for 3d programming, so the answer to the real question is, No, and I wouldn't even try.





I have tried. In fact, I've written a whole emulation of OpenGL in C++ before. It's nasty, and learning a real 3D API is a MUCH better idea until you know what you're doing with 3D technology.
– imallett
Feb 29 '12 at 5:54



You can do pseudo-3d games ( like "Doom" ) with pygame only:



http://code.google.com/p/gh0stenstein/



and if you browse the pygame.org site you may find more "3d" games done with python and pygame.



However, if you really want to go into 3d programming you should look into OpenGl, Blender or any other real 3d lib.



Python Soya can render 3d graphics on pygame surfaces.



If you want 3D projection functions and all of that stuff you'll have to use a 3D API but if you want to do a basic 3D look I recommend Peter's Website tutorial: http://www.petercollingridge.co.uk/pygame-3d-graphics-tutorial



What you see as a 3D is actually a 2D game. After all, you are watching your screen, which (normally ;) ) is 2D. The virtual world (which is in 3D) is projected onto a plane, which is then shown on your screen. Our brains then convert that 2D image into a 3D one (like they do with the image of our eyes), making it look like it's 3D.



So it's relatively easy to make a 3D game: you just create a virtual world using a multidimensional matrix and then project it each loop on a 2D plane, which you display on your screen.



One tutorial that you can put on your way to 3D programs (using pygame) is this one .



Pygame was never originally meant to do 3d, but there is a way you can do 3d with any 2d graphics library. All you need is the following function, which converts 3d points to 2d points, which allows you to make any 3d shape by just drawing lines on a screen.


def convert_to_2d(point=[0,0,0]):
return [point[0]*(point[2]*.3),point[1]*(point[2]*.3)]



This is called pseudo 3d, or 2.5d. This can be done, but may be slow, and is extremely difficult to do, so it is suggested that you use a library meant for 3d.



It is easy to make 3D driver for PyGame. PyGame has some assets for 3D game development.
Now I am developing Py3D driver with using PyGame. When I'll end then I'll show you link to download Py3D. I tried to make 3D game with PyGame and I need just small addon for PyGame. It is wrong you think you must use SDL, PyOpenGL, OpenGL, PyQt5, Tkinter. All of them are wrong for making 3D games. OpenGL and PyOpenGL or Panda3D are very hard for learning. All my games maked on those drivers was awful. PyQt5 and Tkinter aren't drivers for making games, but them've got addons for it. Don't try to make any game on those drivers. All drivers where we need to use module math.py are hard. You can easily make small addon for them, I think everybody can make driver for PyGame by 1-2 weeks.



Pygame is just a library for changing the color of pixels (and some other useful stuff for programming games). You can do this by blitting images to the screen or directly setting the colors of pixels.



Because of this, it is easy to write 2D games with pygame, as the above is all you really need. But a 3D game is just some 3D objects 'squashed' (rendered) into 2D so that it can be displayed on the screen. So, to make a 3D game using only pygame, you would have handle this rendering by yourself, including all the complex matrix maths necessary.



Not only would this run slowly because of the immense processing power involved in this, but it would require you to write a massive 3D rendering/rasterisation engine. And because of python being interpreted it would be even slower. The correct approach would be to have this process run on the GPU using (Py)opengl.



So, yes it is technically possible to do 3D using only pygame, but definitely not recommended. I would suggest you learn Panda3D or some similar 3D engine.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?