Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Buttons

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    14

    Buttons

    Hi guys, I'm writing an opengl program which at this stage is pretty basic, and at the moment I'm just working on getting the UI sorted. I open a new window with an opengl scene/screen or whatever its called and ive managed to load a background image. The next thing I want to do is create click regions/buttons. I made a class that enables me to create a new button object using my button class with height and width dimensions as well as x and y coordinates for positioning. How do I go about implementing buttons though? At the moment, the only way that I've managed to get the whole thing to work is by creating a function along side my other opengl standard functions like resize, paintgl etc... i.e. I have a function called clickevent or something along those lines and inside that, I've got the instances of all my buttons, so the buttons appear every time a click happens and they no longer exist once the click function has been processed which includes every button getting checked for clicks... which as you can image can bog down the performance if lots of clicks are necessary. I tried putting the button instantiation inside the opengl class constructor but when I subsequently use those classes, it says that they haven't been defined which I actually understood just as I was writing this to mean that once the constructor function ends, the classes are destroyed - at least I think that's what happens. This to me seems really inefficient but it's the only way that I've managed to structure my program which has allowed it to actually get compiled. Any ideas on how else to implement what I'm trying to do?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,104
    Have a look at something like this
    http://gigi.sourceforge.net/screenshots.php
    It might help you

Posting Permissions

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