Recently I managed to create a simple voxel engine with pygame and moderngl and everything functions well.
However when I start my program the pygame window is pitch black for about 10 seconds, looking at my code I managed to find the instruction which caused such a slowdown and I wanted to replace the solid black color with a loading screen (just an image for the moment).
The instruction was the initialization of the scene object (I have a system with multiple classes for different purposes and the scene class is meant to group all the parts that compose a frame such as chunks, clouds or water).Here’s the code of scene.py:
from settings import *
import moderngl as mgl
from world import World
from world_objects.voxel_marker import VoxelMarker
from world_objects.water import Water
from world_objects.clouds import Clouds
class Scene:
def __init__(self, app):
self.app = app
self.world = World(self.app)
self.voxel_marker = VoxelMarker(self.world.voxel_handler)
self.water = Water(app)
self.clouds = Clouds(app)
def update(self):
self.world.update()
self.voxel_marker.update()
self.clouds.update()
def render(self):
# chunks rendering
self.world.render()
# rendering without cull face
self.app.ctx.disable(mgl.CULL_FACE)
self.clouds.render()
self.water.render()
self.app.ctx.enable(mgl.CULL_FACE)
# voxel selection
self.voxel_marker.render()
(Version before I tried to implement the loading screen, trying to implement it the code became a mess and i prefered to delete it)
I tried to render a fullscreen quad and place the image as a texture over it but it didn’t have any effect (might be because of me because it’s my first “big” project in moderngl), even clearing the buffer with a color different from black had no effect.
My desired effect would be that at the start of the program the loading screen image would be displayed and it would disappear as soon as the game can be correctly displayed.
Thanks for any replies, might be a dumb question but I’m quite new to moderngl and 3d graphics in general.