Registriert: Do Jul 23, 2009 04:33 Beiträge: 157
Programmiersprache: Turbo Delphi Pro
Dann kann ich dir nur den TGA-Loader anbieten. Er lädt allerdings ausschließlich unkrompimierte 32-Bit TGAs. Vielleicht bekommst du es damit zum laufen, mehr kann ich dir aktuell nicht anbieten.
Code:
function loadTGA(ffile: String): Cardinal; type tTGAHeader = packed record idLength: Byte; palette: Byte; tgaType: Byte; pAddr: Word; pLength: Word; pSize: Byte; xNull: Word; yNull: Word; width: Word; height: Word; bits: Byte; attribs: Byte; end; // tgaHeader var tgaFile: tFileStream; header: tTGAHeader; data: array of Byte; Texture: Cardinal; begin tgaFile := tFileStream.Create(ffile,fmOpenRead); tgaFile.ReadBuffer(header,sizeof(header)); if (header.idLength <> 0) or (header.palette <> 0) or (header.tgaType <> 2) or (header.bits <> 32) then begin //raise Exception.Create('Invalid TGA-Header') at @loadTGA; exit; end; // if header setLength(data,header.width*header.height*4); tgaFile.ReadBuffer(data[0],length(data)); glGenTextures(1, @Texture); glBindTexture(GL_Texture_2D,Texture);
Registriert: Do Sep 25, 2003 15:56 Beiträge: 7804 Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Moment. Die glBitmap.pas wird sehr häufig eingesetzt. Wenn da Fehler kommen, liegt an der Benutzung. Was für Fehler kommen denn? Und wie benutzt du diese?
_________________ Blog: kevin-fleischer.de und fbaingermany.com
var Form1: TForm1; Texture: TGLBitmap2D; //variable texture deklarieren
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin DC:= GetDC(Handle); if not InitOpenGL then Application.Terminate; RC:= CreateRenderingContext( DC, [opDoubleBuffered], 32, 24, 0,0,0, 0); ActivateRenderingContext(DC, RC); glClearColor(0, 0, 0, 0.0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); Texture:= TGLBitmap2D.Create('dein dateipfad und name.jpg'); //die texture laden(soweit ich weiss werden bmp, jpg und tga unterstüzt) Texture.GenTexture(); // texture wird generiert end;
procedure TForm1.FormDestroy(Sender: TObject); begin DeactivateRenderingContext; DestroyRenderingContext(RC); ReleaseDC(Handle, DC); Texture.Free; // texture wird nach beenden des programms wieder frei gegeben end;
In dieser Unit kommen aber auch viele Fehler, z.B. Unit JPEG wurde nicht gefunden, C:\Programme\dglsdk\lib\glBitmap.pas(594,54) Error: Duplicate identifier "Format" usw. C:\Programme\dglsdk\lib\jedi-sdl.inc(237,4) Warning: Illegal compiler directive "$THREADING" C:\Programme\dglsdk\lib\jedi-sdl.inc(237,4) Warning: Illegal compiler directive "$THREADING" C:\Programme\dglsdk\lib\jedi-sdl.inc(237,4) Warning: Illegal compiler directive "$THREADING" C:\Programme\dglsdk\lib\jedi-sdl.inc(237,4) Warning: Illegal compiler directive "$THREADING" C:\Programme\dglsdk\lib\glu.pas(140,14) Hint: Type "PPointer" redefinition C:\Programme\dglsdk\lib\jedi-sdl.inc(237,4) Warning: Illegal compiler directive "$THREADING" C:\Programme\dglsdk\lib\glut.pas(74,14) Hint: Type "PInteger" redefinition C:\Programme\dglsdk\lib\glut.pas(75,12) Hint: Type "PPChar" redefinition C:\Programme\dglsdk\lib\glBitmap.pas(594,54) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(594,54) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(595,54) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(595,54) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(604,83) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(604,83) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(609,87) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(609,87) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(667,38) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(667,38) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(667,71) Error: Duplicate identifier "Width" C:\Programme\dglsdk\lib\glBitmap.pas(667,71) Hint: Identifier already defined in glBitmap.pas at line 563 C:\Programme\dglsdk\lib\glBitmap.pas(667,92) Error: Duplicate identifier "Height" C:\Programme\dglsdk\lib\glBitmap.pas(667,92) Hint: Identifier already defined in glBitmap.pas at line 564 C:\Programme\dglsdk\lib\glBitmap.pas(667,114) Error: Duplicate identifier "Depth" C:\Programme\dglsdk\lib\glBitmap.pas(667,114) Hint: Identifier already defined in glBitmap.pas at line 565 C:\Programme\dglsdk\lib\glBitmap.pas(668,27) Error: Duplicate identifier "Target" C:\Programme\dglsdk\lib\glBitmap.pas(668,27) Hint: Identifier already defined in glBitmap.pas at line 569 C:\Programme\dglsdk\lib\glBitmap.pas(668,35) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(668,35) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(668,43) Error: Duplicate identifier "InternalFormat" C:\Programme\dglsdk\lib\glBitmap.pas(668,43) Hint: Identifier already defined in glBitmap.pas at line 571 C:\Programme\dglsdk\lib\glBitmap.pas(682,61) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(682,61) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(724,38) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(724,38) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(724,71) Error: Duplicate identifier "Width" C:\Programme\dglsdk\lib\glBitmap.pas(724,71) Hint: Identifier already defined in glBitmap.pas at line 563 C:\Programme\dglsdk\lib\glBitmap.pas(724,92) Error: Duplicate identifier "Height" C:\Programme\dglsdk\lib\glBitmap.pas(724,92) Hint: Identifier already defined in glBitmap.pas at line 564 C:\Programme\dglsdk\lib\glBitmap.pas(724,114) Error: Duplicate identifier "Depth" C:\Programme\dglsdk\lib\glBitmap.pas(724,114) Hint: Identifier already defined in glBitmap.pas at line 565 C:\Programme\dglsdk\lib\glBitmap.pas(725,27) Error: Duplicate identifier "Target" C:\Programme\dglsdk\lib\glBitmap.pas(725,27) Hint: Identifier already defined in glBitmap.pas at line 569 C:\Programme\dglsdk\lib\glBitmap.pas(725,35) Error: Duplicate identifier "Format" C:\Programme\dglsdk\lib\glBitmap.pas(725,35) Hint: Identifier already defined in glBitmap.pas at line 570 C:\Programme\dglsdk\lib\glBitmap.pas(725,43) Error: Duplicate identifier "InternalFormat" C:\Programme\dglsdk\lib\glBitmap.pas(725,43) Hint: Identifier already defined in glBitmap.pas at line 571 C:\Programme\dglsdk\lib\glBitmap.pas(795,1) Fatal: There were 19 errors compiling module, stopping
Bei der glBitmap.pas aus dem SDK handelt es sich um eine alte Version die nicht Freepascal kompatibel ist. Im Projekt Thread gibt es die neueste Version, die ist Freepascal kompatibel. Hier der Link: http://www.delphigl.com/forum/viewtopic.php?f=13&t=7458
Ok, ich hab mal dein Beispiel ganommen, aber da kommt eine Windows Fehlermeldung am Anfang, wenn das Programm startet. Mein aktueller Code ist dieserhier:
procedure TForm1.FormCreate(Sender: TObject); begin DC:= GetDC(Handle); if not InitOpenGL then Application.Terminate; RC:= CreateRenderingContext( DC, [opDoubleBuffered], 32, 24, 0,0,0, 0); ActivateRenderingContext(DC, RC); glClearColor(0, 0, 0, 0.0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); Texture:= TGLBitmap2D.Create('bilder\gras18.jpg'); //die texture laden(soweit ich weiss werden bmp, jpg und tga unterstüzt) Texture.GenTexture(); // texture wird generiert end;
procedure TForm1.FormDestroy(Sender: TObject); begin DeactivateRenderingContext; DestroyRenderingContext(RC); ReleaseDC(Handle, DC); Texture.Free; // texture wird nach beenden des programms wieder frei gegeben end;
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Hast du in der glBitmap den JPEG-Support aktiviert (oben sind Compilerdirektiven, die man einkommentieren kann) und liegt die jpeg.dll vor?
greetings
_________________ If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung. current projects: ManiacLab; aioxmpp zombofant network • my photostream „Writing code is like writing poetry“ - source unknown
„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb
Mitglieder in diesem Forum: Bing [Bot] und 41 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.