wiki.delphigl.com/in...hp/Tutorial_lektion4
kapiert irgendjemand den Teil? ich versteh nich so ganz was ich damit jetzt machen soll.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| uses SDL, SDL_Image;
var tex : PSDL_Surface; begin tex := IMG_Load('textur.jpg'); if assigned(tex) then begin glGenTextures(1, @TexID); glBindTexture(GL_TEXTURE_2D, TexID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, tex^.w, tex^.h,0, GL_RGB, GL_UNSIGNED_BYTE, tex^.pixels);
SDL_FreeSurface(tex); end; |
Das is letztendich alles was ich da an code kriege, aber ich frage mich, was soll ich jetzt mit dem code machen? wohin soll ich den schreiben?
ich hab mal versucht ihn in einer Procedure zu packen:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| procedure TForm1.InitTextures; var tex : PSDL_Surface; begin tex := IMG_Load('textur.jpg'); if assigned(tex) then begin glGenTextures(1, @TexID); glBindTexture(GL_TEXTURE_2D, TexID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, tex^.w, tex^.h,0, GL_RGB, GL_UNSIGNED_BYTE, tex^.pixels);
SDL_FreeSurface(tex); end; end; |
Aber dann meckert Delphi zurecht und fragt was texID für eine Variable sei. Das frag ich mich auch.
dann hab ich sie einfachmal als Cardinal deklariert, und die ganze procedure in FormCreate gepackt, aber dann werd ich mit AccessViolations überhäuft...
Hat jemand ne ahnung wie man jetzt weiter machen muss?