JernejL
05-02-2005, 11:04 PM
procedure drawwindowframe(x, y, w, h: single);
begin
glcolor4ub(255, 255, 255, 255);
glFrontFace(GL_CW);
glBindTexture(gl_texture_2d, win.GLID);
// TOP one
glBegin(gl_quads);
glTexCoord2f(F0, FC); glvertex2fwin(x, y);
glTexCoord2f(F0, FB); glvertex2fwin(x, y + winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FA, FC); glvertex2fwin(x + winframe, y);
glTexCoord2f(FA, FC); glvertex2fwin(x + winframe, y);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FB, FC); glvertex2fwin(x + w - winframe, y);
glTexCoord2f(FB, FC); glvertex2fwin(x + w - winframe, y);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FC, FB); glvertex2fwin(x + w, y + winframe);
glTexCoord2f(FC, FC); glvertex2fwin(x + w, y);
// middle one
glTexCoord2f(F0, FB); glvertex2fwin(x, y + winframe);
glTexCoord2f(F0, FA); glvertex2fwin(x, y + h - winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FC, FA); glvertex2fwin(x + w, y + h - winframe);
glTexCoord2f(FC, FB); glvertex2fwin(x + w, y + winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
// bottom one
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FB, F0); glvertex2fwin(x + w - winframe, y + h);
glTexCoord2f(FC, F0); glvertex2fwin(x + w, y + h);
glTexCoord2f(FC, FA); glvertex2fwin(x + w, y + h - winframe);
glTexCoord2f(F0, FA); glvertex2fwin(x, y + h - winframe);
glTexCoord2f(F0, F0); glvertex2fwin(x, y + h);
glTexCoord2f(FA, F0); glvertex2fwin(x + winframe, y + h);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, F0); glvertex2fwin(x + winframe, y + h);
glTexCoord2f(FB, F0); glvertex2fwin(x + w - winframe, y + h);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glend;
glFrontFace(GL_CCW);
end;
here are the rest of functions you might need:
// Dwarf with Axe - GAMEDEV forums: 18 July 2002 6:12:57 PM
//
// There have been thousands of posts along the lines of
// "How do I do 2d in OpenGL" to "Duuuhde, I wunt too maek
// a two dee gaem in ohpun jee el; how do eye set uhp two dee???!?"
//
// I have developed a simple, nice, pretty way for all of you to have your 2D fun.
procedure GlEnable2D;
var
vport: array[0..3] of integer;
begin
glGetIntegerv(GL_VIEWPORT, @vPort);
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix;
glLoadIdentity;
end;
procedure GlDisable2D;
begin
glMatrixMode(GL_PROJECTION);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glPopMatrix;
end;
// remap coords to fit windows coordinate system direction
procedure glvertex2fwin(const x, y: single);
begin
glvertex2f(x, engine.win_height - y);
end;
edit: i forgot some stuff:
const
winframe = 64 / 3; // the texture size, if you use bigger change this otherwise it will come up scaled and will look ugly
F0 = 0;
Fa = 1 / 3;
Fb = 2 / 3;
Fc = 1;
basicly, this will draw cool window frames like the ones you saw in hl2 gui.
i'll try to add screenshoots of what this is ;)
PICS:
http://www.gtatools.com/temp/winframea.jpg
http://www.gtatools.com/temp/winframeb.jpg
you can also come up with things like this:
http://www.gtatools.com/temp/example300.jpg
here is how it looks like in my game:
http://www.gtatools.com/temp/winframeinaction.jpg
begin
glcolor4ub(255, 255, 255, 255);
glFrontFace(GL_CW);
glBindTexture(gl_texture_2d, win.GLID);
// TOP one
glBegin(gl_quads);
glTexCoord2f(F0, FC); glvertex2fwin(x, y);
glTexCoord2f(F0, FB); glvertex2fwin(x, y + winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FA, FC); glvertex2fwin(x + winframe, y);
glTexCoord2f(FA, FC); glvertex2fwin(x + winframe, y);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FB, FC); glvertex2fwin(x + w - winframe, y);
glTexCoord2f(FB, FC); glvertex2fwin(x + w - winframe, y);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FC, FB); glvertex2fwin(x + w, y + winframe);
glTexCoord2f(FC, FC); glvertex2fwin(x + w, y);
// middle one
glTexCoord2f(F0, FB); glvertex2fwin(x, y + winframe);
glTexCoord2f(F0, FA); glvertex2fwin(x, y + h - winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FC, FA); glvertex2fwin(x + w, y + h - winframe);
glTexCoord2f(FC, FB); glvertex2fwin(x + w, y + winframe);
glTexCoord2f(FA, FB); glvertex2fwin(x + winframe, y + winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FB, FB); glvertex2fwin(x + w - winframe, y + winframe);
// bottom one
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glTexCoord2f(FB, F0); glvertex2fwin(x + w - winframe, y + h);
glTexCoord2f(FC, F0); glvertex2fwin(x + w, y + h);
glTexCoord2f(FC, FA); glvertex2fwin(x + w, y + h - winframe);
glTexCoord2f(F0, FA); glvertex2fwin(x, y + h - winframe);
glTexCoord2f(F0, F0); glvertex2fwin(x, y + h);
glTexCoord2f(FA, F0); glvertex2fwin(x + winframe, y + h);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, FA); glvertex2fwin(x + winframe, y + h - winframe);
glTexCoord2f(FA, F0); glvertex2fwin(x + winframe, y + h);
glTexCoord2f(FB, F0); glvertex2fwin(x + w - winframe, y + h);
glTexCoord2f(FB, FA); glvertex2fwin(x + w - winframe, y + h - winframe);
glend;
glFrontFace(GL_CCW);
end;
here are the rest of functions you might need:
// Dwarf with Axe - GAMEDEV forums: 18 July 2002 6:12:57 PM
//
// There have been thousands of posts along the lines of
// "How do I do 2d in OpenGL" to "Duuuhde, I wunt too maek
// a two dee gaem in ohpun jee el; how do eye set uhp two dee???!?"
//
// I have developed a simple, nice, pretty way for all of you to have your 2D fun.
procedure GlEnable2D;
var
vport: array[0..3] of integer;
begin
glGetIntegerv(GL_VIEWPORT, @vPort);
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix;
glLoadIdentity;
end;
procedure GlDisable2D;
begin
glMatrixMode(GL_PROJECTION);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glPopMatrix;
end;
// remap coords to fit windows coordinate system direction
procedure glvertex2fwin(const x, y: single);
begin
glvertex2f(x, engine.win_height - y);
end;
edit: i forgot some stuff:
const
winframe = 64 / 3; // the texture size, if you use bigger change this otherwise it will come up scaled and will look ugly
F0 = 0;
Fa = 1 / 3;
Fb = 2 / 3;
Fc = 1;
basicly, this will draw cool window frames like the ones you saw in hl2 gui.
i'll try to add screenshoots of what this is ;)
PICS:
http://www.gtatools.com/temp/winframea.jpg
http://www.gtatools.com/temp/winframeb.jpg
you can also come up with things like this:
http://www.gtatools.com/temp/example300.jpg
here is how it looks like in my game:
http://www.gtatools.com/temp/winframeinaction.jpg