From 484123add56ac236a9bfb361ab475bf8f3bead6f Mon Sep 17 00:00:00 2001 From: Dennis Peeten Date: Tue, 20 May 2008 12:16:54 +0000 Subject: nog een keer!!! --- matchblox/common/bitmap.c | 12 +- matchblox/common/font.c | 2 +- matchblox/engine/C_3DObject.cpp | 11 +- matchblox/engine/C_3DObject.h | 1 + matchblox/engine/C_Box.cpp | 2 +- matchblox/engine/C_MatchBloxEngine.cpp | 191 +++++++-- matchblox/engine/C_MatchBloxEngine.h | 108 ++++- matchblox/engine/MessageQueue.h | 26 -- matchblox/engine/typedefs.h | 98 +++-- matchblox/include/GL/glut.h | 721 +++++++++++++++++++++++++++++++++ matchblox/main.cpp | 4 +- matchblox/matchblox.sln | 20 + matchblox/matchblox.vcproj | 85 ++-- matchblox/menu/button.c | 2 +- 14 files changed, 1152 insertions(+), 131 deletions(-) delete mode 100644 matchblox/engine/MessageQueue.h create mode 100644 matchblox/include/GL/glut.h create mode 100644 matchblox/matchblox.sln diff --git a/matchblox/common/bitmap.c b/matchblox/common/bitmap.c index 2d69bc9..3a6171a 100644 --- a/matchblox/common/bitmap.c +++ b/matchblox/common/bitmap.c @@ -6,11 +6,21 @@ #define GL_CLAMP_TO_EDGE 0x812F #endif -#include +#include #include #include #include +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif +#ifndef GL_BGR +#define GL_BGR 0x80E0 +#endif +#ifndef GL_BGRA +#define GL_BGRA 0x80E1 +#endif + #include "bitmap.h" #define BITMAP_FILESIZE 0x02 diff --git a/matchblox/common/font.c b/matchblox/common/font.c index 0332174..2f39d7f 100644 --- a/matchblox/common/font.c +++ b/matchblox/common/font.c @@ -6,7 +6,7 @@ #define TRUE !FALSE #endif -#include +#include #include #include "font.h" diff --git a/matchblox/engine/C_3DObject.cpp b/matchblox/engine/C_3DObject.cpp index 3cb00b1..75e7ead 100644 --- a/matchblox/engine/C_3DObject.cpp +++ b/matchblox/engine/C_3DObject.cpp @@ -6,8 +6,7 @@ #include "typedefs.h" #include "C_3DObject.h" - -#include "bitmap.h" +#include "bitmap.h" C_3DObject::C_3DObject() : m_Pos(0.0, 0.0, 0.0), m_Rot(0.0, 0.0, 0.0), @@ -148,9 +147,9 @@ bool C_3DObject::CreateObject(const char *f_pFilePath) << "\nNormals: " << l_Geom.m_norms.size()-1 << "\nTexCrds: " << l_Geom.m_texs.size()-1 << "\nTriangles: " << l_Geom.m_triangles.size() - << "\nBoundBox: x(" << m_BBox.m_dLeft << "," << m_BBox.m_dRight << ")" - << "\n y(" << m_BBox.m_dBottom << "," << m_BBox.m_dTop << ")" - << "\n z(" << m_BBox.m_dFront << "," << m_BBox.m_dBack << ")" + << "\nBoundBox: x(" << m_BBox.m_Min.x << "," << m_BBox.m_Max.x << ")" + << "\n y(" << m_BBox.m_Min.y << "," << m_BBox.m_Max.y << ")" + << "\n z(" << m_BBox.m_Min.z << "," << m_BBox.m_Max.z << ")" << std::endl; if(!l_bParseOk) @@ -251,7 +250,7 @@ bool C_3DObject::LoadGeometryData(const char *f_pFilePath, Geometry_t &f_Geom) { f_Geom.m_verts.push_back(l_v3); //update boundingbox - UpdBBox(m_BBox, l_v3); + m_BBox << l_v3; } break; diff --git a/matchblox/engine/C_3DObject.h b/matchblox/engine/C_3DObject.h index 4027596..55ae123 100644 --- a/matchblox/engine/C_3DObject.h +++ b/matchblox/engine/C_3DObject.h @@ -37,6 +37,7 @@ public: inline const Vect3D_t& GetRot() { return m_Rot; } inline const Vect3D_t& GetScale() { return m_Scale; } inline const BoundingBox_t& GetBoundingBox() { return m_BBox; } + inline const BoundingBox_t& GetAbsBoundBox() { return m_BBox + m_Pos; } inline bool Initialized() { return m_bDispListValid; } void TransRotateScale(); //applies the scaling, translation and rotation diff --git a/matchblox/engine/C_Box.cpp b/matchblox/engine/C_Box.cpp index 9bde3ff..343ae98 100644 --- a/matchblox/engine/C_Box.cpp +++ b/matchblox/engine/C_Box.cpp @@ -20,7 +20,7 @@ C_Box::C_Box(const char *f_strFileName, //calculate the tile size (this should be the same //for all tile types) BoundingBox_t l_BBox = m_pTiles[0]->GetBoundingBox(); - m_dTileSize = l_BBox.m_dRight - l_BBox.m_dLeft; + m_dTileSize = l_BBox.m_Max.x - l_BBox.m_Min.x; //calculate the lower left tile position (in xz plane) m_LowLeftTilePos = Vect3D_t(-m_dTileSize * (double)(m_iTilesX-1)/2.0, diff --git a/matchblox/engine/C_MatchBloxEngine.cpp b/matchblox/engine/C_MatchBloxEngine.cpp index 52ffde9..dafa6a5 100644 --- a/matchblox/engine/C_MatchBloxEngine.cpp +++ b/matchblox/engine/C_MatchBloxEngine.cpp @@ -15,7 +15,9 @@ #include "bitmap.h" C_MatchBloxEngine::C_MatchBloxEngine(const char *f_strModelPath, - const char *f_strLogFile) + const char *f_strLogFile, + GameSettings f_GameSettings) +: m_GameSettings(f_GameSettings) { //create logger @@ -37,19 +39,10 @@ C_MatchBloxEngine::C_MatchBloxEngine(const char *f_strModelPath, //init vars m_CurrentBox = BS_SMALL; - //debug - m_pBox[0]->SetPos(0.0, -5.0, -15.0); - m_pBox[0]->SetRot(45.0, 0.0, 0.0); - m_pBox[0]->RandomizeTiles(); - - m_pBlock[0]->SetPos(-6.0, 1.0, -10.0); - m_pBlock[0]->SetRot(90.0, 0.0, 0.0); - m_pBlock[1]->SetPos(-2.0, 1.0, -10.0); - m_pBlock[1]->SetRot(90.0, 0.0, 0.0); - m_pBlock[2]->SetPos(2.0, 1.0, -10.0); - m_pBlock[2]->SetRot(90.0, 0.0, 0.0); - m_pBlock[3]->SetPos(6.0, 1.0, -10.0); - m_pBlock[3]->SetRot(90.0, 0.0, 0.0); + //init the world bounding box + m_WorldBox.m_Min = Vect3D_t(-50.0, -50.0, -50.0); + m_WorldBox.m_Max = Vect3D_t(50.0, 50.0, 0.0); + } C_MatchBloxEngine::~C_MatchBloxEngine() @@ -60,10 +53,28 @@ C_MatchBloxEngine::~C_MatchBloxEngine() DeleteModels(); } -GameResult C_MatchBloxEngine::GameStep(void) +GameResult C_MatchBloxEngine::ProcessMsgs(msgQueue &f_Queue) { + msgStruct l_msg; + //process message queue - return GR_ERROR; + while (!f_Queue.empty()) + { + //get the first msg + l_msg = f_Queue.front(); + f_Queue.pop(); + + switch (l_msg.m_MessageType) + { + case WII_CURSOR_MOVE: + + break; + + case WII_BUTTON_PRESS: + break; + } + } + return GR_BUSY; } void C_MatchBloxEngine::Render_Basics(unsigned int f_uiElapsedTime) @@ -71,10 +82,13 @@ void C_MatchBloxEngine::Render_Basics(unsigned int f_uiElapsedTime) //render the environment m_pEnvMap->Render(); - m_pBox[(intptr_t)m_CurrentBox]->Render(); - for (int i=0; i<4; i++) - m_pBlock[i]->Render(f_uiElapsedTime); -// m_pHand->Render(f_uiElapsedTime); + if (m_pCurrentSession) + { + m_pBox[(int)m_pCurrentSession->m_BoxSize]->Render(); + for (int i=0; i<4; i++) + m_pBlock[i]->Render(f_uiElapsedTime); + // m_pHand->Render(f_uiElapsedTime); + } } void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime) @@ -148,15 +162,17 @@ bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS) { //log new game - //prepare a fresh box - m_CurrentBox = f_BS; - m_pBox[(int)m_CurrentBox]->RandomizeTiles(); + //prepare a session struct for administration + m_pCurrentSession = new GameSession(8, f_BS); + + //randomize the box tiles + m_pBox[(int)m_pCurrentSession->m_BoxSize]->RandomizeTiles(); + //init box's position + m_pBox[(int)m_pCurrentSession->m_BoxSize]->SetPos(0.0, -6.0, -15.0); //set state to GET READY m_State = ES_GET_READY; - //init object positions - m_pBox[(int)m_CurrentBox]->SetPos(0.0, -6.0, -15.0); return true; } @@ -165,6 +181,20 @@ bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS) bool C_MatchBloxEngine::StartGame() { + if (m_State == ES_GET_READY) + { + BlockType l_Block; + + //start the session timer + l_Block = m_pCurrentSession->StartSession(); + + //move a block into the sky + m_pBlock[(int)l_Block]->SetPos(0.0, 0.0, 15.0); + + m_State = ES_PLAYING_GRAB_BLOCK; + + return true; + } return false; } @@ -178,7 +208,7 @@ bool C_MatchBloxEngine::Pause() m_SavedState = m_State; //probably do something with a time variable - + //set current state to paused m_State = ES_PAUSED; @@ -346,3 +376,112 @@ void C_MatchBloxEngine::LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } +void C_MatchBloxEngine::CursorMove(Vect3D_t &f_NewCursorPos) +{ + //check the state to see what 3d object currently has to be considered to + //be the cursor currently is and which bounding box we need to check for overlap + BoundingBox_t l_CursBBox; + bool l_bCollision = false; //indicates a collission has happend + + switch (m_State) + { + case ES_PLAYING_PUT_BLOCK: + //cursor is the current block figure (that is being held by the player) + //translate the bounding box of the block with the cursor position + l_CursBBox = m_pBlock[m_CurrentBlock]->GetBoundingBox() + f_NewCursorPos; + break; + + default: + //cursor is the hand object + l_CursBBox = m_pHand->GetBoundingBox() + f_NewCursorPos; + break; + } + + //now we have the bounding box of the cursor which we use to do some simple hit tests + + //make sure the cursor is still completely contained in the world bounding box + if (!m_WorldBox.Contains(l_CursBBox)) + { + //restore the previous cursor position, because the new one is invalid + //... nothing to do actually + //maybe generate some vibration event and collision animation??? + l_bCollision = true; + } + else + { + //check for bounding box overlap with the static elements in the scene + //actually only the block box + if (m_pBox[m_CurrentBox]->GetAbsBoundBox().Overlap(l_CursBBox)) + { + //overlap with the block box, a collision is very likely so set + //collision to true and reset to false when the player is putting + //the block in the right hole (if the player is holding a block + //that is, if the player isn't then there is certainly a collision) + l_bCollision = true; + + //check if we are holding a block that has to be put in the box + if (m_State == ES_PLAYING_PUT_BLOCK) + { + + + } + else + { + //we are not holding a block so every contact with the + //block box is a collision + l_bCollision = true; + } + } + } + +} + +bool C_MatchBloxEngine::CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CursBBox) +{ + //check if the block is being put in the right hole + //by testing whether the position of the cursor is close + //enough to the center of the correct hole + //note that the hole positions are relative to the position + //of the box + bool l_bCollision = false; + Vect3D_t l_AbsHolePos = m_pBox[m_CurrentBox]->GetPos() + + m_pTiles[m_CurrentBlock]->GetPos(); + Vect3D_t l_PosDif = l_AbsHolePos - f_CursPos; + double l_dXZProximity = l_PosDif.x * l_PosDif.x + + l_PosDif.y * l_PosDif.y; + + if (l_dXZProximity < m_GameSettings.m_dMinProximity) + { + //the block the player is holding is considered to be in the right hole + //l_bCollision = false; + + //?? would it not be better to check for bounding box intersection with hole? + l_bCollision = !(m_pTiles[m_CurrentBlock]->GetAbsBoundBox() + + m_pBox[m_CurrentBox]->GetPos()).Overlap(f_CursBBox); + + //now check if the block is far enough in the hole to count as a point + if (l_PosDif.z > m_GameSettings.m_dHoleDepth) + { + //yipee!! we have got a winner!! + m_CurrentBlock = m_pCurrentSession->NewTurn(); + + //m_GameState + } + + + + } + + return false; +} + +bool C_MatchBloxEngine::CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CursBBox) +{ + //grabbing a block: just check for bounding box intersection + if (m_pBlock[(int)m_CurrentBlock]->GetAbsBoundBox().Overlap(f_CursBBox)) + { + + } + return true; +} + diff --git a/matchblox/engine/C_MatchBloxEngine.h b/matchblox/engine/C_MatchBloxEngine.h index 21e6b3b..48a17b7 100644 --- a/matchblox/engine/C_MatchBloxEngine.h +++ b/matchblox/engine/C_MatchBloxEngine.h @@ -3,6 +3,7 @@ #define C_MATCHBLOXENGINE_HEADER_FILE #include "MessageQueue.h" +#include "typedefs.h" class C_3DObject; class C_Block; @@ -44,15 +45,99 @@ enum BoxSize BS_LARGE = 2 }; +struct GameSettings +{ + int m_iNrOfTurns; + double m_dMinProximity, //The minimum allowed squared (xz) distance between + //the center of the block and the center of the hole + //for the block to be considered to be in the hole + m_dHoleDepth; //Depth of a hole; the minimum z distance between block + //and a hole, for the block to be successfully inserted + //into the box +}; + +struct GameSession +{ + int m_iTotalTurns, + m_iCurrentTurn; + unsigned int m_uiSessionStart, //time in ms + m_uiTurnStart, + m_uiPauseStart, + *m_puiTurnResult; + int m_iBlocksLeft[4]; //number of blocks per type + BlockType m_CurrentBlockType; + BoxSize m_BoxSize; + + GameSession(int f_iNrOfBlocks, BoxSize f_BS) + : m_iTotalTurns(f_iNrOfBlocks), m_iCurrentTurn(0), + m_BoxSize(f_BS) + { + m_puiTurnResult = new unsigned int[f_iNrOfBlocks]; + + //divide the number of blocks between the block types + int l_iNrPerType = f_iNrOfBlocks/4, + l_iLeft = f_iNrOfBlocks%4; //the left-over count + for(int i=0; i<4; i++) + { + m_iBlocksLeft[i] = l_iNrPerType; + if (l_iLeft > 0) + { + m_iBlocksLeft[i]++; l_iLeft--; + } + } + } + ~GameSession() + { + delete [] m_puiTurnResult; + } + BlockType StartSession() + { + m_uiSessionStart = m_uiTurnStart = glutGet(GLUT_ELAPSED_TIME); + return GetRandomBlockType(); + } + BlockType NewTurn() + { + unsigned int l_uiTime = glutGet(GLUT_ELAPSED_TIME); + + //save turn result + m_puiTurnResult[m_iCurrentTurn] = l_uiTime - m_uiTurnStart; + m_iCurrentTurn++; + m_uiTurnStart = l_uiTime; + + return GetRandomBlockType(); + } + BlockType GetRandomBlockType() + { + int l_iBlockType = rand()%4; + while (m_iBlocksLeft[l_iBlockType] <= 0) + l_iBlockType = (l_iBlockType+1)%4; + + m_iBlocksLeft[l_iBlockType]--; + return (BlockType)l_iBlockType; + } + void PauseSession() + { + //record the time at which the pause starts + m_uiPauseStart = glutGet(GLUT_ELAPSED_TIME); + } + void ResumeSession() + { + //add the total pause time to the timers + unsigned int l_uiPauseTime = glutGet(GLUT_ELAPSED_TIME) - m_uiPauseStart; + m_uiSessionStart += l_uiPauseTime; + m_uiTurnStart += l_uiPauseTime; + } +}; class C_MatchBloxEngine { public: C_MatchBloxEngine(const char *f_strModelPath, - const char *f_strLogFile); + const char *f_strLogFile, + GameSettings f_GameSettings); ~C_MatchBloxEngine(); - GameResult GameStep(void); + GameResult ProcessMsgs(msgQueue &f_Queue); void Render(unsigned int f_uiElapsedTime); bool NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS); @@ -74,13 +159,28 @@ private: m_uiWood3Tex; EngineState m_State, m_SavedState; - BoxSize m_CurrentBox; + GameSession *m_pCurrentSession; + GameSettings m_GameSettings; + BoxSize m_CurrentBox; + BlockType m_CurrentBlock; - void Render_Basics(unsigned int f_uiElapsedTime); + BoundingBox_t m_WorldBox; //an invisible box that limits the movement of the + //player + + //init routines bool LoadModels(const char* f_strModelDir); void DeleteModels(); void LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle); + + //render routines + void Render_Basics(unsigned int f_uiElapsedTime); + + //event/input handlers + void CursorMove(Vect3D_t &f_NewCursorPos); + bool CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox); + bool CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox); + }; #endif //C_MATCHBLOXENGINE_HEADER_FILE diff --git a/matchblox/engine/MessageQueue.h b/matchblox/engine/MessageQueue.h deleted file mode 100644 index 47a061e..0000000 --- a/matchblox/engine/MessageQueue.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MESSAGEQUEUE_HEADER_FILE - -#define MESSAGEQUEUE_HEADER_FILE - -#include - -typedef enum msgType -{ - MOUSE_MOVE, - MOUSE_PRESS, - KEY_PRESS, - SPECIAL_KEY, - WII_CURSOR_MOVE, - WII_BUTTON_PRESS -}; - -typedef struct message -{ - msgType m_MessageType; - int parm1, parm2, parm3, parm4; -} msgStruct; - -typedef std::queue msgQueue; - -#endif //MESSAGEQUEUE_HEADER_FILE - diff --git a/matchblox/engine/typedefs.h b/matchblox/engine/typedefs.h index 0262c14..7acb776 100644 --- a/matchblox/engine/typedefs.h +++ b/matchblox/engine/typedefs.h @@ -5,22 +5,6 @@ #include #include -typedef struct bb -{ - bb() { - //init a bounding box with the min values set to max double and visa versa - m_dLeft = m_dBottom = m_dFront = std::numeric_limits::max(); - m_dRight = m_dTop = m_dBack = -std::numeric_limits::max(); - } - - double m_dLeft, //min x - m_dBottom, //min y - m_dFront, //min z - m_dRight, //max x - m_dTop, //max y - m_dBack; //max z - -} BoundingBox_t; typedef struct vec3d { @@ -45,33 +29,77 @@ typedef struct vec3d inline vec3d& operator*=(const double &scal) { x*=scal; y*=scal; z*=scal; return *this; } - inline const vec3d& operator+(const vec3d &rhs) + inline const vec3d& operator+(const vec3d &rhs) const { return vec3d(*this) += rhs; } - inline const vec3d& operator-(const vec3d &rhs) + inline const vec3d& operator-(const vec3d &rhs) const { return vec3d(*this) -= rhs; } - inline const vec3d& operator*(const vec3d &rhs) + inline const vec3d& operator*(const vec3d &rhs) const { return vec3d(*this) *= rhs; } - inline const vec3d& operator*(const double &scal) + inline const vec3d& operator*(const double &scal) const { return vec3d(*this) *= scal; } } Vect3D_t; +typedef struct bb +{ + Vect3D_t m_Min, //minimal corner vertex (-x, -y, -z) + m_Max; //maximal corner vertex (+x, +y, +z) + //default constructor creates a maximum inverted bounding box + bb() + { + //init a bounding box with the min values set to max double and visa versa + double l_doubleMax = std::numeric_limits::max(); + m_Min = Vect3D_t(l_doubleMax, l_doubleMax, l_doubleMax); + m_Max = Vect3D_t(-l_doubleMax, -l_doubleMax, -l_doubleMax); + } + + //copy constructor + bb(const bb &b) : m_Min(b.m_Min), m_Max(b.m_Max) {} + + //translating a bounding box + inline bb& operator+=(const Vect3D_t &v) + { m_Min += v; m_Max += v; return *this; } + inline const bb& operator+(const Vect3D_t &v) const + { return (bb(*this) += v); } + + //update the bounding box min/max coords with vertex v + inline bb& operator<<(const Vect3D_t &v) + { + if (v.x < m_Min.x) m_Min.x = v.x; + else if (v.x > m_Max.x) m_Max.x = v.x; + if (v.y < m_Min.y) m_Min.y = v.y; + else if (v.y > m_Max.y) m_Max.y = v.y; + if (v.z < m_Min.z) m_Min.z = v.z; + else if (v.z > m_Max.z) m_Max.z = v.z; + return *this; + } + + inline bool Contains(const Vect3D_t &v) const + { + //check if the point is contained in the box + return m_Min.x < v.x && v.x < m_Max.x && + m_Min.y < v.y && v.y < m_Max.y && + m_Min.z < v.z && v.z < m_Max.z; + } + + inline bool Contains(const bb& b) const + { + return Contains(b.m_Min) && Contains(b.m_Max); + } + + inline bool Overlap(const bb& rhs) const + { + //check if the boxes overlap in all three axis + return ( ( m_Min.x < rhs.m_Min.x && rhs.m_Min.x < rhs.m_Max.x) || + ( m_Min.x < rhs.m_Max.x && rhs.m_Max.x < rhs.m_Max.x) ) && + ( ( m_Min.y < rhs.m_Min.y && rhs.m_Min.y < rhs.m_Max.y) || + ( m_Min.y < rhs.m_Max.y && rhs.m_Max.y < rhs.m_Max.y) ) && + ( ( m_Min.z < rhs.m_Min.z && rhs.m_Min.z < rhs.m_Max.z) || + ( m_Min.z < rhs.m_Max.z && rhs.m_Max.z < rhs.m_Max.z) ); + } + +} BoundingBox_t; -inline void UpdBBox(BoundingBox_t &B, Vect3D_t &V) -{ - if (V.x < B.m_dLeft) - B.m_dLeft = V.x; - else if (V.x > B.m_dRight) - B.m_dRight = V.x; - if (V.y < B.m_dBottom) - B.m_dBottom = V.y; - else if (V.y > B.m_dTop) - B.m_dTop = V.y; - if (V.z < B.m_dFront) - B.m_dFront = V.z; - else if (V.z > B.m_dBack) - B.m_dBack = V.z; -}; typedef struct triangle { diff --git a/matchblox/include/GL/glut.h b/matchblox/include/GL/glut.h new file mode 100644 index 0000000..ce0d73c --- /dev/null +++ b/matchblox/include/GL/glut.h @@ -0,0 +1,721 @@ +#ifndef __glut_h__ +#define __glut_h__ + +/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ + +/* This program is freely distributable without licensing fees and is + provided without guarantee or warrantee expressed or implied. This + program is -not- in the public domain. */ + +#if defined(_WIN32) + +/* GLUT 3.7 now tries to avoid including + to avoid name space pollution, but Win32's + needs APIENTRY and WINGDIAPI defined properly. */ +# if 0 + /* This would put tons of macros and crap in our clean name space. */ +# define WIN32_LEAN_AND_MEAN +# include +# else + /* XXX This is from Win32's */ +# ifndef APIENTRY +# define GLUT_APIENTRY_DEFINED +# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +# endif + /* XXX This is from Win32's */ +# ifndef CALLBACK +# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +# endif + /* XXX Hack for lcc compiler. It doesn't support __declspec(dllimport), just __stdcall. */ +# if defined( __LCC__ ) +# undef WINGDIAPI +# define WINGDIAPI __stdcall +# else + /* XXX This is from Win32's and */ +# ifndef WINGDIAPI +# define GLUT_WINGDIAPI_DEFINED +# define WINGDIAPI __declspec(dllimport) +# endif +# endif + /* XXX This is from Win32's */ +# ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +# endif +# endif + +/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA + in your compile preprocessor options. */ +# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA) +# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */ +/* To enable automatic SGI OpenGL for Windows library usage for GLUT, + define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */ +# ifdef GLUT_USE_SGI_OPENGL +# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */ +# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */ +# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */ +# else +# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */ +# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */ +# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */ +# endif +# endif + +/* To disable supression of annoying warnings about floats being promoted + to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor + options. */ +# ifndef GLUT_NO_WARNING_DISABLE +# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */ +# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */ +# endif + +/* Win32 has an annoying issue where there are multiple C run-time + libraries (CRTs). If the executable is linked with a different CRT + from the GLUT DLL, the GLUT DLL will not share the same CRT static + data seen by the executable. In particular, atexit callbacks registered + in the executable will not be called if GLUT calls its (different) + exit routine). GLUT is typically built with the + "/MD" option (the CRT with multithreading DLL support), but the Visual + C++ linker default is "/ML" (the single threaded CRT). + + One workaround to this issue is requiring users to always link with + the same CRT as GLUT is compiled with. That requires users supply a + non-standard option. GLUT 3.7 has its own built-in workaround where + the executable's "exit" function pointer is covertly passed to GLUT. + GLUT then calls the executable's exit function pointer to ensure that + any "atexit" calls registered by the application are called if GLUT + needs to exit. + + Note that the __glut*WithExit routines should NEVER be called directly. + To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */ + +/* XXX This is from Win32's */ +# if !defined(_MSC_VER) && !defined(__cdecl) + /* Define __cdecl for non-Microsoft compilers. */ +# define __cdecl +# define GLUT_DEFINED___CDECL +# endif +# ifndef _CRTIMP +# ifdef _NTSDK + /* Definition compatible with NT SDK */ +# define _CRTIMP +# else + /* Current definition */ +# ifdef _DLL +# define _CRTIMP __declspec(dllimport) +# else +# define _CRTIMP +# endif +# endif +# define GLUT_DEFINED__CRTIMP +# endif + +/* GLUT API entry point declarations for Win32. */ +# ifdef GLUT_BUILDING_LIB +# define GLUTAPI __declspec(dllexport) +# else +# ifdef _DLL +# define GLUTAPI __declspec(dllimport) +# else +# define GLUTAPI extern +# endif +# endif + +/* GLUT callback calling convention for Win32. */ +# define GLUTCALLBACK __cdecl + +#endif /* _WIN32 */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//#if defined(_WIN32) +//# ifndef GLUT_BUILDING_LIB +//extern _CRTIMP void __cdecl exit(int); +//# endif +#if defined(_WIN32) +# ifndef GLUT_BUILDING_LIB /*extern _CRTIMP void __cdecl exit(int);*/ + _CRTIMP __declspec(noreturn) void __cdecl exit(int); +# endif + +#else +/* non-Win32 case. */ +/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */ +# define APIENTRY +# define GLUT_APIENTRY_DEFINED +# define CALLBACK +/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */ +# define GLUTAPI extern +# define GLUTCALLBACK +/* Prototype exit for the non-Win32 case (see above). */ +extern void exit(int); +#endif + +/** + GLUT API revision history: + + GLUT_API_VERSION is updated to reflect incompatible GLUT + API changes (interface changes, semantic changes, deletions, + or additions). + + GLUT_API_VERSION=1 First public release of GLUT. 11/29/94 + + GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling, + extension. Supports new input devices like tablet, dial and button + box, and Spaceball. Easy to query OpenGL extensions. + + GLUT_API_VERSION=3 glutMenuStatus added. + + GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer, + glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic + video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc, + glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat, + glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!). +**/ +#ifndef GLUT_API_VERSION /* allow this to be overriden */ +#define GLUT_API_VERSION 3 +#endif + +/** + GLUT implementation revision history: + + GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT + API revisions and implementation revisions (ie, bug fixes). + + GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of + GLUT Xlib-based implementation. 11/29/94 + + GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of + GLUT Xlib-based implementation providing GLUT version 2 + interfaces. + + GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95 + + GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95 + + GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95 + + GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96 + + GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner + and video resize. 1/3/97 + + GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines. + + GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release. + + GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling. + + GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support. + + GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface. + + GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa +**/ +#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */ +#define GLUT_XLIB_IMPLEMENTATION 15 +#endif + +/* Display mode bit masks. */ +#define GLUT_RGB 0 +#define GLUT_RGBA GLUT_RGB +#define GLUT_INDEX 1 +#define GLUT_SINGLE 0 +#define GLUT_DOUBLE 2 +#define GLUT_ACCUM 4 +#define GLUT_ALPHA 8 +#define GLUT_DEPTH 16 +#define GLUT_STENCIL 32 +#if (GLUT_API_VERSION >= 2) +#define GLUT_MULTISAMPLE 128 +#define GLUT_STEREO 256 +#endif +#if (GLUT_API_VERSION >= 3) +#define GLUT_LUMINANCE 512 +#endif + +/* Mouse buttons. */ +#define GLUT_LEFT_BUTTON 0 +#define GLUT_MIDDLE_BUTTON 1 +#define GLUT_RIGHT_BUTTON 2 + +/* Mouse button state. */ +#define GLUT_DOWN 0 +#define GLUT_UP 1 + +#if (GLUT_API_VERSION >= 2) +/* function keys */ +#define GLUT_KEY_F1 1 +#define GLUT_KEY_F2 2 +#define GLUT_KEY_F3 3 +#define GLUT_KEY_F4 4 +#define GLUT_KEY_F5 5 +#define GLUT_KEY_F6 6 +#define GLUT_KEY_F7 7 +#define GLUT_KEY_F8 8 +#define GLUT_KEY_F9 9 +#define GLUT_KEY_F10 10 +#define GLUT_KEY_F11 11 +#define GLUT_KEY_F12 12 +/* directional keys */ +#define GLUT_KEY_LEFT 100 +#define GLUT_KEY_UP 101 +#define GLUT_KEY_RIGHT 102 +#define GLUT_KEY_DOWN 103 +#define GLUT_KEY_PAGE_UP 104 +#define GLUT_KEY_PAGE_DOWN 105 +#define GLUT_KEY_HOME 106 +#define GLUT_KEY_END 107 +#define GLUT_KEY_INSERT 108 +#endif + +/* Entry/exit state. */ +#define GLUT_LEFT 0 +#define GLUT_ENTERED 1 + +/* Menu usage state. */ +#define GLUT_MENU_NOT_IN_USE 0 +#define GLUT_MENU_IN_USE 1 + +/* Visibility state. */ +#define GLUT_NOT_VISIBLE 0 +#define GLUT_VISIBLE 1 + +/* Window status state. */ +#define GLUT_HIDDEN 0 +#define GLUT_FULLY_RETAINED 1 +#define GLUT_PARTIALLY_RETAINED 2 +#define GLUT_FULLY_COVERED 3 + +/* Color index component selection values. */ +#define GLUT_RED 0 +#define GLUT_GREEN 1 +#define GLUT_BLUE 2 + +#if defined(_WIN32) +/* Stroke font constants (use these in GLUT program). */ +#define GLUT_STROKE_ROMAN ((void*)0) +#define GLUT_STROKE_MONO_ROMAN ((void*)1) + +/* Bitmap font constants (use these in GLUT program). */ +#define GLUT_BITMAP_9_BY_15 ((void*)2) +#define GLUT_BITMAP_8_BY_13 ((void*)3) +#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4) +#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5) +#if (GLUT_API_VERSION >= 3) +#define GLUT_BITMAP_HELVETICA_10 ((void*)6) +#define GLUT_BITMAP_HELVETICA_12 ((void*)7) +#define GLUT_BITMAP_HELVETICA_18 ((void*)8) +#endif +#else +/* Stroke font opaque addresses (use constants instead in source code). */ +GLUTAPI void *glutStrokeRoman; +GLUTAPI void *glutStrokeMonoRoman; + +/* Stroke font constants (use these in GLUT program). */ +#define GLUT_STROKE_ROMAN (&glutStrokeRoman) +#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman) + +/* Bitmap font opaque addresses (use constants instead in source code). */ +GLUTAPI void *glutBitmap9By15; +GLUTAPI void *glutBitmap8By13; +GLUTAPI void *glutBitmapTimesRoman10; +GLUTAPI void *glutBitmapTimesRoman24; +GLUTAPI void *glutBitmapHelvetica10; +GLUTAPI void *glutBitmapHelvetica12; +GLUTAPI void *glutBitmapHelvetica18; + +/* Bitmap font constants (use these in GLUT program). */ +#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15) +#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13) +#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10) +#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24) +#if (GLUT_API_VERSION >= 3) +#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10) +#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12) +#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18) +#endif +#endif + +/* glutGet parameters. */ +#define GLUT_WINDOW_X ((GLenum) 100) +#define GLUT_WINDOW_Y ((GLenum) 101) +#define GLUT_WINDOW_WIDTH ((GLenum) 102) +#define GLUT_WINDOW_HEIGHT ((GLenum) 103) +#define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104) +#define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105) +#define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106) +#define GLUT_WINDOW_RED_SIZE ((GLenum) 107) +#define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108) +#define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109) +#define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110) +#define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111) +#define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112) +#define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113) +#define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114) +#define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115) +#define GLUT_WINDOW_RGBA ((GLenum) 116) +#define GLUT_WINDOW_PARENT ((GLenum) 117) +#define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118) +#define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119) +#if (GLUT_API_VERSION >= 2) +#define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120) +#define GLUT_WINDOW_STEREO ((GLenum) 121) +#endif +#if (GLUT_API_VERSION >= 3) +#define GLUT_WINDOW_CURSOR ((GLenum) 122) +#endif +#define GLUT_SCREEN_WIDTH ((GLenum) 200) +#define GLUT_SCREEN_HEIGHT ((GLenum) 201) +#define GLUT_SCREEN_WIDTH_MM ((GLenum) 202) +#define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203) +#define GLUT_MENU_NUM_ITEMS ((GLenum) 300) +#define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400) +#define GLUT_INIT_WINDOW_X ((GLenum) 500) +#define GLUT_INIT_WINDOW_Y ((GLenum) 501) +#define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502) +#define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503) +#define GLUT_INIT_DISPLAY_MODE ((GLenum) 504) +#if (GLUT_API_VERSION >= 2) +#define GLUT_ELAPSED_TIME ((GLenum) 700) +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +#define GLUT_WINDOW_FORMAT_ID ((GLenum) 123) +#endif + +#if (GLUT_API_VERSION >= 2) +/* glutDeviceGet parameters. */ +#define GLUT_HAS_KEYBOARD ((GLenum) 600) +#define GLUT_HAS_MOUSE ((GLenum) 601) +#define GLUT_HAS_SPACEBALL ((GLenum) 602) +#define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603) +#define GLUT_HAS_TABLET ((GLenum) 604) +#define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605) +#define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606) +#define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607) +#define GLUT_NUM_DIALS ((GLenum) 608) +#define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609) +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +#define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610) +#define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611) +#define GLUT_HAS_JOYSTICK ((GLenum) 612) +#define GLUT_OWNS_JOYSTICK ((GLenum) 613) +#define GLUT_JOYSTICK_BUTTONS ((GLenum) 614) +#define GLUT_JOYSTICK_AXES ((GLenum) 615) +#define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616) +#endif + +#if (GLUT_API_VERSION >= 3) +/* glutLayerGet parameters. */ +#define GLUT_OVERLAY_POSSIBLE ((GLenum) 800) +#define GLUT_LAYER_IN_USE ((GLenum) 801) +#define GLUT_HAS_OVERLAY ((GLenum) 802) +#define GLUT_TRANSPARENT_INDEX ((GLenum) 803) +#define GLUT_NORMAL_DAMAGED ((GLenum) 804) +#define GLUT_OVERLAY_DAMAGED ((GLenum) 805) + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +/* glutVideoResizeGet parameters. */ +#define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900) +#define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901) +#define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902) +#define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903) +#define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904) +#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905) +#define GLUT_VIDEO_RESIZE_X ((GLenum) 906) +#define GLUT_VIDEO_RESIZE_Y ((GLenum) 907) +#define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908) +#define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909) +#endif + +/* glutUseLayer parameters. */ +#define GLUT_NORMAL ((GLenum) 0) +#define GLUT_OVERLAY ((GLenum) 1) + +/* glutGetModifiers return mask. */ +#define GLUT_ACTIVE_SHIFT 1 +#define GLUT_ACTIVE_CTRL 2 +#define GLUT_ACTIVE_ALT 4 + +/* glutSetCursor parameters. */ +/* Basic arrows. */ +#define GLUT_CURSOR_RIGHT_ARROW 0 +#define GLUT_CURSOR_LEFT_ARROW 1 +/* Symbolic cursor shapes. */ +#define GLUT_CURSOR_INFO 2 +#define GLUT_CURSOR_DESTROY 3 +#define GLUT_CURSOR_HELP 4 +#define GLUT_CURSOR_CYCLE 5 +#define GLUT_CURSOR_SPRAY 6 +#define GLUT_CURSOR_WAIT 7 +#define GLUT_CURSOR_TEXT 8 +#define GLUT_CURSOR_CROSSHAIR 9 +/* Directional cursors. */ +#define GLUT_CURSOR_UP_DOWN 10 +#define GLUT_CURSOR_LEFT_RIGHT 11 +/* Sizing cursors. */ +#define GLUT_CURSOR_TOP_SIDE 12 +#define GLUT_CURSOR_BOTTOM_SIDE 13 +#define GLUT_CURSOR_LEFT_SIDE 14 +#define GLUT_CURSOR_RIGHT_SIDE 15 +#define GLUT_CURSOR_TOP_LEFT_CORNER 16 +#define GLUT_CURSOR_TOP_RIGHT_CORNER 17 +#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18 +#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19 +/* Inherit from parent window. */ +#define GLUT_CURSOR_INHERIT 100 +/* Blank cursor. */ +#define GLUT_CURSOR_NONE 101 +/* Fullscreen crosshair (if available). */ +#define GLUT_CURSOR_FULL_CROSSHAIR 102 +#endif + +/* GLUT initialization sub-API. */ +GLUTAPI void APIENTRY glutInit(int *argcp, char **argv); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI void APIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); } +#define glutInit glutInit_ATEXIT_HACK +#endif +#endif +GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutInitDisplayString(const char *string); +#endif +GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y); +GLUTAPI void APIENTRY glutInitWindowSize(int width, int height); +GLUTAPI void APIENTRY glutMainLoop(void); + +/* GLUT window sub-API. */ +GLUTAPI int APIENTRY glutCreateWindow(const char *title); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI int APIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); } +#define glutCreateWindow glutCreateWindow_ATEXIT_HACK +#endif +#endif +GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height); +GLUTAPI void APIENTRY glutDestroyWindow(int win); +GLUTAPI void APIENTRY glutPostRedisplay(void); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) +GLUTAPI void APIENTRY glutPostWindowRedisplay(int win); +#endif +GLUTAPI void APIENTRY glutSwapBuffers(void); +GLUTAPI int APIENTRY glutGetWindow(void); +GLUTAPI void APIENTRY glutSetWindow(int win); +GLUTAPI void APIENTRY glutSetWindowTitle(const char *title); +GLUTAPI void APIENTRY glutSetIconTitle(const char *title); +GLUTAPI void APIENTRY glutPositionWindow(int x, int y); +GLUTAPI void APIENTRY glutReshapeWindow(int width, int height); +GLUTAPI void APIENTRY glutPopWindow(void); +GLUTAPI void APIENTRY glutPushWindow(void); +GLUTAPI void APIENTRY glutIconifyWindow(void); +GLUTAPI void APIENTRY glutShowWindow(void); +GLUTAPI void APIENTRY glutHideWindow(void); +#if (GLUT_API_VERSION >= 3) +GLUTAPI void APIENTRY glutFullScreen(void); +GLUTAPI void APIENTRY glutSetCursor(int cursor); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutWarpPointer(int x, int y); +#endif + +/* GLUT overlay sub-API. */ +GLUTAPI void APIENTRY glutEstablishOverlay(void); +GLUTAPI void APIENTRY glutRemoveOverlay(void); +GLUTAPI void APIENTRY glutUseLayer(GLenum layer); +GLUTAPI void APIENTRY glutPostOverlayRedisplay(void); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) +GLUTAPI void APIENTRY glutPostWindowOverlayRedisplay(int win); +#endif +GLUTAPI void APIENTRY glutShowOverlay(void); +GLUTAPI void APIENTRY glutHideOverlay(void); +#endif + +/* GLUT menu sub-API. */ +GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int)); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI int APIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); } +#define glutCreateMenu glutCreateMenu_ATEXIT_HACK +#endif +#endif +GLUTAPI void APIENTRY glutDestroyMenu(int menu); +GLUTAPI int APIENTRY glutGetMenu(void); +GLUTAPI void APIENTRY glutSetMenu(int menu); +GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value); +GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu); +GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value); +GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu); +GLUTAPI void APIENTRY glutRemoveMenuItem(int item); +GLUTAPI void APIENTRY glutAttachMenu(int button); +GLUTAPI void APIENTRY glutDetachMenu(int button); + +/* GLUT window callback sub-API. */ +GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void)); +GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height)); +GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); +GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); +GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state)); +GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state)); +GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void)); +GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value); +GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state)); +#if (GLUT_API_VERSION >= 2) +GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); +GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); +GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); +GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state)); +GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state)); +GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value)); +GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); +#if (GLUT_API_VERSION >= 3) +GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y)); +GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void)); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state)); +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +GLUTAPI void APIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); +GLUTAPI void APIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); +GLUTAPI void APIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval); +#endif +#endif +#endif + +/* GLUT color index sub-API. */ +GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue); +GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component); +GLUTAPI void APIENTRY glutCopyColormap(int win); + +/* GLUT state retrieval sub-API. */ +GLUTAPI int APIENTRY glutGet(GLenum type); +GLUTAPI int APIENTRY glutDeviceGet(GLenum type); +#if (GLUT_API_VERSION >= 2) +/* GLUT extension support sub-API */ +GLUTAPI int APIENTRY glutExtensionSupported(const char *name); +#endif +#if (GLUT_API_VERSION >= 3) +GLUTAPI int APIENTRY glutGetModifiers(void); +GLUTAPI int APIENTRY glutLayerGet(GLenum type); +#endif + +/* GLUT font sub-API */ +GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character); +GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character); +GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character); +GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI int APIENTRY glutBitmapLength(void *font, const unsigned char *string); +GLUTAPI int APIENTRY glutStrokeLength(void *font, const unsigned char *string); +#endif + +/* GLUT pre-built models sub-API */ +GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutWireCube(GLdouble size); +GLUTAPI void APIENTRY glutSolidCube(GLdouble size); +GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +GLUTAPI void APIENTRY glutWireDodecahedron(void); +GLUTAPI void APIENTRY glutSolidDodecahedron(void); +GLUTAPI void APIENTRY glutWireTeapot(GLdouble size); +GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size); +GLUTAPI void APIENTRY glutWireOctahedron(void); +GLUTAPI void APIENTRY glutSolidOctahedron(void); +GLUTAPI void APIENTRY glutWireTetrahedron(void); +GLUTAPI void APIENTRY glutSolidTetrahedron(void); +GLUTAPI void APIENTRY glutWireIcosahedron(void); +GLUTAPI void APIENTRY glutSolidIcosahedron(void); + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +/* GLUT video resize sub-API. */ +GLUTAPI int APIENTRY glutVideoResizeGet(GLenum param); +GLUTAPI void APIENTRY glutSetupVideoResizing(void); +GLUTAPI void APIENTRY glutStopVideoResizing(void); +GLUTAPI void APIENTRY glutVideoResize(int x, int y, int width, int height); +GLUTAPI void APIENTRY glutVideoPan(int x, int y, int width, int height); + +/* GLUT debugging sub-API. */ +GLUTAPI void APIENTRY glutReportErrors(void); +#endif + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +/* GLUT device control sub-API. */ +/* glutSetKeyRepeat modes. */ +#define GLUT_KEY_REPEAT_OFF 0 +#define GLUT_KEY_REPEAT_ON 1 +#define GLUT_KEY_REPEAT_DEFAULT 2 + +/* Joystick button masks. */ +#define GLUT_JOYSTICK_BUTTON_A 1 +#define GLUT_JOYSTICK_BUTTON_B 2 +#define GLUT_JOYSTICK_BUTTON_C 4 +#define GLUT_JOYSTICK_BUTTON_D 8 + +GLUTAPI void APIENTRY glutIgnoreKeyRepeat(int ignore); +GLUTAPI void APIENTRY glutSetKeyRepeat(int repeatMode); +GLUTAPI void APIENTRY glutForceJoystickFunc(void); + +/* GLUT game mode sub-API. */ +/* glutGameModeGet. */ +#define GLUT_GAME_MODE_ACTIVE ((GLenum) 0) +#define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1) +#define GLUT_GAME_MODE_WIDTH ((GLenum) 2) +#define GLUT_GAME_MODE_HEIGHT ((GLenum) 3) +#define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4) +#define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5) +#define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6) + +GLUTAPI void APIENTRY glutGameModeString(const char *string); +GLUTAPI int APIENTRY glutEnterGameMode(void); +GLUTAPI void APIENTRY glutLeaveGameMode(void); +GLUTAPI int APIENTRY glutGameModeGet(GLenum mode); +#endif + +#ifdef __cplusplus +} + +#endif + +#ifdef GLUT_APIENTRY_DEFINED +# undef GLUT_APIENTRY_DEFINED +# undef APIENTRY +#endif + +#ifdef GLUT_WINGDIAPI_DEFINED +# undef GLUT_WINGDIAPI_DEFINED +# undef WINGDIAPI +#endif + +#ifdef GLUT_DEFINED___CDECL +# undef GLUT_DEFINED___CDECL +# undef __cdecl +#endif + +#ifdef GLUT_DEFINED__CRTIMP +# undef GLUT_DEFINED__CRTIMP +# undef _CRTIMP +#endif + +#endif /* __glut_h__ */ diff --git a/matchblox/main.cpp b/matchblox/main.cpp index f2bfe54..d6cc0b4 100644 --- a/matchblox/main.cpp +++ b/matchblox/main.cpp @@ -154,7 +154,9 @@ int main(int argc, char **argv) init_gl(); MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT); - g_pEngine = new C_MatchBloxEngine("models", ""); + + GameSettings l_set = {10, 2, 2}; + g_pEngine = new C_MatchBloxEngine("models", "", l_set); glutMainLoop(); diff --git a/matchblox/matchblox.sln b/matchblox/matchblox.sln new file mode 100644 index 0000000..51a7482 --- /dev/null +++ b/matchblox/matchblox.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matchblox", "matchblox.vcproj", "{01D512E5-7754-4004-A347-E4681180D3A0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {01D512E5-7754-4004-A347-E4681180D3A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {01D512E5-7754-4004-A347-E4681180D3A0}.Debug|Win32.Build.0 = Debug|Win32 + {01D512E5-7754-4004-A347-E4681180D3A0}.Release|Win32.ActiveCfg = Release|Win32 + {01D512E5-7754-4004-A347-E4681180D3A0}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/matchblox/matchblox.vcproj b/matchblox/matchblox.vcproj index 0f7ecc0..c4cedaf 100644 --- a/matchblox/matchblox.vcproj +++ b/matchblox/matchblox.vcproj @@ -2,9 +2,9 @@ @@ -40,8 +40,8 @@ @@ -183,41 +178,57 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + + + + + + + + + + + + + diff --git a/matchblox/menu/button.c b/matchblox/menu/button.c index d452fd0..36d1b90 100644 --- a/matchblox/menu/button.c +++ b/matchblox/menu/button.c @@ -10,7 +10,7 @@ #include -#include +#include #include #include #include -- cgit v0.12