Related Stack Overflow questions:
import pygame
pygame.init()
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, 3)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, 3)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, pygame.GL_CONTEXT_PROFILE_CORE)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, True)
DISPLAYSURf = pygame.display.set_mode((500,475), pygame.OPENGL | pygame.DOUBLEBUF)
Related Stack Overflow questions:
If a named buffer object is bound, then the 5th parameter of glVertexAttribPointer
is treated as a byte offset into the buffer object’s data store. However, the type of the parameter is still a pointer (c_void_p
).
Hence the offset must be cast with c_void_p
. If the offset is 0, the 5th parameter can either be None
or c_void_p(0)
:
loc_col = glGetAttribLocation(shader_program, "color")
glVertexAttribPointer(loc_col, 3, GL_FLOAT, False, 6*4, ctypes.c_void_p(3*4))
Related Stack Overflow questions:
📁 OpenGL immediate mode - Draw a cube with outline
📁 OpenGL immediate mode - Draw a cube with indces and outline
Related Stack Overflow questions:
Related Stack Overflow questions:
Pyrr’s Matrix44
behaves like and is implemented using numpy.array
.
For Numpy arrays the *
operator means element-wise multiplication, while the @
operator means matrix multiplication.
See array
.
The expression
rot = rot_x * rot_y
performs a component-wise multiplication of the elements of the matrix.
The correct operator for the matrix multiplication is:
rot = rot_x @ rot_y
Related Stack Overflow questions:
Related Stack Overflow questions:
It is like wrapping a checkered paper around the sphere. The 3D vertex coordinates form the sphere. The checkered paper is the 2D texture, with the 2D texture coordinates arranged in a grid. Each texture coordinate has to be associated to a point on the sphere (a vertex coordinate).