From f7b3c364aeddf5fbcef045efa07871b36b21de6e Mon Sep 17 00:00:00 2001 From: Rejean Loyer Date: Mon, 8 Sep 2014 22:35:28 -0400 Subject: [PATCH] ecere: gfx/gui: add SDL 1.x support via new driver named SDL1. --- ecere/ecere.epj | 17 +- ecere/src/gfx/drivers/SDLDisplayDriver.ec | 556 ++++++++++++++++++++++++++++++ ecere/src/gui/drivers/SDLInterface.ec | 531 ++++++++++++++++++++++++++++ 3 files changed, 1102 insertions(+), 2 deletions(-) create mode 100644 ecere/src/gfx/drivers/SDLDisplayDriver.ec create mode 100644 ecere/src/gui/drivers/SDLInterface.ec diff --git a/ecere/ecere.epj b/ecere/ecere.epj index eb7276a..632b9da 100644 --- a/ecere/ecere.epj +++ b/ecere/ecere.epj @@ -85,7 +85,8 @@ from wherever you obtained them. "jpeg", "png", "z", - "freetype" + "freetype", + "SDL" ] }, "Platforms" : [ @@ -1581,7 +1582,13 @@ from wherever you obtained them. } ] }, - "TemplateDisplayDriver.ec" + "TemplateDisplayDriver.ec", + { + "FileName" : "SDLDisplayDriver.ec", + "Options" : { + "ExcludeFromBuild" : false + } + } ], "Options" : { "ExcludeFromBuild" : true @@ -1926,6 +1933,12 @@ from wherever you obtained them. } } ] + }, + { + "FileName" : "SDLInterface.ec", + "Options" : { + "ExcludeFromBuild" : false + } } ], "Options" : { diff --git a/ecere/src/gfx/drivers/SDLDisplayDriver.ec b/ecere/src/gfx/drivers/SDLDisplayDriver.ec new file mode 100644 index 0000000..de7bdf7 --- /dev/null +++ b/ecere/src/gfx/drivers/SDLDisplayDriver.ec @@ -0,0 +1,556 @@ +namespace gfx::drivers; + +#ifdef BUILDING_ECERE_COM +import "instance" +import "Display" +#else +#ifdef ECERE_STATIC +public import static "ecere" +#else +public import "ecere" +#endif +#endif + +import "SDLInterface" + +#if !defined(NO_SDL_DRIVERS) && !defined(NO_SDL1_DRIVER) + +#include + +// source file line number printf (sflnprintf) +#define sflnprintf(format,...) printf("%s:% 5d: " format, __FILE__, __LINE__, ##__VA_ARGS__) + +#define watch _watch +#include +#undef watch + +class SDLDisplay : LFBDisplay +{ +}; + +class SDLDisplayDriver : DisplayDriver +{ + class_property(name) = "SDL1"; + + + // Constructor / Destructor + + bool ::CreateDisplaySystem(DisplaySystem displaySystem) + { + bool result = false; + sflnprintf("class(SDLDisplayDriver) ::CreateDisplaySystem [WIP!]\n"); + displaySystem.flags.memBackBuffer = true; + result = true; + return result; + } + + void ::DestroyDisplaySystem(DisplaySystem displaySystem) + { + sflnprintf("class(SDLDisplayDriver) ::DestroyDisplaySystem [STUB!]\n"); + } + + bool ::CreateDisplay(Display display) + { + bool result = false; + SDLDisplay sdlDisplay = display.driverData = SDLDisplay { }; + sflnprintf("class(SDLDisplayDriver) ::CreateDisplay [WIP!]\n"); + if(sdlDisplay) + { + // To find out the format... + DisplaySize(display, 1, 1); + result = true; + } + return result; + } + + void ::DestroyDisplay(Display display) + { + SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::DestroyDisplay [STUB!]\n"); + + if(display) + ((subclass(DisplayDriver))class(LFBDisplayDriver)).DestroyDisplay(display); + + // TODO: Implementation + + delete sdlDisplay; + display.driverData = null; + } + + + // Display Position and Size + + bool ::DisplaySize(Display display, int width, int height) + { + SDLDisplay sdlDisplay = display.driverData; + bool result = false; + sflnprintf("class(SDLDisplayDriver) ::DisplaySize [WIP!]\n"); + + // TODO: Implementation + + /* + bool validFormat = true; + switch(backDesc.ddpfPixelFormat.dwRGBBitCount) + { + case 8: bitmap.pixelFormat = pixelFormat8; break; + case 15: bitmap.pixelFormat = pixelFormat555; break; + case 16: + if(backDesc.ddpfPixelFormat.dwGBitMask == 0x3E0) + bitmap.pixelFormat = pixelFormat555; + else + bitmap.pixelFormat = pixelFormat565; + break; + case 32: + bitmap.pixelFormat = pixelFormat888; break; + default: + validFormat = false; + break; + } + if(validFormat) + { + bitmap.picture = (byte *)backDesc.lpSurface; + bitmap.stride = backDesc.lPitch; + bitmap.stride >>= GetColorDepthShifts(bitmap.pixelFormat); + bitmap.size = bitmap.stride * bitmap.height; + } + */ + display.displaySystem.pixelFormat = sdlDisplay.bitmap.pixelFormat; + result = true; + + ((subclass(DisplayDriver))class(LFBDisplayDriver)).DisplaySize(display, width, height); + + display.width = width; + display.height = height; + + return result; + } + + void ::DisplayPosition(Display display, int x, int y) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).DisplayPosition(display, x, y); + } + + + // Palettes + + void ::SetPalette(Display display, ColorAlpha * palette, bool colorMatch) + { + SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::SetPalette [WIP!]\n"); + if(sdlDisplay.bitmap.pixelFormat == pixelFormat8) + { + // TODO: Implementation + } + else + ((subclass(DisplayDriver))class(LFBDisplayDriver)).SetPalette(display, palette, colorMatch); + } + + void ::RestorePalette(Display display) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::RestorePalette [STUB!]\n"); + } + + + // Display the back buffer content + + void ::StartUpdate(Display display) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::StartUpdate [STUB!]\n"); + } + + void ::EndUpdate(Display display) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDL2DisplayDriver) ::EndUpdate [STUB!]\n"); + //--//SDL_RenderPresent(); + } + + void ::Scroll(Display display, Box scroll, int x, int y, Extent dirty) + { + } + + void ::Update(Display display, Box updateBox) + { + //SDLDisplay sdlDisplay = display.driverData; + //--//Box * box = updateBox; + sflnprintf("class(SDLDisplayDriver) ::Update [STUB!]\n"); + // SDL_RenderPresent(); + } + + + // Allocate/free a bitmap + + bool ::AllocateBitmap(DisplaySystem displaySystem, Bitmap bitmap, int width, int height, int stride, PixelFormat format, bool allocatePalette) + { + return ((subclass(DisplayDriver))class(LFBDisplayDriver)).AllocateBitmap(displaySystem, bitmap, width, height, stride, format, allocatePalette); + } + + void ::FreeBitmap(DisplaySystem displaySystem, Bitmap bitmap) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).FreeBitmap(displaySystem, bitmap); + } + + + // Lock + + bool ::LockSystem(DisplaySystem displaySystem) + { + sflnprintf("class(SDLDisplayDriver) ::LockSystem [STUB!]\n"); + return false; + } + + void ::UnlockSystem(DisplaySystem displaySystem) + { + sflnprintf("class(SDLDisplayDriver) ::UnlockSystem [STUB!]\n"); + } + + bool ::Lock(Display display) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::Lock [STUB!]\n"); + return true; + } + + void ::Unlock(Display display) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDLDisplayDriver) ::Unlock [STUB!]\n"); + } + + + // Get/release a surface + + bool ::GetSurface(Display display, Surface surface, int x,int y, Box clip) + { + //SDLDisplay sdlDisplay = display.driverData; + LFBSurface lfbSurface; + bool result = false; + sflnprintf("class(SDLDisplayDriver) ::GetSurface [WIP!]\n"); + { + if((surface.driverData = lfbSurface = LFBSurface { })) + { + surface.offset.x = x; + surface.offset.y = y; + //surface.unclippedBox = surface.box = clip; + // TODO: Implementation + result = ((subclass(DisplayDriver))class(LFBDisplayDriver)).GetSurface(display, surface, x, y, clip); + } + } + return result; + } + + bool ::GetBitmapSurface(DisplaySystem displaySystem, Surface surface, Bitmap bitmap, int x, int y, Box clip) + { + return ((subclass(DisplayDriver))class(LFBDisplayDriver)).GetBitmapSurface(displaySystem, surface, bitmap, x, y, clip); + } + + void ::ReleaseSurface(Display display, Surface surface) + { + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDL2DisplayDriver) ::ReleaseSurface [WIP!]\n"); + ((subclass(DisplayDriver))class(LFBDisplayDriver)).ReleaseSurface(display, surface); + // TODO: Implementation + } + + + // Clip a surface + + void ::Clip(Display display, Surface surface, Box clip) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Clip(display, surface, clip); + } + + + // Grab from the screen + + bool ::GrabScreen(Display display, Bitmap bitmap, int x, int y, unsigned int w, unsigned int h) + { + bool result = false; + //SDLDisplay sdlDisplay = display.driverData; + sflnprintf("class(SDL2DisplayDriver) ::GrabScreen [WIP!]\n"); + // TODO: Implementation + result = ((subclass(DisplayDriver))class(LFBDisplayDriver)).GrabScreen(display, bitmap, x,y, w,h); + return result; + } + + + // Converts a bitmap format + + bool ::ConvertBitmap(DisplaySystem displaySystem, Bitmap src, PixelFormat format, ColorAlpha * palette) + { + return ((subclass(DisplayDriver))class(LFBDisplayDriver)).ConvertBitmap(displaySystem, src, format, palette); + } + + + // Converts an LFB bitmap into an offscreen bitmap for this device + + bool ::MakeDDBitmap(DisplaySystem displaySystem, Bitmap bitmap, bool mipMaps) + { + return ((subclass(DisplayDriver))class(LFBDisplayDriver)).MakeDDBitmap(displaySystem, bitmap, mipMaps); + } + + + // Font loading + + Font ::LoadFont(DisplaySystem displaySystem, const char * faceName, float size, FontFlags flags) + { + Font font = (Font)((subclass(DisplayDriver))class(LFBDisplayDriver)).LoadFont(displaySystem, faceName, size, flags); + return font; + } + + void ::UnloadFont(DisplaySystem displaySystem, Font font) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).UnloadFont(displaySystem, font); + } + + + // 2D Drawing + + void ::SetForeground(Display display, Surface surface, ColorAlpha color) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).SetForeground(display, surface, color); + } + + void ::SetBackground(Display display, Surface surface, ColorAlpha color) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).SetBackground(display, surface, color); + } + + void ::SetBlitTint(Display display, Surface surface, ColorAlpha tint) + { + sflnprintf("class(SDLDisplayDriver) ::SetBlitTint [STUB!]\n"); + } + + void ::LineStipple(Display display, Surface surface, uint stipple) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).LineStipple(display, surface, stipple); + } + + ColorAlpha ::GetPixel(Display display, Surface surface, int x, int y) + { + sflnprintf("class(SDLDisplayDriver) ::GetPixel [STUB!]\n"); + return 0; + } + + void ::PutPixel(Display display, Surface surface, int x, int y) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).PutPixel(display, surface, x,y); + } + + void ::DrawLine(Display display, Surface surface, int x1, int y1, int x2, int y2) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).DrawLine(display, surface, x1,y1,x2,y2); + } + + void ::Rectangle(Display display, Surface surface, int x1, int y1, int x2, int y2) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Rectangle(display, surface, x1,y1,x2,y2); + } + + void ::Area(Display display, Surface surface,int x1, int y1, int x2, int y2) + { + /* if(x1>x2) { int tmp = x2; x2 = x1; x1 = tmp; } + + if(x1surface.box.right) x2=surface.box.right; + if(y1surface.box.bottom) y2=surface.box.bottom; +*/ + x1 += surface.offset.x; + x2 += surface.offset.x; + y1 += surface.offset.y; + y2 += surface.offset.y; + + { + //--//SDL_Rect rect = { (short)x1, (short)y1, (short)(x2-x1+1), (short)(y2-y1+1) }; + //--//SDL_SetRenderDrawColor(surface.background.color.r, surface.background.color.g, surface.background.color.b, surface.background.a); + //--//SDL_RenderFill(&rect); + //SDL_FillRect() + // ((subclass(DisplayDriver))class(LFBDisplayDriver)).Area(display, surface, x1,y1,x2,y2); + } + } + + void ::Clear(Display display, Surface surface, ClearType type) + { + sflnprintf("class(SDL2DisplayDriver) ::Clear [WIP!]\n"); + //--//SDL_Rect rect = { (short)surface.box.left, (short)surface.box.top, (short)(surface.box.right-surface.box.left+1), (short)(surface.box.bottom-surface.box.top+1) }; + //--//SDL_SetRenderDrawColor(surface.background.color.r, surface.background.color.g, surface.background.color.b, surface.background.a); + //--//SDL_RenderFill(&rect); + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Clear(display, surface, type); + } + + void ::Blit(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Blit(display, surface, src, dx, dy, sx, sy, w, h); + } + + void ::Stretch(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Stretch(display, surface, src, dx, dy, sx, sy, w, h, sw, sh); + } + + void ::Filter(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Filter(display, surface, src, dx, dy, sx, sy, w, h, sw, sh); + } + + void ::BlitDI(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h) + { + // Using Blit() + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Blit(display, surface, src, dx, dy, sx, sy, w, h); + } + + void ::StretchDI(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh) + { + // Using Stretch() + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Stretch(display, surface, src, dx, dy, sx, sy, w, h, sw, sh); + } + + void ::FilterDI(Display display, Surface surface, Bitmap src, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh) + { + // Using Filter() + //Filter(display, surface, src, dx, dy, sx, sy, w, h, sw, sh); + ((subclass(DisplayDriver))class(LFBDisplayDriver)).Filter(display, surface, src, dx, dy, sx, sy, w, h, sw, sh); + } + + void ::TextFont(Display display, Surface surface, Font font) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).TextFont(display, surface, font); + // why this? + SetForeground(display, surface, surface.foreground); + } + + void ::TextOpacity(Display display, Surface surface, bool opaque) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).TextOpacity(display, surface, opaque); + } + + void ::WriteText(Display display, Surface surface, int x, int y, const char * text, int len) + { + if(surface.textOpacity) + { + int w, h; + ((subclass(DisplayDriver))class(LFBDisplayDriver)).FontExtent(display.displaySystem, surface.font, text, len, &w, &h); + Area(display, surface, x, y, x+w-1, y+h-1); + } + ((subclass(DisplayDriver))class(LFBDisplayDriver)).WriteText(display, surface, x,y, text, len); + } + + void ::TextExtent(Display display, Surface surface, const char * text, int len, int * width, int * height) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).TextExtent(display, surface, text, len, width, height); + } + + void ::FontExtent(DisplaySystem displaySystem, Font font, const char * text, int len, int * width, int * height) + { + ((subclass(DisplayDriver))class(LFBDisplayDriver)).FontExtent(displaySystem, font, text, len, width, height); + } + + void ::DrawingChar(Display display, Surface surface, char character) + { + sflnprintf("class(SDLDisplayDriver) ::DrawingChar [STUB!]\n"); + } + + void ::NextPage(Display display) + { + sflnprintf("class(SDLDisplayDriver) ::NextPage [STUB!]\n"); + } + + // 3D Graphics + +#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D) + void ::SetRenderState(Display display, RenderState state, uint value) + { + sflnprintf("class(SDLDisplayDriver) ::SetRenderState [STUB!]\n"); + } + + void ::SetLight(Display display, int id, Light light) + { + sflnprintf("class(SDLDisplayDriver) ::SetLight [STUB!]\n"); + } + + void ::SetCamera(Display display, Surface surface, Camera camera) + { + sflnprintf("class(SDLDisplayDriver) ::SetCamera [STUB!]\n"); + } + + bool ::AllocateMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags, int nVertices) + { + sflnprintf("class(SDLDisplayDriver) ::AllocateMesh [STUB!]\n"); + return false; + } + + void ::FreeMesh(DisplaySystem displaySystem, Mesh mesh) + { + sflnprintf("class(SDLDisplayDriver) ::FreeMesh [STUB!]\n"); + } + + bool ::LockMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags) + { + sflnprintf("class(SDLDisplayDriver) ::LockMesh [STUB!]\n"); + return false; + } + + void ::UnlockMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags) + { + sflnprintf("class(SDLDisplayDriver) ::UnlockMesh [STUB!]\n"); + } + + void * ::AllocateIndices(DisplaySystem displaySystem, int nIndices, bool indices32bit) + { + sflnprintf("class(SDLDisplayDriver) ::AllocateIndices [STUB!]\n"); + return null; + } + + void ::FreeIndices(DisplaySystem displaySystem, void * indices) + { + sflnprintf("class(SDLDisplayDriver) ::FreeIndices [STUB!]\n"); + } + + uint16 * ::LockIndices(DisplaySystem displaySystem, void * indices) + { + sflnprintf("class(SDLDisplayDriver) ::LockIndices [STUB!]\n"); + return null; + } + + void ::UnlockIndices(DisplaySystem displaySystem, void * indices, bool indices32bit, int nIndices) + { + sflnprintf("class(SDLDisplayDriver) ::UnlockIndices [STUB!]\n"); + } + + void ::SelectMesh(Display display, Mesh mesh) + { + sflnprintf("class(SDLDisplayDriver) ::SelectMesh [STUB!]\n"); + } + + void ::ApplyMaterial(Display display, Material material, Mesh mesh) + { + sflnprintf("class(SDLDisplayDriver) ::ApplyMaterial [STUB!]\n"); + } + + void ::DrawPrimitives(Display display, PrimitiveSingle * primitive, Mesh mesh) + { + sflnprintf("class(SDLDisplayDriver) ::DrawPrimitives [STUB!]\n"); + } + + void ::PushMatrix(Display display) + { + sflnprintf("class(SDLDisplayDriver) ::PushMatrix [STUB!]\n"); + } + + void ::PopMatrix(Display display, bool setMatrix) + { + sflnprintf("class(SDLDisplayDriver) ::PopMatrix [STUB!]\n"); + } + + void ::SetTransform(Display display, Matrix transMatrix, bool viewSpace, bool useCamera) + { + sflnprintf("class(SDLDisplayDriver) ::SetTransform [STUB!]\n"); + } +#endif + +} + +#endif // !defined(NO_SDL_DRIVERS) && !defined(NO_SDL1_DRIVER) diff --git a/ecere/src/gui/drivers/SDLInterface.ec b/ecere/src/gui/drivers/SDLInterface.ec new file mode 100644 index 0000000..172fff3 --- /dev/null +++ b/ecere/src/gui/drivers/SDLInterface.ec @@ -0,0 +1,531 @@ +namespace gui::drivers; + +#ifdef BUILDING_ECERE_COM +import "Window" +import "Interface" +#else +#ifdef ECERE_STATIC +public import static "ecere" +#else +public import "ecere" +#endif +#endif + +import "SDLDisplayDriver" + +#if !defined(NO_SDL_DRIVERS) && !defined(NO_SDL1_DRIVER) + +#include + +// source file line number printf (sflnprintf) +#define sflnprintf(format,...) printf("%s:% 5d: " format, __FILE__, __LINE__, ##__VA_ARGS__) + +#define watch _watch +#include +#undef watch + +static bool fullScreenMode; + +static define guiApp = (GuiApplication)__thisModule.application; + +class SDLInterface : Interface +{ + class_property(name) = "SDL1"; + + /**************************************************************************** + /// PRIVATE UTILITY FUNCTIONS ///////////// + ****************************************************************************/ + void ::RepositionDesktop(bool updateChildren) + { + // TODO: Implement this + int x = 0, y = 0, w = 0, h = 0; + guiApp.SetDesktopPosition(x, y, w, h, updateChildren); + } + + bool ::ProcessKeyMessage(Key key, unichar ch) + { + bool result = true; + //Key code = key; + + // TODO: Implement this + + // MouseWheel + // result = window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit, code, 0); + + // KeyUp + // result = window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, code, ch); + + // KeyDown + // result = window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, code, ch); + + // KeyHit + // result = window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit, code,ch); + return result; + } + + + // TODO: Implement these + + // Activated (Special code to write to handle modal windows...) + // window.ExternalActivate(true, true, window, null); + + // Application Activated + // guiApp.SetAppFocus + + + // Window Redraw + // window.UpdateDirty(box); + + + // Resolution changed + // guiApp.desktop.DisplayModeChanged() + + // IME Code + + // Keyboard and Mouse Messages + + + // Timer 18.2 times per second: Call guiApp.SignalEvent(); + + // Mouse Cursors + + /**************************************************************************** + /// DRIVER IMPLEMENTATION ///////////// + ****************************************************************************/ + + + // --- User Interface System --- + + bool ::Initialize() + { + SDL_Init(SDL_INIT_EVENTTHREAD); + SDL_VideoInit(null, 0); + return true; + } + + void ::Terminate() + { + SDL_Quit(); + } + + bool ::ProcessInput(bool processAll) + { + // TODO: Implement this + SDL_Event event; + while(SDL_PollEvent(&event)) + { + //--//Window window = SDL_GetWindowData(event.window.windowID); + switch (event.type) + { + case SDL_KEYUP: + // event.key.keysym.sym + // SDLK_ESCAPE: + break; +//--// +/* + case SDL_WINDOWEVENT: + { + switch(event.window.event) + { + case SDL_WINDOWEVENT_SHOWN: + break; + case SDL_WINDOWEVENT_HIDDEN: + break; + case SDL_WINDOWEVENT_MOVED: + { + int x,y,w,h; + //--//SDL_GetWindowSize((SDL_WindowID)window.systemHandle, &w, &h); + //--//SDL_GetWindowPosition((SDL_WindowID)window.systemHandle, &x, &y); + window.ExternalPosition(x, y, w, h); + break; + } + case SDL_WINDOWEVENT_RESIZED: + { + int x,y,w,h; + //--//SDL_GetWindowSize((SDL_WindowID)window.systemHandle, &w, &h); + //--//SDL_GetWindowPosition((SDL_WindowID)window.systemHandle, &x, &y); + window.ExternalPosition(x, y, w, h); + break; + } + case SDL_WINDOWEVENT_MINIMIZED: + break; + case SDL_WINDOWEVENT_MAXIMIZED: + break; + case SDL_WINDOWEVENT_RESTORED: + break; + case SDL_WINDOWEVENT_ENTER: + break; + case SDL_WINDOWEVENT_LEAVE: + break; + case SDL_WINDOWEVENT_CLOSE: + { + window.Destroy(0); + break; + } + case SDL_WINDOWEVENT_EXPOSED: + { + /-*SDL_Rect rect = { 0,0,800,600}; + SDL_SetRenderDrawColor(0,120,200,255); + SDL_RenderFill(&rect); + SDL_RenderPresent(); *-/ + window.Update(null); + break; + } + } + break; + } +*/ //--// + } + } + return false; + } + + void ::Wait() + { + sflnprintf("class(SDLInterface) ::Wait [WIP!]\n"); + // TODO: Implement this, wait on a message as well as guiApp.semaphore + SDL_WaitEvent(null); + guiApp.WaitEvent(); + //SDL_WaitEventTimeout(null, (int)(1000 / 18.2)); + //SDL_WaitEventTimeout + } + + void ::Lock(Window window) + { + sflnprintf("class(SDLInterface) ::Lock [STUB!]\n"); + } + + void ::Unlock(Window window) + { + sflnprintf("class(SDLInterface) ::Unlock [STUB!]\n"); + } + + void ::SetTimerResolution(uint hertz) + { + sflnprintf("class(SDLInterface) ::SetTimerResolution [STUB!] Implement high resolution timer here\n"); + } + + const char ** ::GraphicsDrivers(int * numDrivers) + { + static const char *graphicsDrivers[] = { "SDL1" }; + *numDrivers = sizeof(graphicsDrivers) / sizeof(char *); + return (const char **)graphicsDrivers; + } + + void ::EnsureFullScreen(bool * fullScreen) + { + sflnprintf("class(SDLInterface) ::EnsureFullScreen [STUB!]\n"); + } + + void ::GetCurrentMode(bool * fullScreen, Resolution * resolution, PixelFormat * colorDepth, int * refreshRate) + { + int width = 0, height = 0, bpp = 0, freq = 0; + sflnprintf("class(SDLInterface) ::GetCurrentMode [WIP!]\n"); + *fullScreen = fullScreenMode; + if(fullScreenMode) + { + Resolution c; + for(c = 0; c