OpenGL - Textur aus Datei laden
-
Wie mach ich das?
Also ich suche eine einfache, möglichkeit eine Textur aus einer datei in eine für OpenGL verwertbare Form zu bringen. Das ganze sollte sowohl unter Linux als auch unter Windows funktionieren und es sollten möglichst viele Dateiformate unterstützt werden, aufjedenfall aber portable network graphics (png). Gibt es da vieleicht eine Bibliothek für? Ich hab nämlich keine Lust mir sowas selbst zu schreiben.
-
Ja, gibt es
Clanlib, SDL oder Allegro, wobei ich ersteres bevorzuge
Schau mal in die FAQ für mehr Infos !
-
Such mit Google mal nach DevIL oder OpenIL.
Das ist ne' ImageLib, die sogar spezielle Funktionen für OpenGL unterstützt.
Ist echt einfach und läuft auf Linux und Win.
Was die Formate angeht, hier ist ein Ausschnitt aus der Devil-Doc:IL_BMP
Load the image as a Microsoft bitmap (.bmp).
IL_CUT
Load the image as a .cut image.
IL_DDS
Load the image as a DirectDraw Surface (.dds) image.
IL_DOOM
Load the image as a Doom texture.
IL_DOOM_FLAT
Load the image as a Doom flat (floor).
IL_GIF
Load the image as a Graphics Interchange Format (.gif) file.
IL_ICO
Load the image as a Microsoft icon (.ico).
IL_JPG
Load the image as a Jpeg (.jpg).
IL_LIF
Load the image as a Homeworld .lif file.
IL_MNG
Load the image as a .mng file.
IL_PCD
Load the image as a .pcd image.
IL_PCX
Load the image as a PCX.
IL_PIC
Load the image as a .pic image.
IL_PNG
Load the image as a Portable Network Graphics (.png) image.
IL_PNM
Load the image as a Portable AnyMap (.pbm, .pgm or .ppm).
IL_PSD
Load the image as an Adobe Photoshop (.psd) image.
IL_PSP
Load the image as a Paint Shop Pro (.psp) image.
IL_SGI
Load the image as a SGI (.bw, .rgb, .rgba or .sgi).
IL_TGA
Load the image as a TrueVision Targa.
IL_TIF
Load the image as a TIFF (.tif or .tiff) image.
IL_RAW
Load the image as raw data with a 13-byte header.
IL_JASC_PAL
Load the file into the current image's palette as a Paint Shop Pro (Jasc) palette.
-
Danke Kane, genau sowas hab ich gesucht.
Jetzt muss ich nur noch herausfinden wie es funktioniert.
-
iuc bin col
-
Eho schrieb:
Danke Kane, genau sowas hab ich gesucht.
Jetzt muss ich nur noch herausfinden wie es funktioniert.Für OpenGL ist auch generell gli gut. Liefert auch gleich eine Textur-ID zurück. Kann aber nur DDS und TGA. Reicht aber.
Ansonsten das genannte devIL oder auch FreeImage. Gibt etliche.
-
Schaut euch mal das Eröffnungsdatum des Threads an