Add SDL to power software backend
This commit is contained in:
parent
79c3ad74e7
commit
cd4a7e0cf0
|
@ -30,6 +30,9 @@ set(
|
||||||
if(PLATFORM_DREAMCAST)
|
if(PLATFORM_DREAMCAST)
|
||||||
set(SOURCES ${SOURCES} GL/platforms/sh4.c)
|
set(SOURCES ${SOURCES} GL/platforms/sh4.c)
|
||||||
else()
|
else()
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
link_libraries(${SDL2_LIBRARIES})
|
||||||
set(SOURCES ${SOURCES} GL/platforms/x86.c)
|
set(SOURCES ${SOURCES} GL/platforms/x86.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -7,8 +9,25 @@
|
||||||
static size_t AVAILABLE_VRAM = 16 * 1024 * 1024;
|
static size_t AVAILABLE_VRAM = 16 * 1024 * 1024;
|
||||||
static Matrix4x4 MATRIX;
|
static Matrix4x4 MATRIX;
|
||||||
|
|
||||||
void InitGPU(_Bool autosort, _Bool fsaa) {
|
static VideoMode vid_mode = {
|
||||||
|
640, 480
|
||||||
|
};
|
||||||
|
|
||||||
|
void InitGPU(_Bool autosort, _Bool fsaa) {
|
||||||
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
||||||
|
|
||||||
|
SDL_Window *window = SDL_CreateWindow(
|
||||||
|
"GLdc",
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
vid_mode.width, vid_mode.height,
|
||||||
|
SDL_WINDOW_SHOWN
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
SDL_Renderer *renderer = SDL_CreateRenderer(
|
||||||
|
window, -1, SDL_RENDERER_ACCELERATED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneBegin() {
|
void SceneBegin() {
|
||||||
|
@ -29,6 +48,18 @@ void SceneListFinish() {
|
||||||
|
|
||||||
void SceneFinish() {
|
void SceneFinish() {
|
||||||
|
|
||||||
|
/* Only sensible place to hook the quit signal */
|
||||||
|
|
||||||
|
SDL_Event e = {0};
|
||||||
|
|
||||||
|
while (SDL_PollEvent(&e))
|
||||||
|
switch (e.type) {
|
||||||
|
case SDL_QUIT:
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadMatrix4x4(const Matrix4x4* mat) {
|
void UploadMatrix4x4(const Matrix4x4* mat) {
|
||||||
|
@ -43,10 +74,6 @@ void DownloadMatrix4x4(Matrix4x4* mat) {
|
||||||
memcpy(mat, &MATRIX, sizeof(Matrix4x4));
|
memcpy(mat, &MATRIX, sizeof(Matrix4x4));
|
||||||
}
|
}
|
||||||
|
|
||||||
static VideoMode vid_mode = {
|
|
||||||
640, 480
|
|
||||||
};
|
|
||||||
|
|
||||||
const VideoMode* GetVideoMode() {
|
const VideoMode* GetVideoMode() {
|
||||||
return &vid_mode;
|
return &vid_mode;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +86,7 @@ void* GPUMemoryAlloc(size_t size) {
|
||||||
if(size > AVAILABLE_VRAM) {
|
if(size > AVAILABLE_VRAM) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
AVAILABLE_VRAM -= size;
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user