PyGameExamplesAndAnswers

StackOverflow            reply.it reply.it


PyGame and OpenGL immediate mode (Legacy OpenGL)

Related Stack Overflow questions:

One example of “immediate mode” is using glBegin and glEnd with glVertex in between them. Another example of “immediate mode” is to use glDrawArrays with a client vertex array (i.e. not a vertex buffer object). […]

Primitive and Mesh

Related Stack Overflow questions:

📁 OpenGL immediate mode - Draw points around a spherical shape

📁 OpenGL immediate mode - 2D water particles

Examples:

📁 OpenGL immediate mode - Draw GLU object

Fixed attribute

Related Stack Overflow questions:

Draw lines and polygons

Wavefront .obj file

The OBJ file format is a simple data-format that represents 3D geometry.

Fixed function attributes

Rendering Image in Pygame Using PyOpenGL

is there a way to render points faster OpenGL

Scale, Rotate, Translate

Examples:

individual object transformation

Projection

Orthographic projection

Perspective projection

confusion about glPerspective and GL_POLYGON

Strange “X” on PyOpenGL + PyGame

Camera

First person

Light

Basic OpenGL Lighting
Per Fragment Lighting

Mouse position and Unproject

How to find PyGame Window Coordinates of an OpenGL Vertice?

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

Hit detection

Text

Compare glWindowPos and glRasterPos. While the coordinates of glRasterPos are transformed by the current modelview and projection matrices, glWindowPos directly updates the x and y coordinates of the current raster position.

Texture

Shader

📁 OpenGL immediate mode - immediat mode shader 1

If you use a shader program, then the matrix transformations have to be done in the vertex shader. The Legacy OpenGL matrix stack is deprecated. If you use a shader program and the legacy matrices, then you have to step back to a OpenGL Shading Language 1.20 (#version 120) shader.
In this version the built in uniforms like gl_ModelViewProjectionMatrix can be used. See Lighthouse3d.com - Hello World in GLSL.

e.g.:

# version 120
attribute vec3 a_position;
attribute vec3 a_color;

varying vec3 v_color;

void main()
{
    gl_Position = gl_ModelViewProjectionMatrix * vec4(a_position, 1.0);
    v_color = a_color;
}

Video and Camera