Registriert: Fr Mai 28, 2010 13:28 Beiträge: 25 Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
I Start a project very simple. I use the dglOpenGL.pas for the main tamplete and the textures.pas.
The program makes this simple thing.
I have a cube in the middle of the screen. I use the virtual keys (with the form.keydown ) up and down. Up changes the image from a folder. The folder has at least 10.000 images. But is small near 100 kb. The images is in png format.
My problem is when i change the image the memory doesn't freed. The texture some how stays inside the memory. So in sort time (the program stats with 19MB) i have 400 mb.
Can someone tell me how can i solve this...
here is the fuctinon to lad a png texture.
Code:
function LoadPNGTexture(Filename: String; var Texture : GLuint; LoadFromResource : Boolean) : Boolean; var //pData : Pointer; PNGImage : TPNGGraphic; BMP : TBitmap; Data : Array of LongWord; W, Width : Integer; H, Height : Integer; Line : ^LongWord; C : LongWord; begin PNGImage := TPNGGraphic.Create; try PNGimage.LoadFromFile(Filename); except MessageBox(0, PChar('Couldn''t load PNG - "'+ Filename +'"'), PChar('BMP Unit'), MB_OK); Exit; end; BMP := TBitmap.Create; BMP.pixelformat:=pf32bit; BMP.width:= PNGImage.Width; BMP.height:= PNGImage.Height; BMP.canvas.draw(0,0,PNGImage);
Width :=BMP.Width; Height :=BMP.Height; SetLength(Data, Width*Height); For H:=0 to Height-1 do Begin Line :=BMP.scanline[Height-H-1]; // flip JPEG For W:=0 to Width-1 do Begin c:=Line^ and $FFFFFF; // Need to do a color swap Data[W+(H*Width)] :=(((c and $FF) shl 16)+(c shr 16)+(c and $FF00)) or $FF000000; // 4 channel. inc(line); End; End;
if Key = VK_UP then begin if WherePointer <=0 then WherePointer := 1; if FileExists('pic'+WherePointer+'.png') then LoadTexture('pic'+WherePointer+'.png'',texCube,False) else LoadTexture(nopicture.png',TexCube,False) WherePointer := WherePointer - 1; end; ;
_________________ Try to think first before you act....
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Do you call glDeleteTextures at some place, specifically before assigning a new texture to TexCube?
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
Registriert: Fr Mai 28, 2010 13:28 Beiträge: 25 Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
Lord Horazont hat geschrieben:
Do you call glDeleteTextures at some place, specifically before assigning a new texture to TexCube?
greetings
Thank you my friend i solve this problem... I use the glDeleteTextures before i call the LoadTexture and the problem solves thank you very very much ....
Thanks...
_________________ Try to think first before you act....
Mitglieder in diesem Forum: 0 Mitglieder und 2 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.