I load them exactly like you presented in the code here in this thread.
My delphi program does not present any errors and
i see box where the texture should be present.
When i load a few images and move frame slider i see
that box changes colors a bit but it has no texture.
When i asked about non power of 2 textures you recommended me
to change some lines in the code of glBitmap.pas. I reverted that
changes, deleted .dcu's, recompiled, but the thing still does not work.
It loads images, it displays a window where is should
present texture. That window is not white like background,
but it has some plain colors which change when i change
frames. the textures are not present.
This does not work in VMWare WindowsXP or on a laptop with
Intel Graphics Extreme 2 - i have seen that card to emulate
OpenGL 1.4. But this has nothing to do with VMWare Windowses
on my dekstop machine which use some other graphics card
emulation.
Strange things...
If not texture dimensions, if not non-power-of-2 textures, then what
this could be..
Registriert: Do Sep 25, 2003 15:56 Beiträge: 7810 Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Maybe its a problem with the pixelformat of the file. But thats like guessing for me. I really have no idea.
Does everything else work correctly? What OpenGL states do you manipulate? Maybe some other stuff is activ and changes your output.
A screenshot whould be helpfull, too (I hope )
_________________ Blog: kevin-fleischer.de und fbaingermany.com
1.Pixel format is 24Bit OS/2 type BMP file, because glBitmap does not accept any other format like Windows BMP.
2.Do you have idea what format have OpenGL textures?
3.what depth do these textures have? [ i have read somewhere that consumer 3D cards convert textures to 32bit - is this time consuming??? ]
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
1. glBitmap accept all bitmaps they can loaded with the TBitmap class. Normally they only could load windows bitmaps. JPGs, TGAs, PNGs are also supported.
2. Opengl texture are uncomressed images with many formats. The most important format is the 8bit per channel format and there the 32 Bit rgba format.
3. Internally they where converted to 32 bit. Sometime and driver depended. The data from an windows 24bit rgb file could transfer directlly to opengl. If some spacerbytes where removed. The convertig of the data is the choise of the driver.
Textureproblem. I don't have any ideas. If you dosn't get any error and no texture where drawn i think we need some picture how it looks like. I think the problem is anywhere else.
PS: If no texture where loaded and white as color is set you should get white planes. Otherwise you should check your texturecoordinates and texturesettings. Some lighteffekt could also result in dark(er) planes.
1st of all, you should put your textures in an array for a better handling.
this saves loads of code because your ifs would turn into something like this:
thats all - using this code, you're able to load hundrets of textures and change them without changing these 2 lines of code.
I don't know exactly what you mean with flickering-effect. Something like this could be caused by too high framerates, which the monitor
can't display, so the graphics card throws the new texture in the graphics ram and the monitor just starts painting it even when the first
texture is drawn before. so you see for a piece of a second two textures on your quad. turning on the vertical synchronisation in your graphics
driver will help.
Another Point is the using of the timer component itself. you should implement a high performance counter to get rid of it.
if that doesn't solve your problem, you should explain exactlier what you mean with flickering.
greetings
edit:
damn, should read more than only the first site ^^
_________________ I'm not the signature, I'm just cleaning the floor...
I am having a lot of brainstorming how to speed up my app.
I have 3 points more to ask today.
I wish to know your opinion.
1.
I have came to the point where i probably experience TBitmap jgp->bmp conversion as performance killer.
I was doing it even in 2-3 TThread objects to check if it could be quicker or maybe my database is slow.
No. i see that frame[0].LoadFromStream function slowly loads JPG image.
I wish to quickly load jpg images to texture array of TglBitmap2D ( frame[1..50] of of TglBitmap2D)
from a disk database.
Do you have any idea how to do this EFFICIENTLY?
I think i cannot afford to load all pictures to TglBitmap2D ARRAY in memory, generate them and use them.
I need to load them from disk file.
My database with images would be 50-200MB for example - too big size for memory.
The function bellow uses TBitmap jpg->bmp conversion which i suspect to be performance killer.
Do you know if there are any other functions to convert loaded jpg to bmp without using
standard TBitmap library?
I would load jpg to memorystream and convert it fast to bmp, then load it with
TglBitmap2D.Load function which would choose LoadFromStream then, without all
that lengthly conversion from JPG using TBitmap.
Or maybe i am wrong and TBitmap is fast conversion??
glBitmap.pas:
Code:
function TglBitmap.LoadJpg(const Stream: TStream):Boolean;
var
bmp: TBitmap;
jpg: TJPEGImage;
StreamPos:Int64;
Temp:array[0..1]ofchar;
begin
Result :=False;
// reading first two bytes to test file and set cursor back to begin
You suggested that i should create some kind of texture manager.
I have declared an array:
frame[1..50] of of TglBitmap2D;
where i load textures using LoadFromStream glBitmap function
a. I load a bmp file to TglBitmap2D object using LoadfromStram
b. I use GenTexture function to generate it
1) at which point the texture is already loaded to graphics card memory?
2)What if all my textures in that array are lets say 200MB ( a 50 images? )
and my graphics card memory is only 128MB like cheap Ati X550.
3) How do i know where that texture went? graphics RAM? operating system RAM? swap file?
3b) There is a function in TglBitmap2D to release memory after texture had been generated.
But what memory? I load these textures to TglBitmap2D array and do not see any
decrease in the memory usage after these textures are generated.
Tell me if you are tired with my questions or i can ask more like today:P
I wish to know everything,i read sources, wiki but my knowledge is still...less than satisfactory.
***
3.
I have analysed glBitmap source and see it uses AssignFromBitmap function which uses TBimap.scanline
function.
I have googled a bit to find some newsgroup post about speeding this bitmap operation up.
I do not know yet IF in AssignFromBitmap
JPG.load function - slows down the program
or bitmap.scanline - slows down the program/
I am sitting here and checking all possibilities to speed up the things.
Maybe part of AssignFromBitmap in glBitmap function:
Code:
for Row :=0to Height -1dobegin
pSource := Bitmap.Scanline[Row];
if(Assigned(pSource))thenbegin
Move(pSource^, pData^, RowSize);
Inc(pData, RowSize);
can be replaced with..
Code:
Right.But direct memory access can be optimized, too (probably you cannot
save more than a few cycles per pixel).But...Did you know that calling
ScanLine takes much time(I think Graphics32's ScanLine is faster)? You can
minimize the calls to ScanLine by using something like:
var
Origin: Integer;
Pitch: Integer;
P: Pointer;
begin
Origin := Integer(Bitmap.ScanLine[0]);
Pitch := Integer(Bitmap.ScanLine[1]) - Origin;
for Y := 0 to Height - 1 do begin
P := Pointer(Origin + Y * Pitch);
or using Bitmap32 library
Code:
var
PixelPtr: PColor32;
begin
PixelPtr:= Bitmap32.PixelPtr[0,0];
with Bitmap32 dofor j:=0to Width*Height -1do
begin
PixelPtr^:= Intensity(PixelPtr^);
Inc(PixelPtr)
end;
end;
andto avoid the intensity callback, you could implement it directly into
the loop.
As you see, there is a few operations to save.
What do you think? What could be the real bottleneck in TglBitmap2D.LoadFromStream ( jpg!) ?
Registriert: Do Sep 25, 2003 15:56 Beiträge: 7810 Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Something about your texturemanager:
You should make this a clever tool. Load 2 up to 4 pics which will be shown next. And let the last 10 pics rest in your GraKa-RAM. If the user steps forward and back, you have no problems with unloaded pics.
The user will whatch those pics, doesn't he? I mean, it is no animation, it should be a slide show? For animations it whould be much harder, because of the huge amount of data you have to load. But if the pic count is < 20 then your gfx-card will have no problem.
You can not determine if a texture is on the card or in the client RAM.
_________________ Blog: kevin-fleischer.de und fbaingermany.com
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
In your special case everthing could be a bottleneck. All the function calls of the glBitmap waste time. You dosnt need to test everything on everyimage. The way to load an jpg and transform it to an Bitmap an load it again is also an bottleneck.
The glBitmap wasn't designed to be the most powerfull textureloader in world. Second place is okay. I designed it to be an easy and very flexible loader.
Some other things.
On generation the glBitmap disposed the internal memory where the texturedata was stored. OpenGL has its own memory so its not necessary to store it longer until generation. But Delphi has its own memorymanager so the Memory could also be allocated by delphi or the taskmanager displayed some differences. To Free the Memory you must set the FreeDataAfterGeneration property to true. Is the default.
To query if the Texture is in the Videomemory you can call the Methode glAreTexturesResident. The property in the glBitmap has the name IsResident. If the card has no own memory the function allways return true.
You must remember. The 128MB of your graphics card are not only for Textures. You must store your Framebuffer into it. Doublebufferd you need 2 Buffers. Windows allocated some memory. So i think from your 128 mb you can only use 64 for textures.
Scanlinecalls. I think this is not your main problem. But yes. Its not the fastes way to load the the difference its just 1 or max 2 milliseconds. Not an thing we should talk about it.
The best thing you could do is to search an jpegalgithym they load it fast and transfer the texturedata direktly to OpenGL!
Could you tell me to which format should i decompress JPG image?
I thought until now i need BMP, but as i see in the sources, even bitmap is
not destination format of image to load to OpenGL.
JPG -> what ? to a pixel array of RGBA?
So in reality i should not generate BMP from JPG but rather try to decompress it and get an array of
pixels in some format?
Please give me a hint about it and what exactly should i search for.
I do not see any OpenGL jpg loaders beside those easy and slow which base on JPG->BMP by Delphi.
Registriert: Sa Jan 01, 2005 17:11 Beiträge: 2068
Programmiersprache: C++
Aro hat geschrieben:
Could you tell me to which format should i decompress JPG image? I thought until now i need BMP, but as i see in the sources, even bitmap is not destination format of image to load to OpenGL.
BMP uses BGR, which is not a problem because you can tell OpenGL that it is in BGR-Format.
Another format ist (unkompressed) TGA. Supports alphachannel but is still BGR(A).
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
Sorry i just have seen it yet.
I can't tell you what algorith you should use. And i never would say you must/should use an commercial lib. I dosn't know what jpeg lib are avail and what the fastet one. It may be possible that an self written algorithm is faster than the delphi class. When i look at irfanview. They loaded all jpegs really fast. Between 70 and 150 milliseconds. I think the loading of an jpeg in delphi is fast but the conversion to RGB is really slow.
The format you transfer to opengl isn't important and you can set it by one parameter of the glTexImage2D function. I mean it's the internal format param. I allways confuse the params. glTexImage used the Pixelbuffer and interprete it as textur or do some conversions. This buffer is only an memorybuffer that contains sequentiall pixel. No more.
When you could load the image as RGBA (BGRA) (8bits per channel) you should do this. RGB (BGR) as format are sometimes slower than RGBA (BGRA). But only if you can load it directlly. To load the image and convert it is slower than the conversion of opengl.
When i have jpeg image it is in jpeg format which i need to convert to RGBA.
But to do this i need to decompress that image as i understand...
and that is where these commercial libs are advertising themselves - speed, multicore support ( intel integrated performance primitives lib )
or pegasus ImagXpress library.
They claim to have jpeg decompression 3 times faster than standard. How
Yes i wish to have it for free, who wants to pay, but as for today i do not understand jpeg format, image compression/decompression.
How much truth in there - i do not know;)
I think i will study jpeg format now:)
What is OpenGL function to return size of memory for textures in graphics card, size of free memory for textures on graphics card?
Mitglieder in diesem Forum: 0 Mitglieder und 0 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.