0

I am working on a graphics game project in OpenGL and I want to make a front page of the game containing a image, few buttons and some text. Buttons on click perform different actions e.g. start button for starting the game , Can anyone please suggest me , How can I do it?

datenwolf
  • 159,371
  • 13
  • 185
  • 298
Mukesh
  • 117
  • 1
  • 1
  • 6

3 Answers3

3

How can I do it?

Well, by implementing it. OpenGL is not a game engine, nor a scene graph, nor a UI toolkit. It's merely a drawing API providing you the means to draw nice pictures, and that's it. Anything beyond that is the task of either a 3rd party library/toolkit, or your own code, or a combination of both.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
2

A usual approach to model this behaviour is by introducing application states. Here is a related question.

You could model your StartScreenState by drawing a plane with buttons using an orthogonal projection and not drawing (or not having initialized yet) the rest. When the player clicks on 'start', you can switch to perspective projection and display game contents.

Community
  • 1
  • 1
kostja
  • 60,521
  • 48
  • 179
  • 224
0

I don't know that I would even use OpenGL for that. OpenGL is for rendering colored/textured triangles/quads so that you can do tons of stuff graphically. There's no such thing as "load an image to coordinate x,y on the screen". The equivalent would be "draw two triangles with these vertices that make up a rectangle and are textured with this image". Which is why I would probably stay away from OpenGL to do this, because you don't really need to use any of the awesome features that OpenGL has.

A very common UI framework that I believe nestles in with OpenGL well if you really want to use the two together is Qt. It should make your life easier in terms of UI stuff. See wiki and dev page.

Andrew Rasmussen
  • 14,912
  • 10
  • 45
  • 81