Results 1 to 5 of 5

Thread: look: half life 2 onscreen panels!!

  1. #1

    look: half life 2 onscreen panels!!

    Code:
    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:

    Code:
    // 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:

    Code:
    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:




    you can also come up with things like this:


    here is how it looks like in my game:
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #2

    look: half life 2 onscreen panels!!

    Looks good! I've been scratching my head at this, and you just saved the day! How about some buttons? *hint hint hint*

  3. #3

    look: half life 2 onscreen panels!!

    Quote Originally Posted by Robert Kosek
    Looks good! I've been scratching my head at this, and you just saved the day! How about some buttons? *hint hint hint*
    buttons could be done without textures, like:

    Code:
    procedure drawButton(x, y, w, h: single; focused, pushed: boolean);
    begin
    resetcolor;
    glFrontFace(GL_CW);
    glBindTexture(gl_texture_2d, btn.GLID);
    
    glcolor3UB(0, 0, 0);
    
    glLineWidth(1);
    
    // border
    glBegin(gl_line_loop);
    glvertex2fwin(x, y);
    glvertex2fwin(x, y + h);
    glvertex2fwin(x + w, y + h);
    glvertex2fwin(x + w, y-1);
    glend;
    
    glLineWidth(2);
    
    glcolor3UB(255, 255, 255);
    
    // TOP one
    glBegin(gl_line_loop);
    glvertex2fwin(x+2, y+1);
    glvertex2fwin(x+2, y + h-2);
    glcolor3UB(128, 128, 128);
    glvertex2fwin(x + w-1, y + h-2);
    glvertex2fwin(x + w-1, y-1+2);
    glend;
    
    glFrontFace(GL_CCW);
    end;
    this looks quite good, i'll poke around with the button a bit more
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #4

    look: half life 2 onscreen panels!!

    have a look at http://www.noeska.com/dogl/glgui.aspx before reinventing the wheel...
    http://3das.noeska.com - create adventure games without programming

  5. #5

    look: half life 2 onscreen panels!!

    Quote Originally Posted by noeska
    have a look at http://www.noeska.com/dogl/glgui.aspx before reinventing the wheel...
    you can't stop me!!

    *runs towards noeska yelling move! MOVE!!!

    :lol:

    personally i think taking jan's gui example code for base
    for gui interface isn't good as it is real mess.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •