it works!! mostly
This commit is contained in:
@@ -7,60 +7,63 @@
|
||||
|
||||
namespace Game
|
||||
{
|
||||
class GameSetup
|
||||
{
|
||||
public:
|
||||
GameRendering Rendering;
|
||||
int32_t FrameCounter = 0;
|
||||
};
|
||||
class GameSetup
|
||||
{
|
||||
public:
|
||||
GameRendering Rendering;
|
||||
int32_t FrameCounter = 0;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
GameSetup Instance;
|
||||
}
|
||||
|
||||
void Setup(void* window)
|
||||
{
|
||||
Log("Game Setup Start!");
|
||||
if (!SDL_Init(SDL_INIT_VIDEO))
|
||||
{
|
||||
Log("Failed to init SDL!");
|
||||
return;
|
||||
}
|
||||
SDL_Window* sdlWindow = SDL_CreateWindow("SDL", 1920, 1080, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
|
||||
if (sdlWindow == nullptr)
|
||||
{
|
||||
Log("Failed to init SDL Window!");
|
||||
return;
|
||||
}
|
||||
auto props = SDL_GetWindowProperties(sdlWindow);
|
||||
SDL_EnumerateProperties(props, [](void*, SDL_PropertiesID id, const char* name)
|
||||
{
|
||||
Log("Prop: %s", name);
|
||||
}, nullptr);
|
||||
void* hwnd = SDL_GetPointerProperty(props, "SDL.window.win32.hwnd", nullptr);
|
||||
if (hwnd == nullptr)
|
||||
{
|
||||
Log("Failed to get window pointer!");
|
||||
return;
|
||||
}
|
||||
Instance.Rendering.Setup(hwnd);
|
||||
}
|
||||
namespace
|
||||
{
|
||||
GameSetup Instance;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
++Instance.FrameCounter;
|
||||
if (Instance.FrameCounter % 100 == 0)
|
||||
{
|
||||
Log("Frame!");
|
||||
}
|
||||
void Setup(void* window)
|
||||
{
|
||||
Log("Game Setup Start!");
|
||||
if (!SDL_Init(SDL_INIT_VIDEO))
|
||||
{
|
||||
Log("Failed to init SDL!");
|
||||
return;
|
||||
}
|
||||
SDL_Window* sdlWindow = SDL_CreateWindow("SDL", 1920, 1080, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
|
||||
if (sdlWindow == nullptr)
|
||||
{
|
||||
Log("Failed to init SDL Window!");
|
||||
return;
|
||||
}
|
||||
auto props = SDL_GetWindowProperties(sdlWindow);
|
||||
SDL_EnumerateProperties(props, [](void*, SDL_PropertiesID id, const char* name)
|
||||
{
|
||||
Log("Prop: %s", name);
|
||||
}, nullptr);
|
||||
void* hwnd = SDL_GetPointerProperty(props, "SDL.window.win32.hwnd", nullptr);
|
||||
if (hwnd == nullptr)
|
||||
{
|
||||
Log("Failed to get window pointer!");
|
||||
return;
|
||||
}
|
||||
Instance.Rendering.Setup(hwnd);
|
||||
}
|
||||
|
||||
Instance.Rendering.Update();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
SDL_Event evt;
|
||||
while (SDL_PollEvent(&evt)) {}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
Log("Shutdown");
|
||||
Instance.Rendering.Shutdown();
|
||||
}
|
||||
++Instance.FrameCounter;
|
||||
if (Instance.FrameCounter % 100 == 0)
|
||||
{
|
||||
Log("Frame!");
|
||||
}
|
||||
|
||||
Instance.Rendering.Update();
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
Log("Shutdown");
|
||||
Instance.Rendering.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user