inital, almost working cross-compilation setup with Visual Studio and cmake

This commit is contained in:
Colin Sames
2026-04-03 15:51:02 +02:00
commit 39d875a316
356 changed files with 326295 additions and 0 deletions

12
game/CMakeLists.txt Normal file
View File

@@ -0,0 +1,12 @@
add_executable(game
"src/main.cpp"
)
target_link_libraries(game PRIVATE engine)
# On Windows, use the WINDOWS subsystem (no console) for release only
if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(game PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
endif()

13
game/src/__main.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "Engine.h"
#include <SDL3/SDL_main.h>
int main(int argc, char* argv[])
{
Engine engine;
if (!engine.Init())
return 1;
engine.Shutdown();
return 0;
}

78
game/src/main.cpp Normal file
View File

@@ -0,0 +1,78 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cstdio>
#include <iostream>
int main(int argc, char* argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO))
{
std::printf("SDL_Init Error: %s\n", SDL_GetError());
return 1;
}
SDL_Window* window = SDL_CreateWindow(
"2D Game Engine",
1280, 720,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
if (!window)
{
std::printf("SDL_CreateWindow Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
if (!renderer)
{
std::printf("SDL_CreateRenderer Error: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
SDL_Quit();
return 1;
}
bool running = true;
Uint64 last_time = SDL_GetTicks();
while (running)
{
// --- Delta time ---
Uint64 now = SDL_GetTicks();
float dt = (now - last_time) / 1000.0f;
last_time = now;
// --- Event handling ---
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_EVENT_QUIT)
running = false;
if (event.type == SDL_EVENT_KEY_DOWN
&& event.key.key == SDLK_ESCAPE)
running = false;
}
// --- Update ---
// TODO: Update game state using dt
// --- Render ---
SDL_SetRenderDrawColor(renderer, 30, 30, 60, 255);
SDL_RenderClear(renderer);
// TODO: Draw your game world here
// Example: draw a white rectangle
SDL_FRect rect = { 100.0f, 100.0f, 64.0f, 64.0f };
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderFillRect(renderer, &rect);
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}