Explorar o código

Added support for system Wait().
Shutdown context on exit.

woollybah %!s(int64=11) %!d(string=hai) anos
pai
achega
7139cdde58
Modificáronse 3 ficheiros con 21 adicións e 2 borrados
  1. 2 0
      sdlgraphics.mod/common.bmx
  2. 16 0
      sdlgraphics.mod/glue.c
  3. 3 2
      sdlgraphics.mod/sdlgraphics.bmx

+ 2 - 0
sdlgraphics.mod/common.bmx

@@ -56,6 +56,7 @@ Extern
 	Function bbSDLGraphicsClose( context:Byte Ptr )	
 	Function bbSDLGraphicsSetGraphics( context:Byte Ptr )
 	Function bbSDLGraphicsFlip( sync:Int )
+	Function bbSDLExit()
 	
 	Function SDL_GetNumVideoDisplays:Int()
 	
@@ -70,6 +71,7 @@ Extern
 	Function bmx_SDL_GetDisplayhertz:Int(display:Int)
 
 	Function bmx_SDL_Poll()
+	Function bmx_SDL_WaitEvent()
 	
 End Extern
 

+ 16 - 0
sdlgraphics.mod/glue.c

@@ -59,7 +59,9 @@ int bbSDLGraphicsGraphicsModes( int display, int *imodes,int maxcount );
 void bbSDLGraphicsFlip( int sync );
 void bbSDLGraphicsSetGraphics( BBSDLContext *context );
 void bbSDLGraphicsGetSettings( BBSDLContext *context, int * width,int * height,int * depth,int * hertz,int * flags);
+void bbSDLGraphicsClose( BBSDLContext *context );
 void bmx_SDL_Poll();
+void bmx_SDL_WaitEvent();
 
 static BBSDLContext *_currentContext;
 
@@ -182,6 +184,12 @@ void bbSDLGraphicsGetSettings( BBSDLContext *context, int * width,int * height,i
 	}
 }
 
+void bbSDLExit(){
+	bbSDLGraphicsClose( _currentContext );
+	_currentContext=0;
+}
+
+
 
 /* System stuff */
 
@@ -259,6 +267,14 @@ void bmx_SDL_Poll() {
 	}
 }
 
+void bmx_SDL_WaitEvent() {
+	SDL_Event event;
+	if (SDL_WaitEvent(&event)) {
+		bmx_SDL_EmitSDLEvent(&event, &bbNullObject);
+	}
+}
+
+
 int mapkey(SDL_Scancode scancode) {
 	switch(scancode) {
 		case SDL_SCANCODE_BACKSPACE:

+ 3 - 2
sdlgraphics.mod/sdlgraphics.bmx

@@ -49,7 +49,7 @@ Type TSDLGraphics Extends TGraphics
 	
 	Method Close()
 		If Not _context Return
-		'bbSDLGraphicsClose( _context )
+		bbSDLGraphicsClose( _context )
 		_context=0
 	End Method
 	
@@ -132,6 +132,7 @@ Type TSDLSystemDriver Extends TSystemDriver
 
 	Method New()
 		SDL_Init(SDL_INIT_VIDEO)
+		OnEnd(bbSDLExit)
 	End Method
 
 	Method Poll()
@@ -139,7 +140,7 @@ Type TSDLSystemDriver Extends TSystemDriver
 	End Method
 	
 	Method Wait()
-		' TODO
+		bmx_SDL_WaitEvent()
 	End Method
 
 	Method Emit( osevent:Byte Ptr,source:Object )