Jump to content
  • Advertisement
  • entries
  • comments
  • views

Python Set up OpenGL 3 for Python



You need to type commands in the console terminal (you need to run the console terminal as administrator):

pip install GLFW
pip install PyOpenGL
pip install Pyrr
pip install NumPy

Pyrr - for trigonometry and linear algebra

NumPy - for special arrays for OpenGL functions

You will see how to use these libraries in video tutorial below.

Now you are ready to create simple games in Python and OpenGL. See this video tutorial about basics of OpenGL. You can start from the second lesson: Modern OpenGL programming in Python - part 02 - creating a GLFW window

After studying of this tutorial you can rewrite a prototype of the Snake 2D Tutorial: Python Snake Game from deprecated/legacy OpenGL 1 to modern OpenGL 3 and make it 3D with textures and lighting. And you will be able to load 3D models from Blender because the video tutorial above covers loading 3D models from Blender.

How to create an empty window using GLFW:

  • Copy the file below ("main.py")
  • Place glfw3.dll (glfw3.dll.zip) with "main.py"
  • Run the application. For this run the command in the console terminal:
python main.py


import glfw

def main():

    # Initialize glfw
    if not glfw.init():

    window = glfw.create_window(800, 600, "My OpenGL Window", None, None)

    if not window:


    while not glfw.window_should_close(window):


if __name__ == "__main__":



Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By Psychopathetica
      Hey guys. I am extremely interested in jumping into the whole RayTracing bandwagon to get with the times and increase the realism in my app. Problem is, this technology is so new, it is difficult to find any sort of tutorial on this sort of thing, even if it is a simple triangle. However, after doing some digging, the main method used is to use a Compute Shader. To be quite honest, I never used one. I mainly have been using only vertex shaders and fragment shaders. Compute shaders I found are not part of the rendering pipeline at all, but somehow feed information in parallel to the GPU to speed up processing, which adds more confusion because it only feeds information not rendering to the GPU. I could not find any sample code showing what this could look like. And the code that is out there are either too complex with way too much overhead in getting the bits needed in rendering a simple ray tracer, or are all Unity and Unreal Engine. Try Googling it yourself and its mainly all Unity and Unreal Engine, and very difficult to find anything. It gets to the point you end up finding Chinese sites.
      So I gave up in the search and brought up this topic here. I was curious in knowing if any of you have any information in doing a simple Ray Tracer. What is a Compute Shader, and how exactly does a Compute Shader get used for Ray Tracing because I am still lost? Thanks in advance.
    • By mandolinable
      hello I am pretty new to glsl and opengl
      I have the 2 shaders attached and they are compiled successfully but the program linking fails like in exception image attachment what wrong i did ?? , forgive about my bad english

    • By Alex Gomez Cortes
      Hello everyone,
      About a month ago I finished programming the lighting (or at least it is what I thought), because a few hours ago I realized that when I translate the object, the lighting breaks (not when rotating, because I multiply the normals by the transpose of the inverse of the modelMatrix), only if I move the object from the 0,0,0.
      I only have one light, a directional one. 
      Here the rock is at 0,0,0.
      Here the rock is at -10,0,0.

      I only moved it to the left, and as you can see looks like the normals are wrong, but I do not touch them, except when I multiply them by the transpose of the inverse of the modelMatrix (if I do not multply the normals by that matrix the lighting doesnt break but when the object rotates the light rotates with it). So, is there a way to have the normals well for translating and rotating? 

      Now I can translate the object and the lighting doesnt brake, but if I rotate it the light rotates with it.

      Now I can rotate it but if I move it the lighting breaks.
      Thanks a lot!!
    • By Gnollrunner
      I'm currently using Direct  X 11 for my procedural world/MMO project.  I've tried to find a freeish game engine or simply graphics engine that supports 64 bit coordinates (CPU side), but apparently there is no such animal.  Right now my investment in Direct X is very small as the vast majorly of the code is straight C++ and the graphics is isolated into an interface class. However now I'm going get more into the GPU stuff and I was wondering if it would be better to switch to something else that would give the program better portability.  I was leaning towards Vulkan for no other reason than it seems to be all the rage (ha, ha), but I wanted to get some opinions from folks with more GPU programming experience.
    • By Josheir
      I am trying to visualize if the attached diagram of data of triangles is correct for the attached hill image.  I used a nested for loop to find all triangles with any vertices having a height greater than zero.  The two triangles marked with an X surprisingly have no height values and the shape of the triangles is odd to me.  The triangles marked with A are left triangles and the triangles marked with B are right triangles.  The rendering was done in OpenGL with C++, and the X coordinates and  Z coordinates are by convention.  
      The one point with a height is shown here:
      void addHillsManually() { heightMapFromArray[20][20] = .5; } Thank you,


Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!