MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
pong Directory Reference

Files

 
pong.cpp

Detailed Description

Vulkan Pong

pong_img

A Vulkan implementation of the classic Pong game, ported from the OpenGL version.

Features

  • Full Vulkan rendering pipeline
  • 3D cube-based paddles and a textured sphere ball
  • AI opponent
  • Keyboard and mouse/touch input support
  • Optional ping.wav paddle-hit sound when SDL3_mixer support is enabled
  • Wireframe mode toggle
  • Grid rotation for 3D viewing effects
  • Text overlay for score and FPS display

Controls

Key/Input Action
Arrow Up/Down Move paddle 1 up/down
Mouse Motion Control paddle 1 position
W/A/S/D Rotate the 3D view
Page Up/Page Down Zoom in/out
Q Reset view rotation
R Reset game (scores and positions)
SPACE Toggle wireframe mode
ENTER Reset camera and view
ESC Quit game

Building

The project is built as part of the libmx2 build system:

cd libmx2/libmx/build
cmake ..
make vk_pong_game

Running

./vk_pong_game -p /path/to/vk_pong/

Or specify resolution:

./vk_pong_game -p /path/to/vk_pong/ -r 1920x1080

Required Assets

The game requires the following assets in the data path:

  • bg.png - Background texture
  • font.ttf - TrueType font for text rendering
  • cube.mxmod - paddle model
  • better_sphere.obj and better_sphere.mtl - ball model and material
  • ball.png and paddle_texture_manifest.txt - object textures
  • ping.wav - paddle-hit sound effect when built with mixer support
  • Compiled SPIR-V shaders: vert.spv, frag.spv

Architecture

This Vulkan pong implementation extends the mx::VKWindow base class, overriding:

  • initVulkan() - Initialize Vulkan and load game-specific resources
  • event() - Handle keyboard, mouse, and touch input
  • proc() - Game logic update (physics, AI, scoring)
  • draw() - Render the game objects using the Vulkan pipeline