Move char\* cast to RSDL this function

This commit is contained in:
Tulpen 2023-05-21 18:21:16 +01:00
parent cbe861693e
commit ccd3364d0c
2 changed files with 7 additions and 5 deletions

View file

@ -6,16 +6,19 @@ import gameengine.math.types;
import std.exception; import std.exception;
import std.format; import std.format;
import std.string : toStringz;
class RSDL : Renderer { class RSDL : Renderer {
this(char* title, IntVec2 size) { this(string title, IntVec2 size) {
const SDLSupport ret = loadSDL(); const SDLSupport ret = loadSDL();
if(ret != sdlSupport) { if(ret != sdlSupport) {
throw new Exception("Couldn't load SDL"); throw new Exception("Couldn't load SDL library!");
} }
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, size.x, size.y, SDL_WINDOW_RESIZABLE); window = SDL_CreateWindow(cast(char*)toStringz(title), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
size.x, size.y, SDL_WINDOW_RESIZABLE);
if (window is null) { if (window is null) {
string error = format("Couldn't create window! what: %d", SDL_GetError()); string error = format("Couldn't create window! what: %d", SDL_GetError());

View file

@ -6,10 +6,9 @@ import gameengine.renderer.renderer;
import gameengine_rsdl; import gameengine_rsdl;
import core.thread; import core.thread;
import std.string : toStringz;
void main() { void main() {
Renderer renderer = new RSDL(cast(char*)toStringz("test".dup), IntVec2(800, 600)); Renderer renderer = new RSDL("test", IntVec2(800, 600));
Engine engine = new Engine(renderer); Engine engine = new Engine(renderer);
while (true) { while (true) {