PDA

View Full Version : Loading images in GL



Robert Kosek
29-01-2005, 12:19 AM
I was switching to FPC, and in GL I noticed that there was no graphics unit. That's okay but what do I use instead and how? I know there are other ways of loading images to the "texture2d" slot, but what do I do?

Also what do I use for KB input? The standard dos style input wouldn't be good, so what do I use in place? I'm trying to stay platform independant, just so you know.

So far I'm stumped! :oops:

{MSX}
29-01-2005, 09:59 AM
Use JEDI-SDL, so that you can still use GL and you have keyboard input and image loading

Robert Kosek
29-01-2005, 03:01 PM
I know, but I don't want to use SDL which I already mentioned. I've got an idea of how to do it, but I'm still unsure.

{MSX}
29-01-2005, 03:22 PM
I know, but I don't want to use SDL which I already mentioned. I've got an idea of how to do it, but I'm still unsure.

Why not? you'll have no problem using it.

Robert Kosek
29-01-2005, 04:11 PM
No offense is meant, but I've been asked the same question about 5 times ... and I've come back to pretty much the same stuff each time. Please take this as final and stop badgering me about SDL. :x

1) I don't want to wait for header translations, GL is more popular with delphi than SDL. No offense but I don't desire to wait for the CURRENT SDL 2.0 version to have it's header translated.
2) Input and Window managment are done by GLUT, no fear SDL is not needed.
3) Unneccesary files! 1.18mb of DLLS for SDL on top of physics and other dlls?
4) I've got books and have been learning straight gl, I'm not going to try it from a different angle. SDL may use gl but it will be different.

I've made my choice and am sticking with it, don't badger me. :evil:

Paulius
29-01-2005, 05:15 PM
No offense back to you, but SDL doesn?¢_Tt use OpenGL, SDL is used to manage a rendering context for OpenGL, just like GLUT. About the size, the versions of DLL?¢_~s I have are SDL - 232Kb GLUT 168Kb, perhaps you?¢_~re talking about other packages that work alongside SDL, but their optional, and any complicated image format loader will take practically the same amount of space and is it really different if some get compiled into the executable? The reason why many old OpenGl book examples use GLUT is just because it was the first cross platform window manager, that?¢_Ts all.

Robert Kosek
29-01-2005, 05:58 PM
Understood, though with that said ... I see no advantage to using SDL. Yes I know it's got networking code and other things, but with indy and a few other pascal things I should be good to go ... I hope.

What I'm trying to do is load a 24bit bitmap in freepascal, the bitmap info headers aren't in a unit but "struct.inc". How do I load an image based off this code and assign it into a GLUint for texture mapping?

Robert Kosek
29-01-2005, 06:56 PM
Here's my code thus far, it loads an image of the format:

Width,Height,Depth: word;
pData: pointer;

But is my code FPC compliant? If not what must I fix? (fixed/finished)

Paulius
29-01-2005, 07:15 PM
CreateFile, ReadFile etc. are Windows API functions, use streams instead. Why use bitmaps at all, why not use something like TGA, they are basic like bitmaps, but can have an alpha channel.

Robert Kosek
29-01-2005, 07:24 PM
1) can't find an FPC compliant unit
2) since I don't know the format well enough, I made my own format

I got my unit working, I'll try the stream interface instead though.

EDIT, Got it converted to using the FileStream.

Robert Kosek
29-01-2005, 08:21 PM
Got it working even better and am considering adding ZLib compression... :D

Robert Kosek
29-01-2005, 10:31 PM
Finally got it working, and so you know ... no alpha yet. Currently the format is the equivilent of an alphaless tga with a similar file size.

A quick and dirty screenshot:
http://img199.exs.cx/img199/1787/success2op.jpg

Alpha is to come, and I doubt that it would be difficult ... already got the basics.

Bart
30-01-2005, 08:40 AM
I once wrote a platform independent unit for loading uncompressed rgb images (also called SGI images; both rgb and rgba). If someone needs it, i'll post it here.