Click to See Complete Forum and Search --> : OpenGL-how to load images
hackedx
March 16th, 2008, 06:49 PM
How do i load images into OpenGL? I want to make a program's GUI in photoshop and load it. Depending on what you click, stuff will happen. Also for example if i wanted the user to enter something at a specific location with(cin>> C++) on the GUI how would i do that?
I'm looking for easy solutions please, nothing hard or confusing.
Thank you.
Lindley
March 16th, 2008, 10:35 PM
This is not an OpenGL problem. Parts of it could be done that way, but you'd run into far more difficulty than necessary.
The image loading part is one issue----just grab a library capable of reading the file type you want (I suggest libpng, libtiff, and jpeg_6b), and read it in as a 2D (or 3D for RGB) array.
There are several options for displaying the images. You could use OpenGL----just drop them into texture and draw quads. Or you could attach them to GUI elements directly if the GUI framework you decide on supports that (it probably does).
Clicking on things probably isn't the best thing to use OpenGL for, but it's possible. The OpenGL solution is to draw the image to the back buffer, then read back the pixels around where the mouse clicked and use something about them (typically color) to figure out what was clicked on. The better way is to use a GUI framework that provides callbacks when buttons are clicked on, removing the particularls from your realm of responsibility.
Text entry would be extremely difficult to do with just OpenGL. Heck, drawing text is pretty hard by itself----there's no built-in mechanism in OpenGL to do it. Adding that and basic form-editing capabilities? Pretty much a nightmare.
Read up on GUI toolkits, and choose one that suits your needs. It'd be a heck of a lot easier than trying to force OpenGL into doing everything for you.
aewarnick
March 22nd, 2008, 02:24 PM
I just started using Gtk+. It's cross platform and really, really convenient to use for automatic layout of controls. Sort of like designing a web page...
I'm writing a wrapper around it in c++ that, in my opinion, will be much faster and easier to program with than Gtkmm. My wrapper also will not enforce the use of the standard library like Gtkmm does.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.