111 lines
2.0 KiB
C++
111 lines
2.0 KiB
C++
#include "render/render.h"
|
|
#include "render/renderdevice.h"
|
|
#include "render/gl_shared.h"
|
|
#include "input/inputsystem.h"
|
|
#include "utils/logger.h"
|
|
|
|
#define RENDER_CLASS_NAME "RenderClassName"
|
|
#define RENDER_WINDOW_NAME "UNEASE Alpha"
|
|
|
|
HWND hWnd = NULL;
|
|
|
|
LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
|
|
WPARAM wParam, LPARAM lParam)
|
|
{
|
|
switch (message)
|
|
{
|
|
case WM_CREATE:
|
|
return 0;
|
|
case WM_DESTROY:
|
|
PostQuitMessage (0);
|
|
return 0;
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
switch (wParam)
|
|
{
|
|
case VK_ESCAPE:
|
|
PostQuitMessage(0);
|
|
return 0;
|
|
}
|
|
|
|
//input->OnKeyAction((int)wParam, true);
|
|
|
|
return 0;
|
|
|
|
case WM_KEYUP:
|
|
//input->OnKeyAction((int)wParam, false);
|
|
|
|
return 0;
|
|
|
|
default:
|
|
return DefWindowProc (hWnd, message, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
void R_CreateWindow(int width, int height)
|
|
{
|
|
static bool wndclassRegistered = false;
|
|
if (wndclassRegistered == false)
|
|
{
|
|
WNDCLASS wc;
|
|
/* register window class */
|
|
wc.style = CS_OWNDC;
|
|
wc.lpfnWndProc = WndProc;
|
|
wc.cbClsExtra = 0;
|
|
wc.cbWndExtra = 0;
|
|
wc.hInstance = GetModuleHandle(0);
|
|
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
|
|
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
|
|
wc.lpszMenuName = NULL;
|
|
wc.lpszClassName = RENDER_CLASS_NAME;
|
|
RegisterClass (&wc);
|
|
|
|
wndclassRegistered=true;
|
|
}
|
|
|
|
/* create main window */
|
|
hWnd = CreateWindow (
|
|
RENDER_CLASS_NAME, RENDER_WINDOW_NAME,
|
|
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
|
|
0, 0, width, height,
|
|
NULL, NULL, GetModuleHandle(0), NULL);
|
|
|
|
|
|
LogMsg("Created window %ix%i", width, height);
|
|
}
|
|
|
|
void R_Init()
|
|
{
|
|
LogMsg("--- R_Init ---");
|
|
|
|
// Create window
|
|
R_CreateWindow(1024, 768);
|
|
|
|
// Load OpenGL
|
|
GL_Load();
|
|
|
|
// Create render device
|
|
g_renderDevice = new RenderDevice();
|
|
}
|
|
|
|
void R_Shutdown()
|
|
{
|
|
if (g_renderDevice != NULL)
|
|
{
|
|
delete g_renderDevice;
|
|
g_renderDevice = NULL;
|
|
}
|
|
}
|
|
|
|
void R_Present()
|
|
{
|
|
GL_SwapBuffers(0);
|
|
}
|
|
|
|
void* R_GetWindow()
|
|
{
|
|
return hWnd;
|
|
}
|