Converted lots of code to using glVertexPointer instead of glVertex2f
git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@452 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
e9e8417d51
commit
bf115c2378
|
@ -236,10 +236,6 @@ void CCourse::MakeCourseNormals () {
|
|||
void CCourse::FillGlArrays() {
|
||||
TVector3 *normals = nmls;
|
||||
|
||||
glDisableClientState (GL_VERTEX_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
|
||||
if (vnc_array == NULL)
|
||||
vnc_array = new GLubyte[STRIDE_GL_ARRAY * nx * ny];
|
||||
|
||||
|
@ -263,17 +259,6 @@ void CCourse::FillGlArrays() {
|
|||
BYTEVAL(3) = 255;
|
||||
}
|
||||
}
|
||||
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (3, GL_FLOAT, STRIDE_GL_ARRAY, vnc_array);
|
||||
|
||||
glEnableClientState (GL_NORMAL_ARRAY);
|
||||
glNormalPointer (GL_FLOAT, STRIDE_GL_ARRAY,
|
||||
vnc_array + 4*sizeof(GLfloat));
|
||||
|
||||
glEnableClientState (GL_COLOR_ARRAY);
|
||||
glColorPointer (4, GL_UNSIGNED_BYTE, STRIDE_GL_ARRAY,
|
||||
vnc_array + 8*sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void CCourse::MakeStandardPolyhedrons () {
|
||||
|
|
|
@ -132,17 +132,28 @@ static void DrawBackLogo (int x, int y, double size) {
|
|||
else left = (Winsys.resolution.width - width) / 2;
|
||||
right = left + width;
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 0.4);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (left, bott);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (right, bott);
|
||||
glTexCoord2f (1, 1);
|
||||
glVertex2f (right, top);
|
||||
glTexCoord2f (0, 1);
|
||||
glVertex2f (left, top);
|
||||
glEnd();
|
||||
glColor4f(1.0, 1.0, 1.0, 0.4);
|
||||
const GLfloat tex [] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
left, bott,
|
||||
right, bott,
|
||||
right, top,
|
||||
left, top
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void CCredits::Keyb (unsigned int key, bool special, bool release, int x, int y) {
|
||||
|
|
|
@ -557,19 +557,27 @@ const FTPoint& FTTextureGlyph::Render (const FTPoint& pen) {
|
|||
|
||||
glTranslatef (pen.X(), pen.Y(), 0.0f);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (uv[0].X(), uv[0].Y());
|
||||
glVertex2f (pos.X(), pos.Y());
|
||||
const GLfloat tex [] = {
|
||||
uv[0].X(), uv[0].Y(),
|
||||
uv[0].X(), uv[1].Y(),
|
||||
uv[1].X(), uv[1].Y(),
|
||||
uv[1].X(), uv[0].Y(),
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
pos.X(), pos.Y(),
|
||||
pos.X(), pos.Y() - destHeight,
|
||||
destWidth + pos.X(), pos.Y() - destHeight,
|
||||
destWidth + pos.X(), pos.Y()
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glTexCoord2f (uv[0].X(), uv[1].Y());
|
||||
glVertex2f (pos.X(), pos.Y() - destHeight);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glTexCoord2f (uv[1].X(), uv[1].Y());
|
||||
glVertex2f (destWidth + pos.X(), pos.Y() - destHeight);
|
||||
|
||||
glTexCoord2f (uv[1].X(), uv[0].Y());
|
||||
glVertex2f (destWidth + pos.X(), pos.Y());
|
||||
glEnd();
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
return advance;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,36 +61,6 @@ void CGameOver::Mouse (int button, int state, int x, int y) {
|
|||
QuitGameOver ();
|
||||
}
|
||||
|
||||
void DrawMessageFrame (float x, float y, float w, float h, int line,
|
||||
TColor backcol, TColor framecol, float transp) {
|
||||
|
||||
float yy = Winsys.resolution.height - y - h;
|
||||
if (x < 0) x = (Winsys.resolution.width - w) / 2;
|
||||
|
||||
glPushMatrix();
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
|
||||
glColor4f (framecol.r, framecol.g, framecol.b, transp);
|
||||
glTranslatef (x, yy, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0, 0);
|
||||
glVertex2f (w, 0);
|
||||
glVertex2f (w, h);
|
||||
glVertex2f (0, h);
|
||||
glEnd();
|
||||
|
||||
glColor4f (backcol.r, backcol.g, backcol.b, transp);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0 + line, 0 + line);
|
||||
glVertex2f (w - line, 0 + line);
|
||||
glVertex2f (w - line, h - line);
|
||||
glVertex2f (0 + line, h - line);
|
||||
glEnd();
|
||||
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
void GameOverMessage (const CControl *ctrl) {
|
||||
int fwidth = 500;
|
||||
|
@ -104,11 +74,11 @@ void GameOverMessage (const CControl *ctrl) {
|
|||
if (param.use_papercut_font > 0) FT.SetSize (28);
|
||||
else FT.SetSize (22);
|
||||
if (g_game.raceaborted) {
|
||||
DrawMessageFrame (leftframe, topframe, fwidth, 100, 4, backcol, framecol, 0.5);
|
||||
DrawFrameX (leftframe, topframe, fwidth, 100, 4, backcol, framecol, 0.5);
|
||||
FT.SetColor (colDBlue);
|
||||
FT.DrawString (CENTER, topframe+30, Trans.Text(25));
|
||||
} else {
|
||||
DrawMessageFrame (leftframe, topframe, fwidth, 210, 4, backcol, framecol, 0.5);
|
||||
DrawFrameX(leftframe, topframe, fwidth, 210, 4, backcol, framecol, 0.5);
|
||||
|
||||
if (param.use_papercut_font > 0) FT.SetSize (20);
|
||||
else FT.SetSize (14);
|
||||
|
|
257
src/gui.cpp
257
src/gui.cpp
|
@ -121,12 +121,16 @@ void TTextField::Draw() const {
|
|||
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glColor4f (colYellow.r, colYellow.g, colYellow.b, colYellow.a);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (x, scrheight-mouseRect.top-h-9);
|
||||
glVertex2f (x+w, scrheight-mouseRect.top-h-9);
|
||||
glVertex2f (x+w, scrheight-mouseRect.top-9);
|
||||
glVertex2f (x, scrheight-mouseRect.top-9);
|
||||
glEnd();
|
||||
const GLfloat vtx [] = {
|
||||
x, scrheight - mouseRect.top - h - 9,
|
||||
x + w, scrheight - mouseRect.top - h - 9,
|
||||
x + w, scrheight - mouseRect.top - 9,
|
||||
x, scrheight - mouseRect.top - 9
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
@ -241,50 +245,44 @@ void TIconButton::Draw () const {
|
|||
texture->Bind();
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
switch (value) {
|
||||
case 0:
|
||||
glTexCoord2f (0, 0.5);
|
||||
glVertex2f (x,y);
|
||||
glTexCoord2f (0.5, 0.5);
|
||||
glVertex2f (r,y);
|
||||
glTexCoord2f (0.5, 1.0);
|
||||
glVertex2f (r,t);
|
||||
glTexCoord2f (0, 1.0);
|
||||
glVertex2f (x,t);
|
||||
break;
|
||||
case 1:
|
||||
glTexCoord2f (0.5, 0.5);
|
||||
glVertex2f (x,y);
|
||||
glTexCoord2f (1.0, 0.5);
|
||||
glVertex2f (r,y);
|
||||
glTexCoord2f (1.0, 1.0);
|
||||
glVertex2f (r,t);
|
||||
glTexCoord2f (0.5, 1.0);
|
||||
glVertex2f (x,t);
|
||||
break;
|
||||
case 2:
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (x,y);
|
||||
glTexCoord2f (0.5, 0);
|
||||
glVertex2f (r,y);
|
||||
glTexCoord2f (0.5, 0.5);
|
||||
glVertex2f (r,t);
|
||||
glTexCoord2f (0, 0.5);
|
||||
glVertex2f (x,t);
|
||||
break;
|
||||
case 3:
|
||||
glTexCoord2f (0.5, 0);
|
||||
glVertex2f (x,y);
|
||||
glTexCoord2f (1.0, 0);
|
||||
glVertex2f (r,y);
|
||||
glTexCoord2f (1.0, 0.5);
|
||||
glVertex2f (r,t);
|
||||
glTexCoord2f (0.5, 0.5);
|
||||
glVertex2f (x,t);
|
||||
break;
|
||||
}
|
||||
glEnd ();
|
||||
const GLfloat vtx[] = {
|
||||
x, y,
|
||||
r, y,
|
||||
r, t,
|
||||
x, t
|
||||
};
|
||||
static const GLfloat tex[4][8] = {
|
||||
{
|
||||
0, 0.5,
|
||||
0.5, 0.5,
|
||||
0.5, 1,
|
||||
0, 1
|
||||
}, {
|
||||
0.5, 0.5,
|
||||
1, 0.5,
|
||||
1, 1,
|
||||
0.5, 1
|
||||
}, {
|
||||
0, 0,
|
||||
0.5, 0,
|
||||
0.5, 0.5,
|
||||
0, 0.5
|
||||
}, {
|
||||
0.5, 0,
|
||||
1, 0,
|
||||
1, 0.5,
|
||||
0.5, 0.5
|
||||
}
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex[value]);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
bool TIconButton::Click(int x, int y) {
|
||||
|
@ -346,16 +344,27 @@ void TArrow::Draw() const {
|
|||
Tex.BindTex (LB_ARROWS);
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f (texleft, texbottom);
|
||||
glVertex2f (bl.x, bl.y);
|
||||
glTexCoord2f (texright, texbottom);
|
||||
glVertex2f (tr.x, bl.y);
|
||||
glTexCoord2f (texright, textop);
|
||||
glVertex2f (tr.x, tr.y);
|
||||
glTexCoord2f (texleft, textop);
|
||||
glVertex2f (bl.x, tr.y);
|
||||
glEnd();
|
||||
const GLfloat tex [] = {
|
||||
texleft, texbottom,
|
||||
texright, texbottom,
|
||||
texright, textop,
|
||||
texleft, textop
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
bl.x, bl.y,
|
||||
tr.x, bl.y,
|
||||
tr.x, tr.y,
|
||||
bl.x, tr.y
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
TArrow* AddArrow(int x, int y, bool down) {
|
||||
|
@ -449,31 +458,36 @@ TUpDown* AddUpDown(int x, int y, int minimum, int maximum, int value, int distan
|
|||
|
||||
// ------------------ Elementary drawing ---------------------------------------------
|
||||
|
||||
void DrawFrameX (int x, int y, int w, int h, int line,
|
||||
const TColor& backcol, const TColor& framecol, double transp) {
|
||||
void DrawFrameX (int x, int y, int w, int h, int line, const TColor& backcol, const TColor& framecol, double transp) {
|
||||
double yy = Winsys.resolution.height - y - h;
|
||||
|
||||
if (x < 0) x = (Winsys.resolution.width -w) / 2;
|
||||
|
||||
glPushMatrix();
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glColor4f (framecol.r, framecol.g, framecol.b, transp);
|
||||
glTranslatef (x, yy, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0, 0);
|
||||
glVertex2f (w, 0);
|
||||
glVertex2f (w, h);
|
||||
glVertex2f (0, h);
|
||||
glEnd();
|
||||
glTranslatef(x, yy, 0);
|
||||
const GLfloat frame [] = {
|
||||
0, 0,
|
||||
w, 0,
|
||||
w, h,
|
||||
0, h
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, frame);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glColor4f (backcol.r, backcol.g, backcol.b, transp);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0 + line, 0 + line);
|
||||
glVertex2f (w - line, 0 + line);
|
||||
glVertex2f (w - line, h - line);
|
||||
glVertex2f (0 + line, h - line);
|
||||
glEnd();
|
||||
const GLfloat back [] = {
|
||||
0 + line, 0 + line,
|
||||
w - line, 0 + line,
|
||||
w - line, h - line,
|
||||
0 + line, h - line
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, back);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -495,48 +509,27 @@ void DrawLevel (int x, int y, int level, double fact) {
|
|||
Tex.BindTex (STARS);
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f (0, bott);
|
||||
glVertex2f (bl.x, bl.y);
|
||||
glTexCoord2f (0.75, bott);
|
||||
glVertex2f (tr.x, bl.y);
|
||||
glTexCoord2f (0.75, top);
|
||||
glVertex2f (tr.x, tr.y);
|
||||
glTexCoord2f (0, top);
|
||||
glVertex2f (bl.x, tr.y);
|
||||
glEnd();
|
||||
}
|
||||
const GLfloat tex [] = {
|
||||
0, bott,
|
||||
0.75, bott,
|
||||
0.75, top,
|
||||
0, top
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
bl.x, bl.y,
|
||||
tr.x, bl.y,
|
||||
tr.x, tr.y,
|
||||
bl.x, tr.y
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
void DrawBonus (int x, int y, size_t max, size_t num) {
|
||||
TVector2 bl, tr;
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
bl.y = Winsys.resolution.height - y - 32;
|
||||
tr.y = Winsys.resolution.height - y;
|
||||
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
Tex.BindTex (TUXBONUS);
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
for (size_t i=0; i<max; i++) {
|
||||
bl.x = x + i * 40;
|
||||
tr.x = bl.x + 32;
|
||||
|
||||
double bott = 0.0;
|
||||
if (i<num) bott = 0.5;
|
||||
double top = bott + 0.5;
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f (0, bott);
|
||||
glVertex2f (bl.x, bl.y);
|
||||
glTexCoord2f (1, bott);
|
||||
glVertex2f (tr.x, bl.y);
|
||||
glTexCoord2f (1, top);
|
||||
glVertex2f (tr.x, tr.y);
|
||||
glTexCoord2f (0, top);
|
||||
glVertex2f (bl.x, tr.y);
|
||||
glEnd();
|
||||
}
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void DrawBonusExt (int y, size_t numraces, size_t num) {
|
||||
|
@ -572,6 +565,8 @@ void DrawBonusExt (int y, size_t numraces, size_t num) {
|
|||
Tex.BindTex (TUXBONUS);
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
for (size_t i=0; i<maxtux; i++) {
|
||||
size_t majr = (i/numraces);
|
||||
size_t minr = i - majr * numraces;
|
||||
|
@ -585,18 +580,26 @@ void DrawBonusExt (int y, size_t numraces, size_t num) {
|
|||
if (i<num) {
|
||||
double bott = 0.5;
|
||||
double top = 1.0;
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, bott);
|
||||
glVertex2f (bl.x, bl.y);
|
||||
glTexCoord2f (1, bott);
|
||||
glVertex2f (tr.x, bl.y);
|
||||
glTexCoord2f (1, top);
|
||||
glVertex2f (tr.x, tr.y);
|
||||
glTexCoord2f (0, top);
|
||||
glVertex2f (bl.x, tr.y);
|
||||
glEnd();
|
||||
|
||||
const GLfloat tex [] = {
|
||||
0, bott,
|
||||
1, bott,
|
||||
1, top,
|
||||
0, top
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
bl.x, bl.y,
|
||||
tr.x, bl.y,
|
||||
tr.x, tr.y,
|
||||
bl.x, tr.y
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
}
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void DrawCursor () {
|
||||
|
|
|
@ -159,7 +159,6 @@ void ResetGUI();
|
|||
void DrawFrameX (int x, int y, int w, int h, int line,
|
||||
const TColor& backcol, const TColor& framecol, double transp);
|
||||
void DrawLevel (int x, int y, int level, double fact);
|
||||
void DrawBonus (int x, int y, size_t max, size_t num);
|
||||
void DrawBonusExt (int y, size_t numraces, size_t num);
|
||||
void DrawCursor ();
|
||||
|
||||
|
|
137
src/hud.cpp
137
src/hud.cpp
|
@ -168,21 +168,29 @@ void draw_gauge (double speed, double energy) {
|
|||
Tex.BindTex (GAUGE_ENERGY);
|
||||
double y = ENERGY_GAUGE_BOTTOM + energy * ENERGY_GAUGE_HEIGHT;
|
||||
|
||||
glColor4fv (energy_background_color);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0.0, y);
|
||||
glVertex2f (GAUGE_IMG_SIZE, y);
|
||||
glVertex2f (GAUGE_IMG_SIZE, GAUGE_IMG_SIZE);
|
||||
glVertex2f (0.0, GAUGE_IMG_SIZE);
|
||||
glEnd ();
|
||||
const GLfloat vtx1 [] = {
|
||||
0.0, y,
|
||||
GAUGE_IMG_SIZE, y,
|
||||
GAUGE_IMG_SIZE, GAUGE_IMG_SIZE,
|
||||
0.0, GAUGE_IMG_SIZE
|
||||
};
|
||||
const GLfloat vtx2 [] = {
|
||||
0.0, 0.0,
|
||||
GAUGE_IMG_SIZE, 0.0,
|
||||
GAUGE_IMG_SIZE, y,
|
||||
0.0, y
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glColor4fv (energy_foreground_color);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0.0, 0.0);
|
||||
glVertex2f (GAUGE_IMG_SIZE, 0.0);
|
||||
glVertex2f (GAUGE_IMG_SIZE, y);
|
||||
glVertex2f (0.0, y);
|
||||
glEnd ();
|
||||
glColor4fv(energy_background_color);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx1);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glColor4fv(energy_foreground_color);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx2);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
double speedbar_frac = 0.0;
|
||||
|
||||
|
@ -212,13 +220,19 @@ void draw_gauge (double speed, double energy) {
|
|||
draw_partial_tri_fan (min (1.0, speedbar_frac));
|
||||
|
||||
glColor4fv (hud_white);
|
||||
Tex.BindTex (GAUGE_OUTLINE);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (0.0, 0.0);
|
||||
glVertex2f (GAUGE_IMG_SIZE, 0.0);
|
||||
glVertex2f (GAUGE_IMG_SIZE, GAUGE_IMG_SIZE);
|
||||
glVertex2f (0.0, GAUGE_IMG_SIZE);
|
||||
glEnd();
|
||||
Tex.BindTex(GAUGE_OUTLINE);
|
||||
const GLfloat vtx3 [] = {
|
||||
0.0, 0.0,
|
||||
GAUGE_IMG_SIZE, 0.0,
|
||||
GAUGE_IMG_SIZE, GAUGE_IMG_SIZE,
|
||||
0.0, GAUGE_IMG_SIZE
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx3);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -241,12 +255,16 @@ void DrawWind (double dir, double speed) {
|
|||
glColor4f (1, 0, 0, 0.5);
|
||||
glTranslatef (82, 77, 0);
|
||||
glRotatef (dir, 0, 0, 1);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (-3, 0.0);
|
||||
glVertex2f (3, 0.0);
|
||||
glVertex2f (3, -speed);
|
||||
glVertex2f (-3, -speed);
|
||||
glEnd();
|
||||
const GLfloat vtx [] = {
|
||||
-2, 0.0,
|
||||
2, 0.0,
|
||||
2, -speed,
|
||||
-2, -speed
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPopMatrix ();
|
||||
Tex.Draw (SPEED_KNOB, 74, Winsys.resolution.height - 84, 1.0);
|
||||
}
|
||||
|
@ -272,13 +290,16 @@ void DrawWind2 (float dir, float speed, const CControl *ctrl) {
|
|||
glPushMatrix ();
|
||||
glColor4f (red, 0, blue, alpha);
|
||||
glTranslatef (72, 66, 0);
|
||||
glRotatef (dir, 0, 0, 1);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (-5, 0.0);
|
||||
glVertex2f (5, 0.0);
|
||||
glVertex2f (5, -len);
|
||||
glVertex2f (-5, -len);
|
||||
glEnd();
|
||||
glRotatef(dir, 0, 0, 1);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
const GLfloat vtx1 [] = {
|
||||
-5, 0.0,
|
||||
5, 0.0,
|
||||
5, -len,
|
||||
- 5, -len
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx1);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glPopMatrix ();
|
||||
|
||||
// direction indicator
|
||||
|
@ -290,12 +311,15 @@ void DrawWind2 (float dir, float speed, const CControl *ctrl) {
|
|||
glColor4f (0, 0.5, 0, 1.0);
|
||||
glTranslatef (72, 66, 0);
|
||||
glRotatef (dir_angle + 180, 0, 0, 1);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (-2, 0.0);
|
||||
glVertex2f (2, 0.0);
|
||||
glVertex2f (2, -50);
|
||||
glVertex2f (-2, -50);
|
||||
glEnd();
|
||||
const GLfloat vtx2 [] = {
|
||||
-2, 0.0,
|
||||
2, 0.0,
|
||||
2, -50,
|
||||
-2, -50
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx2);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPopMatrix ();
|
||||
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
|
@ -343,16 +367,29 @@ void DrawFps () {
|
|||
void DrawPercentBar (float fact, float x, float y) {
|
||||
Tex.BindTex (T_ENERGY_MASK);
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (x, y);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (x+32, y);
|
||||
glTexCoord2f (1, fact);
|
||||
glVertex2f (x+32, y+fact*128);
|
||||
glTexCoord2f (0, fact);
|
||||
glVertex2f (x, y+fact*128);
|
||||
glEnd();
|
||||
|
||||
const GLfloat tex [] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, fact,
|
||||
0, fact
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
x, y,
|
||||
x + 32, y,
|
||||
x + 32, y + fact * 128,
|
||||
x, y + fact * 128
|
||||
};
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void DrawCoursePosition (const CControl *ctrl) {
|
||||
|
|
|
@ -53,10 +53,9 @@ GNU General Public License for more details.
|
|||
|
||||
struct TGuiParticle {
|
||||
TVector2 pt;
|
||||
double size;
|
||||
float size;
|
||||
TVector2 vel;
|
||||
TVector2 tex_min;
|
||||
TVector2 tex_max;
|
||||
const GLfloat* tex;
|
||||
|
||||
TGuiParticle(double x, double y);
|
||||
void Draw(double xres, double yres) const;
|
||||
|
@ -64,7 +63,6 @@ struct TGuiParticle {
|
|||
};
|
||||
|
||||
static list<TGuiParticle> particles_2d;
|
||||
static GLfloat part_col[4] = {1, 1, 1, 0.5 };
|
||||
static TVector2 push_position(0, 0);
|
||||
static TVector2 last_push_position;
|
||||
static double last_update_time = -1;
|
||||
|
@ -81,36 +79,43 @@ TGuiParticle::TGuiParticle(double x, double y) {
|
|||
vel.x = 0;
|
||||
vel.y = -BASE_VELOCITY - p_dist * VELOCITY_RANGE;
|
||||
|
||||
int type = (int) (frand() * (4.0 - EPS));
|
||||
if (type == 0) {
|
||||
tex_min = TVector2(0.0, 0.0);
|
||||
tex_max = TVector2(0.5, 0.5);
|
||||
} else if (type == 1) {
|
||||
tex_min = TVector2(0.5, 0.0);
|
||||
tex_max = TVector2(1.0, 0.5);
|
||||
} else if (type == 2) {
|
||||
tex_min = TVector2(0.5, 0.5);
|
||||
tex_max = TVector2(1.0, 1.0);
|
||||
} else {
|
||||
tex_min = TVector2(0.0, 0.5);
|
||||
tex_max = TVector2(0.5, 1.0);
|
||||
}
|
||||
static const GLfloat tex_coords[4][8] = {
|
||||
{
|
||||
0.0, 0.0,
|
||||
0.5, 0.0,
|
||||
0.5, 0.5,
|
||||
0.0, 0.5
|
||||
}, {
|
||||
0.5, 0.0,
|
||||
1.0, 0.0,
|
||||
1.0, 0.5,
|
||||
0.5, 0.5
|
||||
}, {
|
||||
0.0, 0.5,
|
||||
0.5, 0.5,
|
||||
0.5, 1.0,
|
||||
0.0, 1.0
|
||||
}, {
|
||||
0.5, 0.5,
|
||||
1.0, 0.5,
|
||||
1.0, 1.0,
|
||||
0.5, 1.0
|
||||
}
|
||||
};
|
||||
int type = rand() % 4;
|
||||
tex = tex_coords[type];
|
||||
}
|
||||
|
||||
void TGuiParticle::Draw(double xres, double yres) const {
|
||||
glPushMatrix();
|
||||
glTranslatef (pt.x * xres, pt.y * yres, 0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (tex_min.x, tex_min.y);
|
||||
glVertex2f (0, 0);
|
||||
glTexCoord2f (tex_max.x, tex_min.y);
|
||||
glVertex2f (size, 0);
|
||||
glTexCoord2f (tex_max.x, tex_max.y);
|
||||
glVertex2f (size, size);
|
||||
glTexCoord2f (tex_min.x, tex_max.y);
|
||||
glVertex2f (0, size);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
const GLfloat vtx[] = {
|
||||
pt.x * xres, pt.y * yres,
|
||||
pt.x * xres + size, pt.y * yres,
|
||||
pt.x * xres + size, pt.y * yres + size,
|
||||
pt.x * xres, pt.y * yres + size
|
||||
};
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
void TGuiParticle::Update(double time_step, double push_timestep, const TVector2& push_vector) {
|
||||
|
@ -148,7 +153,7 @@ void init_ui_snow () {
|
|||
push_position = TVector2(0.0, 0.0);
|
||||
}
|
||||
|
||||
void update_ui_snow (double time_step) {
|
||||
void update_ui_snow(double time_step) {
|
||||
double time = Winsys.ClockTime ();
|
||||
|
||||
TVector2 push_vector;
|
||||
|
@ -201,11 +206,15 @@ void draw_ui_snow () {
|
|||
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
Tex.BindTex (SNOW_PART);
|
||||
glColor4f(part_col[0], part_col[1], part_col[2], part_col[3]);
|
||||
part_col[3] = 0.3;
|
||||
glColor4f(1.f, 1.f, 1.f, 0.3f);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
for (list<TGuiParticle>::const_iterator i = particles_2d.begin(); i != particles_2d.end(); ++i) {
|
||||
i->Draw(xres, yres);
|
||||
}
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void push_ui_snow (const TVector2& pos) {
|
||||
|
@ -339,7 +348,7 @@ void create_new_particles (const TVector3& loc, TVector3 vel, int num) {
|
|||
newp->pt.x = loc.x + 2.*(frand() - 0.5) * START_RADIUS;
|
||||
newp->pt.y = loc.y;
|
||||
newp->pt.z = loc.z + 2.*(frand() - 0.5) * START_RADIUS;
|
||||
newp->type = (int) (frand() * (4.0 - EPS));
|
||||
newp->type = rand() % 4;
|
||||
newp->base_size = (frand() + 0.5) * OLD_PART_SIZE;
|
||||
newp->cur_size = NEW_PART_SIZE;
|
||||
newp->age = frand() * MIN_AGE;
|
||||
|
@ -377,8 +386,7 @@ void draw_particles (const CControl *ctrl) {
|
|||
ScopedRenderMode rm(PARTICLES);
|
||||
Tex.BindTex (SNOW_PART);
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColor4f(part_col[0], part_col[1], part_col[2], part_col[3]);
|
||||
part_col[3] = 0.8; // !!!!!!!!!
|
||||
glColor4f(1.f, 1.f, 1.f, 0.8f);
|
||||
|
||||
for (list<Particle>::const_iterator p = particles.begin(); p != particles.end(); ++p) {
|
||||
if (p->age >= 0)
|
||||
|
|
|
@ -1204,5 +1204,21 @@ void UpdateQuadtree (const TVector3& view_pos, float detail) {
|
|||
|
||||
void RenderQuadtree() {
|
||||
GLubyte *vnc_array = Course.GetGLArrays();
|
||||
root->Render (root_corner_data, vnc_array);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, STRIDE_GL_ARRAY, vnc_array);
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, STRIDE_GL_ARRAY,
|
||||
vnc_array + 4 * sizeof(GLfloat));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, STRIDE_GL_ARRAY,
|
||||
vnc_array + 8 * sizeof(GLfloat));
|
||||
|
||||
root->Render(root_corner_data, vnc_array);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
|
167
src/textures.cpp
167
src/textures.cpp
|
@ -28,6 +28,14 @@ GNU General Public License for more details.
|
|||
#include <fstream>
|
||||
#include <cctype>
|
||||
|
||||
|
||||
static const GLfloat fullsize_texture [] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// class CImage
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -369,17 +377,22 @@ void TTexture::Draw() {
|
|||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (0, 0);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (w, 0);
|
||||
glTexCoord2f (1, 1);
|
||||
glVertex2f (w, h);
|
||||
glTexCoord2f (0, 1);
|
||||
glVertex2f (0, h);
|
||||
glEnd();
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
const GLfloat vtx [] = {
|
||||
0, 0,
|
||||
w, 0,
|
||||
w, h,
|
||||
0, h
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, fullsize_texture);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void TTexture::Draw(int x, int y, float size, Orientation orientation) {
|
||||
|
@ -408,30 +421,31 @@ void TTexture::Draw(int x, int y, float size, Orientation orientation) {
|
|||
else left = (Winsys.resolution.width - width) / 2;
|
||||
right = left + width;
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (left, bott);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (right, bott);
|
||||
glTexCoord2f (1, 1);
|
||||
glVertex2f (right, top);
|
||||
glTexCoord2f (0, 1);
|
||||
glVertex2f (left, top);
|
||||
glEnd();
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
const GLfloat vtx [] = {
|
||||
left, bott,
|
||||
right, bott,
|
||||
right, top,
|
||||
left, top
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, fullsize_texture);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void TTexture::Draw(int x, int y, float width, float height, Orientation orientation) {
|
||||
GLint w, h;
|
||||
GLfloat top, bott, left, right;
|
||||
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBindTexture (GL_TEXTURE_2D, id);
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
||||
|
||||
if (orientation == OR_TOP) {
|
||||
top = Winsys.resolution.height - y;
|
||||
bott = top - height;
|
||||
|
@ -443,17 +457,22 @@ void TTexture::Draw(int x, int y, float width, float height, Orientation orienta
|
|||
else left = (Winsys.resolution.width - width) / 2;
|
||||
right = left + width;
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (left, bott);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (right, bott);
|
||||
glTexCoord2f (1, 1);
|
||||
glVertex2f (right, top);
|
||||
glTexCoord2f (0, 1);
|
||||
glVertex2f (left, top);
|
||||
glEnd();
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
const GLfloat vtx [] = {
|
||||
left, bott,
|
||||
right, bott,
|
||||
right, top,
|
||||
left, top
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, fullsize_texture);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void TTexture::DrawFrame(int x, int y, double w, double h, int frame, const TColor& col) {
|
||||
|
@ -467,6 +486,8 @@ void TTexture::DrawFrame(int x, int y, double w, double h, int frame, const TCol
|
|||
|
||||
glBindTexture (GL_TEXTURE_2D, id);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
if (frame > 0) {
|
||||
if (w < 1) glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &ww);
|
||||
if (h < 1) glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &hh);
|
||||
|
@ -474,26 +495,34 @@ void TTexture::DrawFrame(int x, int y, double w, double h, int frame, const TCol
|
|||
glColor4f (col.r, col.g, col.b, 1.0);
|
||||
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (xx - frame, yy - frame);
|
||||
glVertex2f (xx + ww + frame, yy - frame);
|
||||
glVertex2f (xx + ww + frame, yy + hh + frame);
|
||||
glVertex2f (xx - frame, yy + hh + frame);
|
||||
glEnd();
|
||||
const GLfloat vtx [] = {
|
||||
xx - frame, yy - frame,
|
||||
xx + ww + frame, yy - frame,
|
||||
xx + ww + frame, yy + hh + frame,
|
||||
xx - frame, yy + hh + frame
|
||||
};
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (xx, yy);
|
||||
glTexCoord2f (1, 0);
|
||||
glVertex2f (xx + ww, yy);
|
||||
glTexCoord2f (1, 1);
|
||||
glVertex2f (xx + ww, yy + hh);
|
||||
glTexCoord2f (0, 1);
|
||||
glVertex2f (xx, yy + hh);
|
||||
glEnd();
|
||||
|
||||
const GLfloat vtx [] = {
|
||||
xx, yy,
|
||||
xx + ww, yy,
|
||||
xx + ww, yy + hh,
|
||||
xx, yy + hh
|
||||
};
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, fullsize_texture);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -634,17 +663,22 @@ void CTexture::DrawNumChr (char c, int x, int y, int w, int h, const TColor& col
|
|||
float texleft = idx * texw;
|
||||
float texright = (idx + 1) * texw;
|
||||
|
||||
glColor4f (col.r, col.g, col.b, col.a);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (texleft, 0);
|
||||
glVertex2f (bl.x, bl.y);
|
||||
glTexCoord2f (texright, 0);
|
||||
glVertex2f (tr.x, bl.y);
|
||||
glTexCoord2f (texright, 1);
|
||||
glVertex2f (tr.x, tr.y);
|
||||
glTexCoord2f (texleft, 1);
|
||||
glVertex2f (bl.x, tr.y);
|
||||
glEnd();
|
||||
const GLfloat tex [] = {
|
||||
texleft, 0,
|
||||
texright, 0,
|
||||
texright, 1,
|
||||
texleft, 1
|
||||
};
|
||||
const GLfloat vtx [] = {
|
||||
bl.x, bl.y,
|
||||
tr.x, bl.y,
|
||||
tr.x, tr.y,
|
||||
bl.x, tr.y
|
||||
};
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
void CTexture::DrawNumStr (const char *s, int x, int y, float size, const TColor& col) {
|
||||
|
@ -657,9 +691,14 @@ void CTexture::DrawNumStr (const char *s, int x, int y, float size, const TColor
|
|||
int qw = (int)(22 * size);
|
||||
int qh = (int)(32 * size);
|
||||
|
||||
glColor4f(col.r, col.g, col.b, col.a);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
for (size_t i=0; s[i] != '\0'; i++) {
|
||||
DrawNumChr (s[i], x + (int)i*qw, y, qw, qh, col);
|
||||
}
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
|
@ -135,16 +135,21 @@ static const TLight toollight = {
|
|||
};
|
||||
static int tool_mode = 0;
|
||||
|
||||
void DrawQuad (float x, float y, float w, float h,
|
||||
float scrheight, const TColor& col, int frame) {
|
||||
void DrawQuad (float x, float y, float w, float h, float scrheight, const TColor& col, int frame) {
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glColor4f (col.r, col.g, col.b, col.a);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (x-frame, scrheight-y-h-frame);
|
||||
glVertex2f (x+w+frame, scrheight-y-h-frame);
|
||||
glVertex2f (x+w+frame, scrheight-y+frame);
|
||||
glVertex2f (x-frame, scrheight-y+frame);
|
||||
glEnd();
|
||||
const GLfloat vtx [] = {
|
||||
x - frame, scrheight - y - h - frame,
|
||||
x + w + frame, scrheight - y - h - frame,
|
||||
x + w + frame, scrheight - y + frame,
|
||||
x - frame, scrheight - y + frame
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vtx);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue