u/Hot-Bodybuilder-2687

The beginning of a Voxel engine journey !

The beginning of a Voxel engine journey !

Hi guys !
That be some years I work with godot, and i've start a project with godot by using renderingserver etc... etc... but performance stay bad (maybe I do things not correctly + I use ClaudeCode for this so for sure there is a lot of bad things on this project)

So i've wanted to really do something entirely by myself !
I've wanted to use a language that be like GDscript : Simple.

So I have do that with python :

import glfw
import moderngl as mgl
import numpy as np


class App:
    def __init__(self):
        self.vao = None
        glfw.init()
        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)
        glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
        glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
        self.window = glfw.create_window(1280, 720, "Voxel Engine", None, None)
        glfw.make_context_current(self.window)
        self.ctx = mgl.create_context()
        self.ctx.clear_color = (0.3, 0.6, 0.9, 1.0)
        self.setup_shaders()

    def run(self):
        while not glfw.window_should_close(self.window):
            self.ctx.clear(color=(0.3, 0.6, 0.9, 1.0))
            self.vao.render()
            glfw.swap_buffers(self.window)
            glfw.poll_events()

        glfw.terminate()

    def setup_shaders(self):
        rendering_program = self.ctx.program(
            vertex_shader = '''
            #version 330
            in vec2 in_vertices_position;
            void main() {
                gl_Position = vec4(in_vertices_position, 0.0, 1.0);
            }
    
            ''',
            fragment_shader = '''
            #version 330
            out vec4 out_color;
            void main() {
                out_color = vec4(1.0, 1.0, 1.0, 1.0);
                }
            ''',
        )

        triangle_vertices = np.array([
            -0.5, -0.5,
            0.5, -0.5,
            0.0, 0.5
        ], dtype=np.float32)

        vbo = self.ctx.buffer(triangle_vertices.tobytes())

        self.vao = self.ctx.vertex_array(rendering_program, vbo, "in_vertices_position")

if __name__ == "__main__":
    App().run()

And that work I have a white triangle !

https://preview.redd.it/dibqdv0tno0h1.png?width=1282&format=png&auto=webp&s=510b7d7eaa03e6f049dd36e1691f30890dd99686

Next step : do a face with an IBO.
Its really nice to learn some OpenGL etc... etc... and by don't using AI, I really feel better things by doing this project.
Everything is made by me, and thats really enjoyable.

reddit.com
u/Hot-Bodybuilder-2687 — 10 days ago