no engine anymore
This commit is contained in:
60
engine/gamewindow_sdl.cpp
Normal file
60
engine/gamewindow_sdl.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "SDL3/SDL_error.h"
|
||||
#include "igamewindow.h"
|
||||
#include "tier1/interface.h"
|
||||
#include "tier0/lib.h"
|
||||
#include "tier0/platform.h"
|
||||
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include "SDL3/SDL.h"
|
||||
#include "SDL3/SDL_init.h"
|
||||
#include "SDL3/SDL_video.h"
|
||||
#include "SDL3/SDL_vulkan.h"
|
||||
#include "SDL3/SDL_events.h"
|
||||
|
||||
SDL_Window *g_pWindow;
|
||||
IGameWindow *gamewindow;
|
||||
|
||||
class CSDLGameWindow: public IGameWindow
|
||||
{
|
||||
public:
|
||||
virtual void Init() override;
|
||||
virtual void Shutdown() override;
|
||||
virtual void UpdateWindow() override;
|
||||
};
|
||||
|
||||
|
||||
void CSDLGameWindow::Init()
|
||||
{
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD))
|
||||
Plat_FatalErrorFunc("SDL_Init: %s\n", SDL_GetError());
|
||||
|
||||
g_pWindow = SDL_CreateWindow("funnygame", 1280, 720, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||
if (!g_pWindow)
|
||||
Plat_FatalErrorFunc("SDL_Init: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
void CSDLGameWindow::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindow::UpdateWindow()
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_QUIT:
|
||||
SDL_Quit();
|
||||
Plat_Exit(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
EXPOSE_INTERFACE(CSDLGameWindow, IGameWindow, GAME_WINDOW_INTERFACE_NAME);
|
||||
Reference in New Issue
Block a user