This document describes features implemented specifically for the Windows DirectX build that are not available on the Linux/SDL builds.
The Windows build supports fully resizable game windows with intelligent scaling of all UI elements.
- Window can be freely resized by dragging edges or corners
- Aspect ratio automatically maintained during resize:
- Widescreen mode: 16:10 ratio (800:480)
- Standard mode: 4:3 ratio (640:480)
- Implemented via Win32
WM_SIZINGmessage handler inStuntCarRacer.cpp
- All fonts scale proportionally with window size
- Two font sizes automatically adjusted:
- Small font: Base 15pt
- Large font: Base 25pt
- Fonts recreated in
OnResetDevice()when window resizes - Scaling factor calculated by
GetTextScale()helper function
- Cockpit overlay (wheels, dashboard, panels) scales with window
- Maintains proper proportions at any resolution
- Implementation in
Car.cpp::DrawCockpit() - Uses separate X and Y scale factors for accurate rendering
- All text elements maintain proper screen positions
- Dashboard elements (boost, distance, lap time) scale correctly
- Base coordinate system allows consistent positioning across resolutions
- Speedbar dynamically adjusts length and position
#define BASE_WIDTH_WIDESCREEN 800
#define BASE_WIDTH_STANDARD 640
#define BASE_HEIGHT 480float GetTextScale() {
long current_width, current_height;
GetScreenDimensions(¤t_width, ¤t_height);
float base_width = wideScreen ? BASE_WIDTH_WIDESCREEN : BASE_WIDTH_STANDARD;
return current_width / base_width;
}- Windows: Retrieved from DirectX backbuffer (
D3DSURFACE_DESC) - Linux: Hardcoded to base resolution (fixed 800x480 or 640x480)
Modified Files:
StuntCarRacer.cpp: Window message handling, font scaling, text positioningStuntCarRacer.h: Base resolution constantsCar.cpp: Cockpit scaling implementationCar.h: Cockpit rendering constants
Key Functions:
GetScreenDimensions(): Returns current screen width/heightGetTextScale(): Calculates scaling factor for fonts/textMsgProc(): HandlesWM_SIZINGmessages to preserve aspect ratioOnResetDevice(): Recreates fonts at correct scaled sizesDrawCockpit(): Scales cockpit overlay based on resolution
✅ Fully functional
- Window resizing works
- All scaling features active
- Uses DirectX backbuffer dimensions
- Window resizing not implemented in SDL code
GetScreenDimensions()returns hardcoded values- Scaling functions present but return 1.0x (no scaling)
- Game runs at fixed 800x480 or 640x480
- No breaking changes - code is compatible but inactive
To implement dynamic resizing on Linux, the following would be needed:
- SDL window resize event handling
- Dynamic SDL window dimension querying
- SDL aspect ratio constraint implementation
- OpenGL viewport reconfiguration on resize
The scaling logic is already in place in shared code, so Linux would benefit from the same font/cockpit scaling once SDL window resizing is implemented.
Enhanced error logging for DirectX operations to aid debugging.
- All DirectX resource creation calls checked for failures
- Vertex buffer lock operations validated
- Texture loading verified
- Errors logged via
OutputDebugStringW()for debugging
Examples:
if (FAILED(CreatePolygonVertexBuffer(pd3dDevice))) {
OutputDebugStringW(L"ERROR: Failed to create polygon vertex buffer\n");
return hr;
}- Windows: Active - provides debugging information
- Linux: N/A - code not compiled (DirectX-specific)
These Windows-specific features enhance the Windows DirectX build without affecting Linux/SDL builds:
- ✅ Shared codebase maintained
- ✅ No breaking changes to Linux
- ✅ Proper platform guards (
#ifndef linux) - ✅ Code quality improvements benefit both platforms