00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(SJGLUTWINDOW_H_INCLUDED)
00012 #define SJGLUTWINDOW_H_INCLUDED
00013
00014
00015 #pragma warning(disable:4786)
00016 #include <string>
00017
00018 #include "wnd.h"
00019
00020
00021
00022 #ifdef SJGUI_USE_WIN32_API
00023 #include <windows.h>
00024 #include <GL\gl.h>
00025 #include <GL\glu.h>
00026
00027 #undef min
00028 #undef max
00029
00030 using sjgui::min;
00031 using sjgui::max;
00032
00033 #else // SJGUI_USE_WIN32_API
00034 #include <GL/glut.h>
00035
00036 #ifndef SJGUI_USE_GLUT
00037 #define SJGUI_USE_GLUT
00038 #endif
00039 #endif // SJGUI_USE_WIN32_API
00040
00046 #define SET_GL_FOR_GUI_DRAW_WITH_SIZE(x,y,width,height) \
00047 glMatrixMode(GL_PROJECTION); \
00048 glLoadIdentity(); \
00049 glViewport(x,y,width,height); \
00050 gluOrtho2D(x,width, height,y); \
00051 glMatrixMode(GL_MODELVIEW); \
00052 glLoadIdentity(); \
00053 glDisable(GL_DEPTH_TEST); \
00054 glDisable(GL_TEXTURE_2D); \
00055 glDisable(GL_BLEND);
00056
00061 #define SET_GL_FOR_GUI_DRAW \
00062 SET_GL_FOR_GUI_DRAW_WITH_SIZE(0,0,CWnd::GetScreenWidth(),CWnd::GetScreenHeight())
00063
00068 #define SET_GL_FOR_PROSPECTIVE(angle,near_cut_off,far_cut_off) \
00069 glEnable(GL_DEPTH_TEST); \
00070 glDepthFunc(GL_LEQUAL); \
00071 glMatrixMode(GL_PROJECTION); \
00072 glLoadIdentity(); \
00073 glViewport(GetAbsPos().GetX(),GetAbsPos().GetY(),GetAbsPos().GetWidth(),GetAbsPos().GetHeight()); \
00074 gluPerspective(angle,(GLfloat)GetWidth()/(GLfloat)GetHeight(),near_cut_off,far_cut_off); \
00075 glMatrixMode(GL_MODELVIEW); \
00076 glLoadIdentity();
00077
00078
00079
00084 #define SET_GL_SIMPLE_PROSPECTIVE SET_GL_FOR_PROSPECTIVE(45.0f,1.0f,1000.0f);
00085
00086 namespace sjgui{
00087
00097 int Create(const char* pcCaption,CWnd* pWnd,int iBits=16,bool yFullScreen=false);
00103 void SetMode(unsigned int uiMode);
00107 void SetPos(int iX,int iY);
00112 void SetScreenSize(int iW,int iH);
00113
00118 void GlobalMainLoop();
00124 void IgnoreRepeates(bool b=true);
00125
00130 void SwitchFullScreen(int iW,int iH,int iBits);
00132 bool IsFullScreen();
00134 void SetClearColor(GLfloat* fC);
00135
00143
00144
00157 void OnResizeEvent(CWnd* pWnd, int iWidth, int iHeight);
00162 int OnInitEvent(CWnd* pWnd);
00166 void OnKeyDownEvent(CWnd* pWnd,int iKey);
00170 void OnKeyUpEvent(CWnd* pWnd,int iKey);
00174 void OnMouseMoveEvent(CWnd* pWnd,int iX, int iY);
00176 }
00177
00178 #endif // !defined(SJGLUTWINDOW_H_INCLUDED)