Game buttons

Member
Posts: 131
Joined: 2010.08
Post: #1
Which one should buttons in a game be, views or objects that draw to the main view's OpenGL context?
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #2
Generally speaking it is usually faster to draw your buttons yourself right in your main OpenGL view.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #3
It is faster, but is it otherwise better?
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #4
What, is faster not better enough for you? Rasp

Yes, you can draw them in their own views if you wish. One thing that is probably a negative is that if you're using OS supplied buttons, they don't usually look good with your game graphics, but that's up to your choice of aesthetic appeal. You'd be surprised how little details like that matter to customers. Sometimes you'll even get negative comments for things like that, unless it isn't too tacky.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #5
When I do this to draw into an NSOpenGLView that is a button,
Code:
- (void)drawRect {
    [self reshape];
    glClearColor(0, 0, 1, 0);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glColor3f(5.0f, 0.0f, 1.0f);
    glBegin(GL_POLYGON);
    {
        glVertex2f(INDENT, INDENT);
        glVertex2f(size.width - INDENT, INDENT);
        glVertex2f(size.width - INDENT, size.height - INDENT);
        glVertex2f(INDENT, size.height - INDENT);
    }
    glEnd();
    glPopMatrix();
}
the whole main NSOpenGLView is cleared into 0, 0, 1, 0. Only this view should be cleared. How to solve this problem? (Is it that I manually call this drawRect method instead of letting the application do it?)
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #6
Dude, if you're drawing your button using OpenGL, it makes no sense at all not to draw it into your main OpenGL view. I was thinking you were talking about using a system button or Quartz drawing into another NSView.

Just draw your game scene first, then draw your button scene on top of that in the same OpenGL view.
Quote this message in a reply
Member
Posts: 131
Joined: 2010.08
Post: #7
Thanks. However, could you explain the problem. Why is the clear function used for another OpenGL context?
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #8
My guess would be that you didn't make the button's glContext the active one before you started drawing to it.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Strange bug with yellow minimize buttons GolfHacker 21 9,540 Jun 20, 2007 05:15 PM
Last Post: GolfHacker
  GLUI buttons eShad0w 1 6,424 Jul 6, 2006 12:17 PM
Last Post: Duane
  textured windows/animated buttons hyperzoanoid 5 3,909 Jan 5, 2003 01:19 PM
Last Post: hyperzoanoid
  Receiving mouse clicks from different buttons Tobi 6 5,091 May 20, 2002 12:22 AM
Last Post: Tobi