This lab stands to prepare the moderngl development environment. Below the steps and requirements for initial coding tasks. Please make sure to edit the python provided files; for dependencies, you can add the files you need.
- Install moderngl and its dependencies
- Make sure that the following programs run
01_hello_world.py
06_multiple_objects.py
09_models_and_images.py
- Modify this program to change the box's texture to a correctly aligned TEC logo
- Document how to execute the 3 programs in the section below.
- For documentation and missing dependencies, follow these links:
If Miniconda is not already installed on your system:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh
Follow the on-screen instructions to complete the installation and initialize Conda.
Create and activate a new Conda environment with Python 3.10:
conda create -n myenv python=3.10 conda activate myenv
-
Install
pygame
:conda install -c conda-forge pygame
or usepip install pygame
-
Install
moderngl
(for OpenGL context handling):pip install moderngl
-
Install
PyGLM
(for GLM functionality):pip install PyGLM
-
Install
numpy
:pip install numpy
-
Install
Pillow
(for image handling):pip install pillow
-
Install
objloader
(for handling 3D object files):pip install objloader
In your program, ensure the OpenGL context version and profile are set to 3.3 Core Profile. Insert these lines before the pygame.display.set_mode()
call:
import pygame
# Set OpenGL context to version 3.3 core profile
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)
This ensures that the OpenGL context supports GLSL version 330 as specified in the shaders.
After setting up your environment and ensuring OpenGL context compatibility, run the included files.
- 25% -
01_hello_world.py
is running with no errors - 25% -
06_multiple_objects.py
is running with no errors - 25% -
09_models_and_images.py
is running with the requested change (TEC logo texture) - 25% - Documentation on how to run your programs