Does Blender use OpenGl or DirectX? Or is it all done from scratch?
You can look at the blender source code and see it's written in both python and C/C++ -- less python, more C. OpenGL is referenced frequently in the code, while DirectX only rarely. So there ya go.
Does Blender use OpenGl or DirectX?
All graphics output of Blender is done using OpenGL.
Or does it use a programming language (python?) to do everything from scratch?
Why "or"? An API doesn't substitute a programming language. Blender has been programmed in C, C++ and Python. OpenGL is used to render everthing on screen, including the user interface.
Expanding on what datenwolf said. Blender for the majority was written in C, the Game Engine was written in C++ and the entire application has Python bindings (meaning you can use python within the application). Blender uses OpenGL and has a special engine (comprised of opengl calls and functionality, mostly legacy but pushing to use modern stuff, vbos etc) that is used to draw the interface and power its 3d capabilities called GHOST.
For such questions I found ohloh to be useful. It is a site which generates statistics on open source projects. One of the statistics is a list of different programming languages used in the project. You can look at the statistics for Blender here.
ohloh is also useful for identifying the tools a project used and/or to compare to similar projects.
Related
So, I have been wanting to make my own GUI library for Python 3. And I couldn't find anything anywhere on where to start. So I decided to ask the question here.
Goal:
Be able to make Python Libraries without using other libraries.
Edit:
So, If I was to make a Library in C for Python. How would I go about doing that.
Tkinter is a python wrapper around tcl/tk's GUI toolkit , similar to how PySide/PyQt and wxPython are wrappers around the Qt and Wx C++ GUI toolkits.
If you wanted to build your own from scratch you would have to make use of existing operating system APIs and/or use something cross platform like OpenGL. For a good example of the latter you can look into Kivy, which is built on OpenGL
Different operating systems have different API's for doing GUI's. So how you have to do it very much depends on the operating system. I think one of the reasons that Python uses Tkinter is because it was already ported to different operating systems.
GUI API's are typically provided as shared libraries, often written in or compatible with C.
If you want to use those from Python, you will have to write a Python wrapper for them. For example using ctypes. Doing that requires a significant understanding of (1) Python, (2) ctypes and (3) the GUI API in question. If more than one of these technologies is new to you, I would not recommend taking on such a project.
I have developed an application in C which works on command line interface. I want to make my code display data over GUI, and I would also want to provide a window waiting for user input.
I need some directions on how to proceed. I came across a few sites saying libraries in python will serve the purpose.: WxPython, TKinter, PyQt
How to start abt? How do I link my C application to the GUI? And should I develop a GUI application, too, and then link it to my C application?
I am a beginner. Please help.
Thanks.
I recommend using GTK+ or Qt for your application.
They are popular, cross-platform and both have extensive documentation and great community.
Take a look at Cython for easily connecting the C world with the Python world if you decide to link your C code with the UI, it's highly convenient as a glue language.
Depending on your application, it might be a good option to keep it as a command line application that you call from a python program. The subprocess module is the usual route here, but there are some tools that can help even more -- like commandwrapper.
As for the GUI, apart from the already mentioned (perfectly viable) alternatives in other answers, Kivy is an interesting newcomer, and pyFLTK is a lightweight, easy-to-learn, old-school approach. These are a bit exotic, but it's good to know they exist.
Finally, QT5 was recently released and it shows a lot of promise. You might want to consider it if you don't mind writing C++, it's various language wrappers are not ready yet.
You'll need to install the libraries for whichever GUI framework you want to use. WxWidgets is available for C, as well as Python, so you don't really need to link to the Python library. Other options (as indicated by Intelis) are GTK+ and QT.
If you're developing in Windows, then you may also use the Windows API to create your GUI application. Alternatively, you might consider using C++ (Either managed C++ or MFC).
Once you have installed the appropriate libraries, you will need to include them in your C source by using the #include <...> directive.
Take a look at these sites:
WxWidgets Tutorial.
GTK+ Tutorials
QT Tutorial
Looking to put together a 3D side-scrolling action platformer. Since this is my first time trying to put together a non-simple adventure game, I'm at a loss for which engine to consider.
I would prefer one that supports scripting in python, since that's my primary language. Without tight controls, the game will suck... so speed is a priority. Cross-platform is also important to me.
Any suggestions?
Active game engines with Python scripting
Panda3D is a framework and requires low-level programming
pyglet is a multimedia library and requires low-level programming
Inactive game engines with Python scripting
ratcave (based on pyglet, inactive since 2018)
Engendro 3D (inactive since 2018)
PySoy3D (inactive since 2016)
Delta3D (inactive since 2016)
sylphis3d (inactive since 2015)
Eden (based on Panda3D, inactive since 2014)
Python-Ogre (inactive)
Blender Game Engine (discontinued)
The OGRE engine used to have 3rd party Python bindings, as of 1.10 official Python bindings. As of 2.2 there is no official or 3rd party Python support.
Panda3D:
http://www.panda3d.org/
It's a 3D game engine written in C++ but specifically designed for use in Python. Disney has used it for some of its games in the past, including 2 MMOs. There is support for shaders, etc., and is BSD licensed. Windows, Mac, and Linux are all supported, and there appears to be a browser plugin. I haven't used it personally, though.
Try PyGame and PyOpenGL together, here are some examples.
You also may use the Blender Game Engine.
Pyglet is another one.
http://www.pyglet.org/
See Differences between Python game libraries Pygame and Pyglet?
PyOgre is the Python bindings of the C++ graphics engine Ogre.
Unfortunately there are no game engines in the modern sense of the word (includes editors, tools, physics, not just an audio and graphics programming library), that support Python scripting.
However there are modern game engines, which have benefits like level editors and built-in physics that might make up for the lack of Python:
Godot (GDScript which has syntax similar to Python, open source)
Unity (C#, proprietary)
Unreal (C++, proprietary)
This is what I would use: Unity. It has a learning curve, but once you get the hang of it, it's very powerful. It uses your choice of Java, Boo(which I hear is very similar to Python), and C#.
Regardless of what you pick, I would advise you learn Java. It's a widespread language, so it should open up lots of options for you in various ventures. Learning another language is always very good for you.
Both Unity and Unreal have excellent third party Python Bindings. Its been a while since I've used the Unity one, but at the time it was perfectly competent. It does use Iron Python, so its not the C Python implementation, but at least its not Boo which I believe has been dropped from Unity anyway.
https://forum.unity.com/threads/python-interpreter-in-unity.86461/
And heres the Unreal one. I've used this a lot, and it works great. Its a bit of a headache to install initially, and I'd advise against it if your planning to deploy mobile as you'd have to get your hands dirty with some messy C++ and a very tight runtime. But if your writing a desktop game, its perfectly competent.
https://github.com/20tab/UnrealEnginePython
I just downloaded the original Python interpreter from Python's site. I just want to learn this language but to start with, I want to write Windows-based standalone applications that are powered by any RDBMS. I want to bundle it like any typical Windows setup.
I searched old posts on SO and found guys suggesting wxPython and py2exe. Apart from that few suggested IronPython since it is powered by .NET.
I want to know whether IronPython is a pure variant of Python or a modified variant. Secondly, what is the actual use of Python? Is it for PHP like thing or like C# (you can either program Windows-based app. or Web.).
IronPython isn't a variant of Python, it is Python. It's an implementation of the Python language based on the .NET framework. So, yes, it is pure Python.
IronPython is caught up to CPython (the implementation you're probably used to) 2.6, so some of the features/changes seen in Python 2.7 or 3.x will not be present in IronPython. Also, the standard library is a bit different (but what you lose is replaced by all that .NET has to offer).
The primary application of IronPython is to script .NET applications written in C# etc., but it can also be used as a standalone. IronPython can also be used to write web applications using the SilverLight framework.
If you need access to .NET features, use IronPython. If you're just trying to make a Windows executable, use py2exe.
Update
For writing basic RDBMS apps, just use CPython (original Python), it's more extensible and faster. Then, you can use a number of tools to make it stand alone on a Windows PC. For now, though, just worry about learning Python (those skills will mostly carry over to IronPython if you choose to switch) and writing your application.
IronPython is an independent Python implementation written in C# as opposed to the original implementation, often referred to as CPython due to it being written in (no surprise) C.
Python is multi-purpose - you can use it to write web apps (often using a framework such as Django or Pylons), GUI apps (as you've mentioned), command-line tools and as a scripting language embedded inside an app written in another language (for instance, the 3D modelling tool Blender can be scripted using Python).
what does "Pure Python" mean? If you're talking about implemented in Python in the same sense that a module may be pure python, then no, and no Python implementation is. If you mean "Compatible with cPython" then yes, code written to cPython will work in IronPython, with a few caveats. The one that's likely to matter most is that the libraries are different, for instance code depending on ctypes or Tkinter won't work. Another difference is that IronPython lags behind cPython by a bit. the very latest version of this writing is 2.6.1, with an Alpha version supporting a few of the 2.7 language features available too.
What do you really need? If you want to learn to program with python, and also want to produce code for windows, you can use IronPython for that, but you can also use cPython and py2exe; both will work equally well for this with only differences in the libraries.
IronPython is an implementation of Python using C#. It's just like the implementation of Python using Java by Jython. You might want to note that IronPython and Jython will always lag behind a little bit in development. However, you do get the benefit of having some libraries that's not available in the standard Python libraries. In IronPython, you will be able to get access to some of the .NET stuff, like System.Drawings and such, though by using these non-standard libraries, it will be harder to port your code to other platforms. For example, you will have to install mono to run apps written in IronPython on Linux (On windows you will need the .NET Framework)
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is.
Just to avoid the "just use C" comments, here is why I want to use Python:
There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while.
Thanks for any help.
You may also want to consider using Pyglet instead of PyOpenGL. It's a ctypes-wrapper around the native OpenGL libs on the local platform, along with windowing support (should handle most of the stuff you want to use GLUT for.) The pyglet-users list is pretty active and very helpful.
Well, I don't know if these are the libs the original poster are using but I saw identical issues in a pet project I'm working on (Graphics Engine using C++ and Python) using PyOpenGL.
PyOpenGL didn't correctly pick up the rendering context if it was created after the python script had been loaded (I was loading the script first, then calling Python methods in it from my C++ code).
The problem doesn't appear if you initialize the display and create the OpenGL rendering context before loading the Python script.
What OpenGL library are you using? What windowing library? What version of Python?
Most likely cause I can think of is that your windowing library (SDL or whatever you're using) isn't initializing OpenGL before you start calling into it.
We have neither ideas about random segmentation faults. There is not enough information. What python libraries are you using for opengl? How do you use them? Can you show us your code? It's probably something trivial but my god -skill ends up to telling me just and only that.
Raytracer in python? I'd prefer just doing that in C with those structs. But then, I'm assuming you aren't going to do a realtime raytracer so that may be ok.
Perhaps you are calling an OpenGL function that requires an active OpenGL context, without having one? That shouldn't necessarily crash, but I guess it might. How to set up such a context depends on the platform, and it's been a while since I used GL from Python (and when I did, I also used GTK+ which complicates matters).
Scripts never cause segmentation faults.
But first see if your kernel and kmod video driver working property ...
Extension modules can cause "segmentation fault".