summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-05-14 11:56:32 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-05-14 11:56:32 (GMT)
commitaee762191d706d03d5e1a42bf98415466f584bda (patch)
tree6e0f14bfe36a6d57736f804802b156a979424fa4
parentd4d35970d88edccdd963e53ea3e11f702e1e2bab (diff)
download2iv55-aee762191d706d03d5e1a42bf98415466f584bda.zip
2iv55-aee762191d706d03d5e1a42bf98415466f584bda.tar.gz
2iv55-aee762191d706d03d5e1a42bf98415466f584bda.tar.bz2
moved stuff around
-rw-r--r--matchblox/C_3DObject.cpp336
-rw-r--r--matchblox/C_3DObject.h66
-rw-r--r--matchblox/C_Block.cpp71
-rw-r--r--matchblox/C_Block.h33
-rw-r--r--matchblox/C_Box.cpp111
-rw-r--r--matchblox/C_Box.h35
-rw-r--r--matchblox/C_Environment.cpp119
-rw-r--r--matchblox/C_Environment.h32
-rw-r--r--matchblox/C_Hand.cpp43
-rw-r--r--matchblox/C_Hand.h33
-rw-r--r--matchblox/C_Log.cpp24
-rw-r--r--matchblox/C_Log.h20
-rw-r--r--matchblox/C_MatchBloxEngine.cpp348
-rw-r--r--matchblox/C_MatchBloxEngine.h87
-rw-r--r--matchblox/bitmap.cpp98
-rw-r--r--matchblox/bitmap.h24
16 files changed, 0 insertions, 1480 deletions
diff --git a/matchblox/C_3DObject.cpp b/matchblox/C_3DObject.cpp
deleted file mode 100644
index 3cb00b1..0000000
--- a/matchblox/C_3DObject.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-#include <GL/glut.h>
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-#include "typedefs.h"
-#include "C_3DObject.h"
-
-#include "bitmap.h"
-
-C_3DObject::C_3DObject()
- : m_Pos(0.0, 0.0, 0.0), m_Rot(0.0, 0.0, 0.0),
- m_Scale(1.0, 1.0, 1.0),
- m_bOwnTexture(false),
- m_bDispListValid(false)
-{
- std::cout << "C_3DObject:: default constructor\n";
-}
-
-
-C_3DObject::C_3DObject(const char* f_strFileName,
- char* f_strColorTexName,
- MatProps_t f_Material)
- : m_Pos(0.0, 0.0, 0.0), m_Rot(0.0, 0.0, 0.0),
- m_Scale(1.0, 1.0, 1.0),
- m_bOwnTexture(false),
- m_bDispListValid(false),
- m_Mat(f_Material)
-{
- BitmapStruct l_bmp;
-
- //load 3d model
- m_bDispListValid = CreateObject(f_strFileName);
-
- //load textures
- if (m_bDispListValid)
- {
- if (f_strColorTexName != NULL)
- {
- std::cout << "Loading " << f_strColorTexName << std::endl;
- l_bmp = BitmapLoad(f_strColorTexName);
- m_uiColorTex = (GLuint)l_bmp.m_iImageId;
- m_bOwnTexture = true;
- }
- }
-}
-
-C_3DObject::C_3DObject(const char* f_strFileName,
- GLuint f_uiTexture,
- MatProps_t f_Material)
- : m_Pos(0.0, 0.0, 0.0), m_Rot(0.0, 0.0, 0.0),
- m_Scale(1.0, 1.0, 1.0),
- m_bOwnTexture(false),
- m_bDispListValid(false),
- m_uiColorTex(f_uiTexture),
- m_Mat(f_Material)
-{
- //load 3d model
- m_bDispListValid = CreateObject(f_strFileName);
-
-}
-
-C_3DObject::~C_3DObject()
-{
- if (glIsList(m_uiListIndex))
- glDeleteLists(m_uiListIndex, 1);
-
- if (glIsTexture(m_uiColorTex) && m_bOwnTexture)
- glDeleteTextures(1, &m_uiColorTex);
-}
-
-void C_3DObject::TransRotateScale()
-{
- glScaled(m_Scale.x, m_Scale.y, m_Scale.z);
- glTranslated(m_Pos.x, m_Pos.y, m_Pos.z);
- glRotated(m_Rot.z, 0.0, 0.0, 1.0);
- glRotated(m_Rot.x, 1.0, 0.0, 0.0);
- glRotated(m_Rot.y, 0.0, 1.0, 0.0);
-}
-
-void C_3DObject::Render()
-{
- //apply OpenGL settings for rendering this Object
- glPushAttrib(GL_TEXTURE_BIT);
- glEnable(GL_TEXTURE_2D);
- //modulate the texture color with the computed material
- //colors
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D, m_uiColorTex);
-
- //set material properties
- glMaterialfv(GL_FRONT, GL_AMBIENT, m_Mat.m_fAmb);
- glMaterialfv(GL_FRONT, GL_DIFFUSE, m_Mat.m_fDif);
- glMaterialfv(GL_FRONT, GL_SPECULAR, m_Mat.m_fSpec);
- glMaterialfv(GL_FRONT, GL_EMISSION, m_Mat.m_fEmi);
- glMaterialf(GL_FRONT, GL_SHININESS, m_Mat.m_fShin);
-
-/*
- //scale translate and rotate
- glPushMatrix();
-
- glScaled(m_Scale.x, m_Scale.y, m_Scale.z);
- glTranslated(m_Pos.x, m_Pos.y, m_Pos.z);
- glRotated(m_Rot.z, 0.0, 0.0, 1.0);
- glRotated(m_Rot.x, 1.0, 0.0, 0.0);
- glRotated(m_Rot.y, 0.0, 1.0, 0.0);
-*/
-
- //render by calling the display list
- if(m_bDispListValid)
- {
- glCallList(m_uiListIndex);
- }
- else
- {
- //or render a LARGE cube when we failed to load the
- //geometry
- glutSolidCube(10.0);
- }
-
-// glPopMatrix();
-
- glPopAttrib();
-}
-
-
-
-bool C_3DObject::CreateObject(const char *f_pFilePath)
-{
- Geometry_t l_Geom;
- bool l_bParseOk;
- Vect3D_t l_DummyVect;
-
- //the triangle indices are 1-based so we insert dummy Vect3D_t
- //to fill the 0 positions in the vertex, normals and texcoords
- //vector containers.
- l_Geom.m_verts.push_back(l_DummyVect);
- l_Geom.m_norms.push_back(l_DummyVect);
- l_Geom.m_texs.push_back(l_DummyVect);
-
- l_bParseOk = LoadGeometryData(f_pFilePath, l_Geom);
-
- //output statistics
- std::cout << "C_3DObject: file " << f_pFilePath
- << "\nParse: " << (l_bParseOk? "SUCCESS" : "FAILURE")
- << "\nVertices: " << l_Geom.m_verts.size()-1
- << "\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 << ")"
- << std::endl;
-
- if(!l_bParseOk)
- {
- std::cout << "C_3DObject Error: failed to parse file "
- << f_pFilePath << std::endl;
-
- return false;
- }
-
- //create display list
- m_uiListIndex = glGenLists(1);
- glNewList(m_uiListIndex, GL_COMPILE);
-
- glBegin(GL_TRIANGLES);
-
- //iterate through the triangles
- std::vector<Triangle_t>::iterator it = l_Geom.m_triangles.begin();
- for(; it != l_Geom.m_triangles.end(); it++)
- {
- //vertex1
- Vect3D_t v = l_Geom.m_verts[it->v1],
- t = l_Geom.m_texs[it->t1],
- n = l_Geom.m_norms[it->n1];
-
- glNormal3d(n.x, n.y, n.z);
- glTexCoord3d(t.x, t.y, t.z);
- glVertex3d(v.x, v.y, v.z);
-
- //vertex2
- v = l_Geom.m_verts[it->v2],
- t = l_Geom.m_texs[it->t2],
- n = l_Geom.m_norms[it->n2];
-
- glNormal3d(n.x, n.y, n.z);
- glTexCoord3d(t.x, t.y, t.z);
- glVertex3d(v.x, v.y, v.z);
-
- //vertex3
- v = l_Geom.m_verts[it->v3],
- t = l_Geom.m_texs[it->t3],
- n = l_Geom.m_norms[it->n3];
-
- glNormal3d(n.x, n.y, n.z);
- glTexCoord3d(t.x, t.y, t.z);
- glVertex3d(v.x, v.y, v.z);}
-
- glEnd();
-
- glEndList();
-
- return true;
-}
-
-bool C_3DObject::LoadGeometryData(const char *f_pFilePath, Geometry_t &f_Geom)
-{
- std::ifstream l_infile(f_pFilePath);
- char l_inbuffer[256];
- bool l_bParseOk = true;
- Vect3D_t l_v3;
- Triangle_t l_tri;
-
- if (l_infile.fail())
- {
- std::cout << "C_3DObject Error: could not open file "
- << f_pFilePath << std::endl;
-
- return false;
- }
-
-
- //load data
- while(!l_infile.eof() && l_bParseOk)
- {
- //read the next line
- l_infile.getline(l_inbuffer, 256);
-
- //check if reading succeeded
- if (l_infile.eof() || l_infile.fail() || l_infile.bad())
- {
- break;
- }
-
- //try to parse the first string of the line as one of the keywords:
- //v -> vertex coordinate
- //vt -> texture coordinate
- //vn -> vertex normal
- //f -> face record
- switch (l_inbuffer[0])
- {
- case 'v' :
- //posibilities 'v' 'vt' 'vn'
- switch (l_inbuffer[1])
- {
- case ' ':
- //vertex
- if (l_bParseOk = ParseVect3D(&l_inbuffer[2], l_v3))
- {
- f_Geom.m_verts.push_back(l_v3);
- //update boundingbox
- UpdBBox(m_BBox, l_v3);
- }
- break;
-
- case 't':
- if (l_inbuffer[2] == ' ')
- {
- //texture coordinates
- if (l_bParseOk = ParseVect3D(&l_inbuffer[3], l_v3))
- {
- f_Geom.m_texs.push_back(l_v3);
- }
- }
- break;
-
- case 'n':
- if (l_inbuffer[2] == ' ')
- {
- //normal
- if (l_bParseOk = ParseVect3D(&l_inbuffer[3], l_v3))
- {
- f_Geom.m_norms.push_back(l_v3);
- }
- }
- break;
- }
- break;
-
- case 'f':
- if (l_inbuffer[1] == ' ')
- {
- //face (triangle)
- if (l_bParseOk = ParseTriangle(&l_inbuffer[2], l_tri))
- {
- f_Geom.m_triangles.push_back(l_tri);
- }
- }
- break;
-
- case 'm' : // 'mtllib'?
- break;
-
- case 'u' : // 'usemtl' ?
- break;
- }
- }
-
- l_infile.close();
-
- if (!l_bParseOk)
- {
- std::cout << "Parse error in: \"" << l_inbuffer << "\"\n";
- }
-
- return l_bParseOk;
-}
-
-bool C_3DObject::ParseVect3D(const char *f_pInBuffer, Vect3D_t &f_V3)
-{
- //format: " x y z "
- std::stringstream l_inbuffer(f_pInBuffer);
-
- l_inbuffer >> std::skipws >> f_V3.x >> f_V3.y >> f_V3.z;
-
- //std::cout << "Read values: " << f_V3.x << ", " << f_V3.y << ", " << f_V3.z << "\n";
-
- return !l_inbuffer.fail();
-}
-
-bool C_3DObject::ParseTriangle(const char *f_pInBuffer, Triangle_t &f_triangle)
-{
- //format v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3
- std::stringstream l_inbuffer(f_pInBuffer);
-
- char l_slash;
-
- l_inbuffer >> std::skipws >> f_triangle.v1 >> l_slash >> f_triangle.t1 >> l_slash >> f_triangle.n1;
- l_inbuffer >> std::skipws >> f_triangle.v2 >> l_slash >> f_triangle.t2 >> l_slash >> f_triangle.n2;
- l_inbuffer >> std::skipws >> f_triangle.v3 >> l_slash >> f_triangle.t3 >> l_slash >> f_triangle.n3;
-
- return !l_inbuffer.fail();
-}
-
diff --git a/matchblox/C_3DObject.h b/matchblox/C_3DObject.h
deleted file mode 100644
index 4027596..0000000
--- a/matchblox/C_3DObject.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef C_3DOBJECT_HEADER_FILE
-
-#define C_3DOBJECT_HEADER_FILE
-
-#include <fstream>
-#include <vector>
-
-#include "typedefs.h"
-
-class C_3DObject
-{
-public:
- C_3DObject();
- C_3DObject(const char* f_strFileName,
- char* f_strColorTexName,
- MatProps_t f_Material);
- C_3DObject(const char* f_strFileName,
- GLuint f_uiTexturei,
- MatProps_t f_Material);
-
- ~C_3DObject();
-
- inline void SetPos(double f_dX, double f_dY, double f_dZ)
- { m_Pos.x = f_dX; m_Pos.y = f_dY; m_Pos.z = f_dZ; }
- inline void SetRot(double f_dX, double f_dY, double f_dZ)
- { m_Rot.x = f_dX; m_Rot.y = f_dY; m_Rot.z = f_dZ; }
- inline void SetScale(double f_dX, double f_dY, double f_dZ)
- { m_Scale.x = f_dX; m_Scale.y = f_dY; m_Scale.z = f_dZ; }
- inline void SetPos(const Vect3D_t &pos)
- { m_Pos = pos; }
- inline void SetRot(const Vect3D_t &rot)
- { m_Rot = rot; }
- inline void SetScale(const Vect3D_t &scale)
- { m_Scale = scale; }
-
- inline const Vect3D_t& GetPos() { return m_Pos; }
- 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 bool Initialized() { return m_bDispListValid; }
-
- void TransRotateScale(); //applies the scaling, translation and rotation
- //for this object
- virtual void Render(); //renders the object using the current projection
- //and modelview matrices
-
-protected:
- Vect3D_t m_Pos,
- m_Rot,
- m_Scale;
-
- BoundingBox_t m_BBox; //bounding box of the object
- GLuint m_uiListIndex; //display list index
- bool m_bDispListValid;
- GLuint m_uiColorTex;
- bool m_bOwnTexture;
- MatProps_t m_Mat;
-
- bool CreateObject(const char *f_pFilePath);
- bool LoadGeometryData(const char *f_pFilePath, Geometry_t &f_Geom);
- bool ParseVect3D(const char *f_pInbuffer, Vect3D_t &f_V3);
- bool ParseTriangle(const char *f_pInbuffer, Triangle_t &f_triangle);
-};
-
-#endif //C_3DOBJECT_HEADER_FILE
-
diff --git a/matchblox/C_Block.cpp b/matchblox/C_Block.cpp
deleted file mode 100644
index 4c092a2..0000000
--- a/matchblox/C_Block.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <GL/glut.h>
-
-#include <iostream>
-
-#include "C_Block.h"
-
-#define FADE_DURATION 500
-
-/*Durations of animations*/
-unsigned int g_BlockAnimDurations[4] = {0, 500, 500, 500};
-
-C_Block::C_Block(const char* f_strFileName,
- GLuint f_uiColorTex ,
- MatProps_t f_Mat)
-: C_3DObject(f_strFileName, f_uiColorTex, f_Mat),
- m_CurrState(BS_IDLE), m_uiAnimStart(0)
-{
-
-}
-
-C_Block::~C_Block()
-{
-
-}
-
-void C_Block::Render(unsigned int f_iElapsedTime)
-{
- unsigned int l_uiDeltaTime = f_iElapsedTime - m_uiAnimStart;
- double l_Scale = 0.0;
-
-
- //check if the previous animation has ended in between
- //calls to this Render function.
- if (l_uiDeltaTime > g_BlockAnimDurations[(int)m_CurrState])
- {
- m_CurrState = BS_IDLE;
- }
-
- glPushMatrix();
-
- switch (m_CurrState)
- {
- case BS_FADE_IN:
- l_Scale = (double)l_uiDeltaTime / (double)g_BlockAnimDurations[BS_FADE_IN];
- //glScaled(l_Scale, l_Scale, l_Scale);
- SetScale(l_Scale, l_Scale, l_Scale);
- TransRotateScale();
- C_3DObject::Render();
- break;
-
- case BS_FADE_OUT:
- l_Scale = 1.0 - ((double)l_uiDeltaTime / (double)g_BlockAnimDurations[BS_FADE_OUT]);
-// glScaled(l_Scale, l_Scale, l_Scale);
- SetScale(l_Scale, l_Scale, l_Scale);
- TransRotateScale();
- C_3DObject::Render();
- break;
-
- case BS_COLLIDE:
- break;
-
- case BS_IDLE:
- default:
- TransRotateScale();
- C_3DObject::Render();
- break;
- }
-
- glPopMatrix();
-
-}
diff --git a/matchblox/C_Block.h b/matchblox/C_Block.h
deleted file mode 100644
index f0e03b7..0000000
--- a/matchblox/C_Block.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef C_BLOCK_HEADER_FILE
-
-#define C_BLOCK_HEADER_FILE
-
-#include "C_3DObject.h"
-
-typedef enum BlockAnimState
-{
- BS_IDLE = 0,
- BS_FADE_IN = 1,
- BS_FADE_OUT = 2,
- BS_COLLIDE = 3
-};
-
-
-class C_Block : public C_3DObject
-{
-public:
- C_Block(const char* f_strFileName,
- GLuint f_uiColorTex ,
- MatProps_t f_Mat);
- ~C_Block();
-
- void Render(unsigned int f_iElapsedTime);
- inline void SetState(BlockAnimState f_State, unsigned int f_uiElapsedTime) { m_CurrState = f_State; m_uiAnimStart = f_uiElapsedTime; }
-
-private:
- BlockAnimState m_CurrState;
- unsigned int m_uiAnimStart;
-};
-
-#endif //C_BLOCK_HEADER_FILE
-
diff --git a/matchblox/C_Box.cpp b/matchblox/C_Box.cpp
deleted file mode 100644
index 9bde3ff..0000000
--- a/matchblox/C_Box.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <GL/glut.h>
-#include <math.h>
-
-#include "C_Box.h"
-#include "typedefs.h"
-
-C_Box::C_Box(const char *f_strFileName,
- GLuint f_uiTexture,
- MatProps_t f_Mat,
- int f_iTilesX, int f_iTilesY,
- C_3DObject *f_pTiles[5])
-: C_3DObject(f_strFileName, f_uiTexture, f_Mat),
- m_pTiles(f_pTiles), m_iTilesX(f_iTilesX),
- m_iTilesY(f_iTilesY)
-{
- m_iNumTiles = m_iTilesX * m_iTilesY;
- //create a new tiles layout array
- m_iTilesLayout = new int[m_iNumTiles];
-
- //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;
-
- //calculate the lower left tile position (in xz plane)
- m_LowLeftTilePos = Vect3D_t(-m_dTileSize * (double)(m_iTilesX-1)/2.0,
- 0.0,
- m_dTileSize * (double)(m_iTilesY-1)/2.0);
-}
-
-C_Box::~C_Box()
-{
- delete [] m_iTilesLayout;
-}
-
-void C_Box::RandomizeTiles()
-{
- int l_iNumTiles = m_iTilesX * m_iTilesY;
-
- //first set the layout to all tiles with no hole
- for (int i=0; i<l_iNumTiles; i++)
- m_iTilesLayout[i] = 4;
-
- //add the four hole tiles
- for (int i=0; i<4; i++)
- {
- //generate a random number in the range
- //0 - (l_iNumTiles-1)
- int pos = rand() % l_iNumTiles;
-
- //skip position in which we already inserted a hole
- //type tile (type 4)
- while (m_iTilesLayout[pos] != 4)
- pos = (pos+1) % l_iNumTiles;
-
- //insert the hole tile in the free spot
- m_iTilesLayout[pos] = i;
-
- //set the position for the hole tile relative to the box its position
- int col = pos % m_iTilesX;
- int row = pos / m_iTilesX;
-
- m_pTiles[i]->SetPos(m_LowLeftTilePos.x + (double)col * m_dTileSize,
- 0.0,
- m_LowLeftTilePos.z - (double)row * m_dTileSize);
- }
-}
-
-void C_Box::Render()
-{
- //
- glPushMatrix();
-
- //apply transformation for box
- TransRotateScale();
-
- //render the box
- C_3DObject::Render();
-
-
- //render the tiles
- for(int x=0; x<m_iTilesX; x++)
- for(int y=0; y<m_iTilesY; y++)
- {
- int l_iTileIndex = m_iTilesLayout[x + y*m_iTilesX];
- //check the tile
- if (l_iTileIndex >= 0 && l_iTileIndex <= 3)
- {
- //tile with a hole
- glPushMatrix();
- m_pTiles[l_iTileIndex]->TransRotateScale();
- m_pTiles[l_iTileIndex]->Render();
- glPopMatrix();
- }
- else
- {
- //tile without a hole
- //set the position
- m_pTiles[4]->SetPos(m_LowLeftTilePos.x + (double)x * m_dTileSize,
- 0.0,
- m_LowLeftTilePos.z - (double)y * m_dTileSize);
- glPushMatrix();
- m_pTiles[4]->TransRotateScale();
- m_pTiles[4]->Render();
- glPopMatrix();
- }
- }
-
- glPopMatrix();
-}
-
diff --git a/matchblox/C_Box.h b/matchblox/C_Box.h
deleted file mode 100644
index ed8c133..0000000
--- a/matchblox/C_Box.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef C_BOX_HEADER_FILE
-
-#define C_BOX_HEADER_FILE
-
-#include <GL/glut.h>
-#include "C_3DObject.h"
-
-class C_Box : public C_3DObject
-{
-public:
- C_Box(const char *f_strFileName,
- GLuint f_uiTexture,
- MatProps_t f_Mat,
- int f_iTilesX, int f_iTilesY,
- C_3DObject *f_pTiles[5]);
-
- ~C_Box();
-
- void RandomizeTiles();
- void Render();
-
-private:
- C_3DObject **m_pTiles; //the tile objects for the top face of the box (holes)
- int m_iTilesX, //number of tiles in x direction
- m_iTilesY, //number of tiles in y direction
- m_iNumTiles; //total number of tiles
- double m_dTileSize; //the width and height of a tile
- Vect3D_t m_LowLeftTilePos; //center position of the lower leftmost
- //tile (relative to the box its position)
-
- int *m_iTilesLayout; //the indices of the tile objects
-};
-
-#endif //C_BOX_HEADER_FILE
-
diff --git a/matchblox/C_Environment.cpp b/matchblox/C_Environment.cpp
deleted file mode 100644
index 0c7cbfd..0000000
--- a/matchblox/C_Environment.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-#include <GL/glut.h>
-#include <string>
-#include <iostream>
-
-#include "bitmap.h"
-#include "C_Environment.h"
-
-#ifndef GL_CLAMP_TO_EDGE
-#define GL_CLAMP_TO_EDGE 0x812F
-#endif //GL_CLAMP_TO_EDGE
-
-using namespace std;
-
-C_Environment::C_Environment(const char *f_strEnvMapBaseName,
- double f_dDistance)
- : m_dDist(f_dDistance)
-{
- string l_strBase = f_strEnvMapBaseName,
- l_strFilename;
- const char *l_suffix[] = { "negative_x.bmp",
- "negative_y.bmp",
- "negative_z.bmp",
- "positive_x.bmp",
- "positive_y.bmp",
- "positive_z.bmp"
- };
-
- BitmapStruct l_bmp;
-
- //load textures
- for (int i=0; i<6; i++)
- {
- l_strFilename = l_strBase + l_suffix[i];
- l_bmp = BitmapLoad((char*)l_strFilename.c_str());
- m_uiFaceTex[i] = (GLuint)l_bmp.m_iImageId;
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- }
-}
-
-C_Environment::~C_Environment()
-{
- glDeleteTextures(6, m_uiFaceTex);
-}
-
-void C_Environment::Render()
-{
- double l_Vertices[8][3] =
- { { -m_dDist, -m_dDist, m_dDist },
- { m_dDist, -m_dDist, m_dDist },
- { m_dDist, -m_dDist, -m_dDist },
- { -m_dDist, -m_dDist, -m_dDist },
- { -m_dDist, m_dDist, m_dDist },
- { m_dDist, m_dDist, m_dDist },
- { m_dDist, m_dDist, -m_dDist },
- { -m_dDist, m_dDist, -m_dDist } };
-
-
- //init render settings for rendering of the environment
- //mapped cube
-
- glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT);
-
- //no lighting
- glDisable(GL_LIGHTING);
- //enable texturing
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- //neg x (left)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[0]);
- RenderFace(l_Vertices, 3, 0, 4, 7);
-
- //neg y (down)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[1]);
- RenderFace(l_Vertices, 3, 2, 1, 0);
-
- //nez z (front)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[2]);
- RenderFace(l_Vertices, 2, 3, 7, 6);
-
- //pos x (right)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[3]);
- RenderFace(l_Vertices, 1, 2, 6, 5);
-
- //pos y (top)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[4]);
- RenderFace(l_Vertices, 4, 5, 6, 7);
-
- //pos z (back)
- glBindTexture(GL_TEXTURE_2D, m_uiFaceTex[5]);
- RenderFace(l_Vertices, 0, 1, 5, 4);
-
- glPopAttrib();
-}
-
-void C_Environment::RenderFace(double f_verts[8][3],
- int f_v00, int f_v10,
- int f_v11, int f_v01)
-{
- //render textured quad in counter clockwise order
- glBegin(GL_QUADS);
- glTexCoord2i(0,0);
- glVertex3dv(f_verts[f_v00]);
-
- glTexCoord2i(1,0);
- glVertex3dv(f_verts[f_v10]);
-
- glTexCoord2i(1,1);
- glVertex3dv(f_verts[f_v11]);
-
- glTexCoord2i(0,1);
- glVertex3dv(f_verts[f_v01]);
- glEnd();
-
-}
diff --git a/matchblox/C_Environment.h b/matchblox/C_Environment.h
deleted file mode 100644
index cfdb816..0000000
--- a/matchblox/C_Environment.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef C_ENVIRONMENT_H
-
-#define C_ENVIRONMENT_H
-
-#include <GL/glut.h>
-
-class C_Environment
-{
-public:
- //environment map consist of 6 bitmaps with a common
- //base name with the axis name (_positive_x.bmp,
- //_negative_y.bmp, ...)
- //appended, the distance is the distance from the center
- //to the sides of the cube
- C_Environment(const char *f_strEnvMapBaseName,
- double f_dDistance);
- ~C_Environment();
-
- void Render();
- void RenderFace(double f_verts[8][3],
- int f_v00, int f_v10,
- int f_v11, int f_v01);
-
-private:
- double m_dDist;
-
- //texture handles for the faces of the cube
- GLuint m_uiFaceTex[6]; //order -x, -y, -z, +x, +y, +z
-};
-
-#endif //C_ENVIRONMENT_H
-
diff --git a/matchblox/C_Hand.cpp b/matchblox/C_Hand.cpp
deleted file mode 100644
index 8c4d977..0000000
--- a/matchblox/C_Hand.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <GL/glut.h>
-#include "C_Hand.h"
-
-#define FADE_DURATION 500
-
-//duration of animations in ms
-unsigned int g_HandAnimDurations[3] = {0, 100, 100};
-
-
-C_Hand::C_Hand(const char* f_strFileName, GLuint f_uiTex,
- MatProps_t f_Mat)
-: C_3DObject(f_strFileName, f_uiTex, f_Mat),
- m_CurrState(HS_IDLE), m_uiAnimStart(0)
-{
-}
-
-
-void C_Hand::Render(unsigned int f_iElapsedTime)
-{
- unsigned int l_uiDeltaTime = f_iElapsedTime - m_uiAnimStart;
-
- if (l_uiDeltaTime > g_HandAnimDurations[(int)m_CurrState])
- {
- m_CurrState = HS_IDLE;
- }
-
- switch (m_CurrState)
- {
- case HS_GRAB:
- C_3DObject::Render();
- break;
-
- case HS_RELEASE:
- C_3DObject::Render();
- break;
-
- case HS_IDLE:
- default:
- C_3DObject::Render();
- break;
- }
-
-}
diff --git a/matchblox/C_Hand.h b/matchblox/C_Hand.h
deleted file mode 100644
index 3ada63d..0000000
--- a/matchblox/C_Hand.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef C_HAND_HEADER_FILE
-
-#define C_HAND_HEADER_FILE
-
-#include "C_3DObject.h"
-#include "typedefs.h"
-
-typedef enum HandAnimState
-{
- HS_IDLE = 0,
- HS_GRAB = 1,
- HS_RELEASE = 2,
- HS_COLLIDE = 3
-};
-
-
-class C_Hand : public C_3DObject
-{
-public:
- C_Hand(const char* f_strFileName, GLuint f_uiTex,
- MatProps_t f_Mat);
- ~C_Hand();
-
- void Render(unsigned int f_iElapsedTime);
- inline void SetState(HandAnimState f_State, unsigned int f_uiElapsedTime) { m_CurrState = f_State; m_uiAnimStart = f_uiElapsedTime; }
-
-private:
- HandAnimState m_CurrState;
- unsigned int m_uiAnimStart;
-};
-
-#endif //C_HAND_HEADER_FILE
-
diff --git a/matchblox/C_Log.cpp b/matchblox/C_Log.cpp
deleted file mode 100644
index d9a1154..0000000
--- a/matchblox/C_Log.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "C_Log.h"
-
-C_Log::C_Log(char *f_strFileName)
-{
-}
-
-C_Log::~C_Log()
-{
-}
-
-bool C_Log::LogNewSession(int f_iUserID, int f_iGameID)
-{
- return true;
-}
-
-bool C_Log::LogSessionTurn(int f_iUserID, int f_iGameID, int f_iBlockNr, int HolePos, unsigned int f_uiTime)
-{
- return true;
-}
-
-bool C_Log::LogSessionTotals(int f_iUserID, int f_iGameID, unsigned int f_uiTotalTime)
-{
- return true;
-}
diff --git a/matchblox/C_Log.h b/matchblox/C_Log.h
deleted file mode 100644
index 2b598dd..0000000
--- a/matchblox/C_Log.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef C_LOG_HEADER_FILE
-
-#define C_LOG_HEADER_FILE
-
-class C_Log
-{
-public:
- C_Log(char *f_strFileName);
- ~C_Log();
-
- bool LogNewSession(int f_iUserID, int f_iGameID);
- bool LogSessionTurn(int f_iUserID, int f_iGameID, int f_iBlockNr, int HolePos, unsigned int f_uiTime);
- bool LogSessionTotals(int f_iUserID, int f_iGameID, unsigned int f_uiTotalTime);
-
-private:
-// FILE *m_pLogFile;
-};
-
-#endif //C_LOG_HEADER_FILE
-
diff --git a/matchblox/C_MatchBloxEngine.cpp b/matchblox/C_MatchBloxEngine.cpp
deleted file mode 100644
index 7e17b1b..0000000
--- a/matchblox/C_MatchBloxEngine.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-#include <GL/glut.h>
-
-#include <time.h>
-#include <string>
-#include <iostream>
-
-#include "C_MatchBloxEngine.h"
-
-#include "C_3DObject.h"
-#include "C_Environment.h"
-#include "C_Hand.h"
-#include "C_Block.h"
-#include "C_Box.h"
-#include "C_Log.h"
-#include "bitmap.h"
-
-C_MatchBloxEngine::C_MatchBloxEngine(const char *f_strModelPath,
- const char *f_strLogFile)
-{
- //create logger
-
-
- //Load models
- if (LoadModels(f_strModelPath))
- {
- //set state to initialised;
- m_State = ES_INITIALISED;
- }
- else
- {
- m_State = ES_ERROR;
- }
-
- //initialise a random seed
- srand ( time(NULL) );
-
- //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);
-}
-
-C_MatchBloxEngine::~C_MatchBloxEngine()
-{
- //destroy logger
-
- //delete models
- DeleteModels();
-}
-
-GameResult C_MatchBloxEngine::GameStep(msgQueue &f_Queue)
-{
- //process message queue
- return GR_ERROR;
-}
-
-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);
-}
-
-void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime)
-{
- switch (m_State)
- {
- case ES_INITIALISED:
- Render_Basics(f_uiElapsedTime);
- break;
-
- case ES_ERROR:
- //render a red cube
- glPushMatrix();
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_LIGHTING);
- glColor3d(1.0, 0.0, 0.0);
- glTranslated(0.0, 0.0, -5.0);
- glutSolidCube(5.0);
- glPopAttrib();
- glPopMatrix();
- break;
-
- case ES_GET_READY:
- Render_Basics(f_uiElapsedTime);
- //render some GET READY text
- break;
-
- case ES_PLAYING_GRAB_BLOCK:
- Render_Basics(f_uiElapsedTime);
- break;
-
- case ES_PLAYING_PUT_BLOCK:
- Render_Basics(f_uiElapsedTime);
- break;
-
- case ES_PAUSED:
- Render_Basics(f_uiElapsedTime);
- //render menu??
- break;
-
- case ES_FINISHED:
- //render results...
- break;
- }
-
- //glPushMatrix();
-
- //double l_dSeconds = (double)f_uiElapsedTime/1000.0;
-
- //glRotated(l_dSeconds * 5.0, 0.0, 1.0, 0.0);
- ////glRotated(l_dSeconds * 10, 0.0, 0.0, 1.0);
-
- //m_pEnvMap->Render();
-
- //glPopMatrix();
-
- //m_pBox[0]->Render();
-
- //for(int i=0; i<4; i++)
- //{
- // glPushMatrix();
- // m_pBlock[i]->Render(f_uiElapsedTime);
- // glPopMatrix();
- //}
-
-}
-
-bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS)
-{
- if(m_State == ES_INITIALISED)
- {
- //log new game
-
- //prepare a fresh box
- m_CurrentBox = f_BS;
- m_pBox[(int)m_CurrentBox]->RandomizeTiles();
-
- //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;
- }
-
- return false;
-}
-
-bool C_MatchBloxEngine::StartGame()
-{
- return false;
-}
-
-bool C_MatchBloxEngine::Pause()
-{
- //only pause when playing
- if (m_State == ES_PLAYING_GRAB_BLOCK ||
- m_State == ES_PLAYING_PUT_BLOCK)
- {
- //save current state
- m_SavedState = m_State;
-
- //probably do something with a time variable
-
- //set current state to paused
- m_State = ES_PAUSED;
-
- return true;
- }
-
- return false;
-}
-
-bool C_MatchBloxEngine::Resume()
-{
- if (m_State == ES_PAUSED)
- {
- //restore previous state
- m_State = m_SavedState;
-
- //restore timers
- //
-
- return true;
- }
- return false;
-}
-
-bool C_MatchBloxEngine::Abort()
-{
- //abort when not in error or init state
- if (m_State != ES_ERROR && m_State != ES_INITIALISED)
- {
- //set state to initialised
- m_State = ES_INITIALISED;
-
- //..
-
- return true;
- }
- return false;
-}
-
-bool C_MatchBloxEngine::LoadModels(const char* f_strModelDir)
-{
- MatProps_t l_Mat;
- std::string l_BaseName = f_strModelDir;
-
- //create the environment mapped cube
- m_pEnvMap = new C_Environment("envmaps/terrain_", 50.0);
-
- //load the bitmaps for the textures
- LoadTexture((l_BaseName + "/wood1.bmp").c_str(), m_uiWood1Tex);
- LoadTexture((l_BaseName + "/wood2.bmp").c_str(), m_uiWood2Tex);
- LoadTexture((l_BaseName + "/wood3.bmp").c_str(), m_uiWood3Tex);
-
- //load the block models
- //red squares
- l_Mat.setAmb(1.0, 0.0, 0.0, 1.0);
- l_Mat.setDif(1.0, 0.0, 0.0, 1.0);
- m_pBlock[BT_SQUARE] = new C_Block((l_BaseName + "/square.obj").c_str(),
- m_uiWood1Tex, l_Mat);
- if (!m_pBlock[BT_SQUARE]->Initialized()) return false;
-
- //yellow cricles
- l_Mat.setAmb(0.0, 1.0, 1.0, 1.0);
- l_Mat.setDif(0.0, 1.0, 1.0, 1.0);
- m_pBlock[BT_CIRCLE] = new C_Block((l_BaseName + "/circle.obj").c_str(),
- m_uiWood1Tex, l_Mat);
- if (!m_pBlock[BT_CIRCLE]->Initialized()) return false;
-
- //green triangles
- l_Mat.setAmb(0.0, 1.0, 0.0, 1.0);
- l_Mat.setDif(0.0, 1.0, 0.0, 1.0);
- m_pBlock[BT_TRIANGLE] = new C_Block((l_BaseName + "/triangle.obj").c_str(),
- m_uiWood1Tex, l_Mat);
- if (!m_pBlock[BT_TRIANGLE]->Initialized()) return false;
-
- //blue crosses
- l_Mat.setAmb(0.0, 0.0, 1.0, 1.0);
- l_Mat.setDif(0.0, 0.0, 1.0, 1.0);
- m_pBlock[BT_CROSS] = new C_Block((l_BaseName + "/cross.obj").c_str(),
- m_uiWood1Tex, l_Mat);
- if (!m_pBlock[BT_CROSS]->Initialized()) return false;
-
-
- //load the hand???
-
-
- //Load the box tiles
- l_Mat.setAmb(1.0, 1.0, 1.0, 1.0);
- l_Mat.setDif(1.0, 1.0, 1.0, 1.0);
-
- m_pTiles[BT_SQUARE] = new C_3DObject((l_BaseName + "/tile_square.obj").c_str(),
- m_uiWood3Tex, l_Mat);
- if (!m_pTiles[BT_SQUARE]->Initialized()) return false;
-
- m_pTiles[BT_CIRCLE] = new C_3DObject((l_BaseName + "/tile_circle.obj").c_str(),
- m_uiWood3Tex, l_Mat);
- if (!m_pTiles[BT_CIRCLE]->Initialized()) return false;
-
- m_pTiles[BT_TRIANGLE] = new C_3DObject((l_BaseName + "/tile_triangle.obj").c_str(),
- m_uiWood3Tex, l_Mat);
- if (!m_pTiles[BT_TRIANGLE]->Initialized()) return false;
-
- m_pTiles[BT_CROSS] = new C_3DObject((l_BaseName + "/tile_cross.obj").c_str(),
- m_uiWood3Tex, l_Mat);
- if (!m_pTiles[BT_CROSS]->Initialized()) return false;
-
- m_pTiles[4] = new C_3DObject((l_BaseName + "/tile_no_hole.obj").c_str(),
- m_uiWood3Tex, l_Mat);
- if (!m_pTiles[4]->Initialized()) return false;
-
-
- //Load the box models
- m_pBox[0] = new C_Box((l_BaseName + "/box_small.obj").c_str(),
- m_uiWood2Tex, l_Mat, 2, 2, m_pTiles);
- if (!m_pBox[0]->Initialized()) return false;
-
- m_pBox[1] = new C_Box((l_BaseName + "/box_med.obj").c_str(),
- m_uiWood2Tex, l_Mat, 4, 2, m_pTiles);
- if (!m_pBox[1]->Initialized()) return false;
-
- m_pBox[2] = new C_Box((l_BaseName + "/box_large.obj").c_str(),
- m_uiWood2Tex, l_Mat, 4, 4, m_pTiles);
- if (!m_pBox[2]->Initialized()) return false;
-
-
- return true;
-}
-
-void C_MatchBloxEngine::DeleteModels()
-{
- //delete objects
- delete m_pEnvMap;
- delete m_pBlock[0];
- delete m_pBlock[1];
- delete m_pBlock[2];
- delete m_pBlock[3];
- //delete m_pHand;
- delete m_pBox[0];
- delete m_pBox[1];
- delete m_pBox[2];
- delete m_pTiles[0];
- delete m_pTiles[1];
- delete m_pTiles[2];
- delete m_pTiles[3];
- delete m_pTiles[4];
-
- //delete textures
- glDeleteTextures(1, &m_uiWood1Tex);
- glDeleteTextures(1, &m_uiWood2Tex);
- glDeleteTextures(1, &m_uiWood3Tex);
-}
-
-void C_MatchBloxEngine::LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle)
-{
- BitmapStruct l_Bmp;
-
- l_Bmp = BitmapLoad((char*)f_BmpName);
- f_uiTexHandle = (GLuint)l_Bmp.m_iImageId;
-
- glBindTexture(GL_TEXTURE_2D, f_uiTexHandle);
-
- //set the texture paramaters
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-}
-
diff --git a/matchblox/C_MatchBloxEngine.h b/matchblox/C_MatchBloxEngine.h
deleted file mode 100644
index 97aa892..0000000
--- a/matchblox/C_MatchBloxEngine.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef C_MATCHBLOXENGINE_HEADER_FILE
-
-#define C_MATCHBLOXENGINE_HEADER_FILE
-
-#include "MessageQueue.h"
-
-class C_3DObject;
-class C_Block;
-class C_Hand;
-class C_Log;
-class C_Environment;
-class C_Box;
-
-typedef enum GameResult
-{
- GR_FINISHED,
- GR_BUSY,
- GR_ERROR
-} GameResult;
-
-enum EngineState
-{
- ES_INITIALISED,
- ES_ERROR,
- ES_GET_READY, //game initialised, waiting for start signal from player
- ES_PLAYING_GRAB_BLOCK, //no block in hand -> grab floating block
- ES_PLAYING_PUT_BLOCK, //block in hand -> put block in box
- ES_PAUSED, //pause...
- ES_FINISHED //finished -> show score and goto init
-};
-
-enum BlockType
-{
- BT_SQUARE = 0,
- BT_CIRCLE = 1,
- BT_TRIANGLE = 2,
- BT_CROSS = 3
-};
-
-enum BoxSize
-{
- BS_SMALL = 0,
- BS_MED = 1,
- BS_LARGE = 2
-};
-
-
-class C_MatchBloxEngine
-{
-public:
- C_MatchBloxEngine(const char *f_strModelPath,
- const char *f_strLogFile);
- ~C_MatchBloxEngine();
-
- GameResult GameStep(msgQueue &f_Queue);
- void Render(unsigned int f_uiElapsedTime);
-
- bool NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS);
- bool StartGame();
- bool Pause();
- bool Resume();
- bool Abort();
-
-private:
- C_Environment *m_pEnvMap;
- C_Block *m_pBlock[4];
- C_Hand *m_pHand;
- C_3DObject *m_pTiles[5];
- C_Box *m_pBox[3];
- C_Log *m_pLog;
-
- GLuint m_uiWood1Tex,
- m_uiWood2Tex,
- m_uiWood3Tex;
-
- EngineState m_State, m_SavedState;
- BoxSize m_CurrentBox;
-
- void Render_Basics(unsigned int f_uiElapsedTime);
-
- bool LoadModels(const char* f_strModelDir);
- void DeleteModels();
- void LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle);
-};
-
-#endif //C_MATCHBLOXENGINE_HEADER_FILE
-
diff --git a/matchblox/bitmap.cpp b/matchblox/bitmap.cpp
deleted file mode 100644
index 243952a..0000000
--- a/matchblox/bitmap.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifdef G_OS_WIN32
- #define WIN32_LEAN_AND_MEAN 1
- #include <windows.h>
- #define GL_BGR 0x80E0
- #define GL_BGRA 0x80E1
-#endif
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "bitmap.h"
-
-#define BITMAP_FILESIZE 0x02
-#define BITMAP_OFFSET 0x0a
-#define BITMAP_HEADERSIZE 0x0e
-#define BITMAP_WIDTH 0x12
-#define BITMAP_HEIGHT 0x16
-#define BITMAP_DEPTH 0x1c
-#define BITMAP_IMAGE_SIZE 0x22
-
-
-struct BitmapStruct BitmapLoad(char *filename)
-{
- struct BitmapStruct l_sImage;
- GLuint texture;
- FILE *bitmap;
-
- // try to open the file
- bitmap = fopen(filename, "r");
-
- // does the bitmap exist?
- if (bitmap > 0)
- {
- unsigned int dataoffset, filesize, imagesize;
- short depth;
- GLsizei width, height;
- unsigned char *imagedata;
-
- fseek(bitmap, BITMAP_FILESIZE, SEEK_SET);
- fread(&filesize, 4, 1, bitmap);
- fseek(bitmap, BITMAP_OFFSET, SEEK_SET);
- fread(&dataoffset, 4, 1, bitmap);
- fseek(bitmap, BITMAP_WIDTH, SEEK_SET);
- fread(&width, 4, 1, bitmap);
- fread(&height, 4, 1, bitmap);
- fseek(bitmap, BITMAP_DEPTH, SEEK_SET);
- fread(&depth, 2, 1, bitmap);
- fseek(bitmap, BITMAP_IMAGE_SIZE, SEEK_SET);
- fread(&imagesize, 4, 1, bitmap);
-
- imagedata = (unsigned char *)malloc((size_t)imagesize);
-
- fseek(bitmap, dataoffset, SEEK_SET);
- fread(imagedata, (size_t)imagesize, 1, bitmap);
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
-
- if (depth == 24) // 24 bits
- {
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_BGR, GL_UNSIGNED_BYTE, imagedata);
- }
- else // depth == 32 bits
- {
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, imagedata);;
- }
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- l_sImage.m_iImageId = texture;
- l_sImage.m_iWidth = width;
- l_sImage.m_iHeight = height;
-
- free(imagedata);
- fclose(bitmap);
-
- return l_sImage;
- }
- else
- {
- // couldn't find bitmap
- exit(0);
- }
-}
-
-
-
-void BitmapConvertWidth(struct BitmapStruct *f_sImage, double f_dHeight)
-{
- double l_dRatio;
-
- l_dRatio = (double)f_sImage->m_iHeight / f_dHeight;
- f_sImage->m_iWidth = (int)(f_sImage->m_iWidth / l_dRatio);
-
-} // ConvertButton
diff --git a/matchblox/bitmap.h b/matchblox/bitmap.h
deleted file mode 100644
index 5aa9be6..0000000
--- a/matchblox/bitmap.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _CBITMAP_H
-#define _CBITMAP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct BitmapStruct {
- int m_iImageId;
- int m_iWidth;
- int m_iHeight;
-};
-
-struct BitmapStruct BitmapLoad(char *filename);
-void BitmapRender(int f_iXPos, int f_iYPos, int f_iWidth, int f_iHeight, int f_iImageId);
-void BitmapConvertWidth(struct BitmapStruct *f_sImage, double f_dHeight);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif