
gittech. site
for different kinds of informations and explorations.
Minecraft clone from scratch with only OpenGL
Published at
6 days ago
Main Article
Minecraft from scratch
A Minecraft clone from scratch with only modern OpenGL. No game engines or frameworks.
https://github.com/user-attachments/assets/206225e1-12f3-42da-ae13-1566fba06f21
Features
- Infinite and procedurally generated terrain using Perlin noise
- Physics engine with collision detection
- Day/night cycle
- Dynamic lighting
- Block placement and destruction
- Tree generation
- Basic cave systems
- Dynamic chunk loading/unloading based on player position
- Simple culling techniques for rendering optimization
- Simple inventory system
- Flying mode
Installation
# clone
git clone https://github.com/GianlucaP106/minecraft minecraft && cd minecraft
# run game (requires go)
go run .
Controls
- WASD - Movement
- Space - Jump
- F - Toggle flying mode
- Mouse - Look around
- Left Click - Break block
- Right Click - Place block
- 1-9 - Select inventory slot
Technical Highlights
Graphics
- Written in OpenGL 4.1
- Custom shader programs for blocks, UI elements, and effects
- View frustum culling for performance optimization
World Generation
- Multi-octave Perlin noise for terrain generation
- Biome system affecting terrain height and features
- Procedural cave system generation
- Dynamic tree placement based on biome
Physics
- Custom physics engine
- Rigid body dynamics
- Custom collision detection and response
- Jump mechanics
Architecture
The game is built with a component-based architecture, with key systems including:
- World: (chunk loading, block updates)
- World Generator: (noise, terrain, tree, biome)
- Physics engine and Rigid Body (collision, movement)
- Player, Camera and Ray
- Chunk and Block
Dependencies
- github.com/go-gl/gl/v4.1-core/gl
- github.com/go-gl/glfw/v3.3/glfw
- github.com/go-gl/mathgl/mgl32