A real-time 3D sphere rendered entirely from numeric digits, built with legacy OpenGL and WinAPI. The sphere rotates continuously with digits mapped across its surface using spherical coordinates.
Digits in teal (
RGB 0, 0.545, 0.545) scatter across a rotating sphere. Each digit's value is derived from its 3D position on the sphere surface.
- Spherical surface sampling — vertices generated via nested phi × theta loops
- Digit-mapped surface — each vertex value computed as
|x + y + z| × 10 mod 10 - Bitmap font rendering — uses
wglUseFontBitmapswith Courier New Bold 18px - Orthographic projection — 16:9 aspect ratio at 1920×1080 resolution
- Smooth real-time rotation — X axis +0.3°/frame, Y axis +0.5°/frame (~60fps via
Sleep(16)) - Teal digit coloring —
glColor3f(0.0, 0.545, 0.545)
- Windows OS (WinAPI required)
- OpenGL 1.x — fixed-function pipeline (no shaders needed)
- MSVC or MinGW compiler
- Libraries:
opengl32,gdi32,user32
Since everything is unified into a single file, you only need to compile one source file.
Requirements: Windows OS, MinGW/MSVC compiler, and standard Windows libraries (opengl32, gdi32, user32).
g++ start.cpp -o startall.exe -DUNICODE -D_UNICODE -lopengl32 -lgdi32 -luser32
./startall.exeopengl-digit-sphere/
├── circlenum.cpp
└── README.md
└── squarechange.cpp
└── start.cpp
- Window & OpenGL context dibuat menggunakan WinAPI (
WNDCLASS,wglCreateContext) - Font bitmap di-generate via
wglUseFontBitmapslalu disimpan dalam display list - Setiap frame,
display()dipanggil — menghitung posisi (x, y, z) tiap digit dari koordinat bola (phi, theta) - Digit ditampilkan di posisi 3D menggunakan
glRasterPos3f+glCallLists - Rotasi diupdate setiap iterasi loop utama sebelum
SwapBuffers
Kamu bisa ubah parameter berikut di circlenum.cpp:
| Parameter | Default | Keterangan |
|---|---|---|
radius |
0.6f |
Radius bola |
angleX += |
0.3f |
Kecepatan rotasi sumbu X |
angleY += |
0.5f |
Kecepatan rotasi sumbu Y |
| phi/theta step | 0.12f |
Kerapatan digit di permukaan |
| Font size | -18 |
Ukuran font (negatif = pixel height) |
Sleep(16) |
16ms | Target ~60fps |
The application starts with a blank canvas. Use the following keys to interact:
C: Render Sphere mode.S: Render Cube mode.Spacebar: Clear screen (Empty mode).
- Menggunakan OpenGL fixed-function pipeline (legacy) — tidak kompatibel dengan OpenGL Core Profile
itoa()adalah fungsi non-standard (tersedia di MSVC & MinGW, tidak di GCC Linux)- Tidak ada depth sorting untuk digit — urutan render mengikuti loop, bukan jarak kamera
- Window size hardcoded ke 1920×1080
MIT License.