glwindow.monkey2 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Namespace mojo.app
  2. Class GLWindow Extends Window
  3. Method New()
  4. Init()
  5. End
  6. Method New( title:String="Window",width:Int=640,height:Int=480,flags:WindowFlags=Null )
  7. Super.New( title,width,height,flags )
  8. Init()
  9. End
  10. Method New( title:String,rect:Recti,flags:WindowFlags=Null )
  11. Super.New( title,rect,flags )
  12. Init()
  13. End
  14. Method BeginGL()
  15. #If __HOSTOS__="macos"
  16. glFlush()
  17. #Endif
  18. SDL_GL_MakeCurrent( SDLWindow,_sdlGLContext )
  19. End
  20. Method EndGL()
  21. #If __HOSTOS__="macos"
  22. glFlush()
  23. #Endif
  24. SDL_GL_MakeCurrent( Super.SDLWindow,Super.SDLGLContext )
  25. End
  26. Protected
  27. Method OnRender( canvas:Canvas ) Override
  28. BeginGL()
  29. OnRenderGL()
  30. EndGL()
  31. End
  32. Method OnRenderGL() Virtual
  33. End
  34. Private
  35. Field _sdlGLContext:SDL_GLContext
  36. Method Init()
  37. _sdlGLContext=SDL_GL_CreateContext( SDLWindow )
  38. Assert( _sdlGLContext,"FATAL ERROR: SDL_GL_CreateContext failed" )
  39. End
  40. End