00001 #ifndef __SDLCANVAS_H 00002 #define __SDLCANVAS_H 00003 00004 #ifdef WIN32 00005 #include <windows.h> 00006 #endif //WIN32 00007 #include <GL/gl.h> 00008 #include "RAS_ICanvas.h" 00009 00010 #include <SDL/SDL.h> 00011 00012 00013 class SDLCanvas : public RAS_ICanvas 00014 { 00015 private: 00016 int m_width; 00017 int m_height; 00018 00019 public: 00020 SDLCanvas() {} 00021 00022 virtual ~SDLCanvas() {} 00023 virtual void Init() {} 00024 virtual void SwapBuffers() 00025 { 00026 SDL_GL_SwapBuffers(); 00027 } 00028 virtual void Resize(int width,int height) 00029 { 00030 m_width = width; 00031 m_height = height; 00032 } 00033 virtual int GetWidth() 00034 { 00035 return m_width; 00036 } 00037 virtual int GetHeight() 00038 { 00039 return m_height; 00040 } 00041 virtual void BeginFrame() {} 00042 virtual void EndFrame() {} 00043 virtual void ClearColor(float r,float g,float b,float a) 00044 { 00045 glClearColor(r,g,b,a); 00046 } 00047 virtual void ClearBuffer(int type) 00048 { 00049 int ogltype = 0; 00050 if (type & RAS_ICanvas::COLOR_BUFFER ) 00051 ogltype |= GL_COLOR_BUFFER_BIT; 00052 if (type & RAS_ICanvas::DEPTH_BUFFER ) 00053 ogltype |= GL_DEPTH_BUFFER_BIT; 00054 glClear(ogltype); 00055 } 00056 }; 00057 00058 00059 #endif // __SDLCANVAS_H