Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Mai 31, 2024 12:26

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 61 Beiträge ]  Gehe zu Seite Vorherige  1, 2, 3, 4, 5  Nächste
Autor Nachricht
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 21, 2006 13:44 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Use the Pascaltag when you post some sourcecode. Please.

To your flicker problem. That's 100 percently right. You have an timer that were call 33 times in an second. And everytime it is called you changed the textur.

What would you like to do? An screensaver? Then its better you use an smooth transition. I think simple blending is enough for this moment.

Try this for the rendering.
Code:
  1. // First draw on Textur 100% opaque. (Alpha = 1 = 100%)
  2. glColor3f(1, 1, 1);
  3. fTexture1.Bind;
  4. glBegin(GL_QUADS);
  5.   glTexCoord2i(0, 0);
  6.   glVertex3f(0, 0, 0);
  7.  
  8.   glTexCoord2i(0, fTexture1.Heigth);
  9.   glVertex3f(0, panel.Height, 0);
  10.  
  11.   glTexCoord2i(fTexture1.Width, fTexture1.Height);
  12.   glVertex3f(panel.Width, panel.Height, 0);
  13.  
  14.   glTexCoord2i(fTexture1.Width, 0);
  15.   glVertex3f(panel.Width, 0, 0);
  16. glEnd;
  17.  
  18. // setting up Blending
  19. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  20. glEnable(GL_BLEND);
  21.  
  22. // Draw second Textur with variable Alpha (fBlendFaq)
  23. glColor4f(1, 1, 1, fBlendFaq);
  24. fTexture2.Bind;
  25. glBegin(GL_QUADS);
  26.   glTexCoord2i(0, 0);
  27.   glVertex3f(0, 0, 0);
  28.  
  29.   glTexCoord2i(0, fTexture2.Heigth);
  30.   glVertex3f(0, panel.Height, 0);
  31.  
  32.   glTexCoord2i(fTexture2.Width, fTexture2.Height);
  33.   glVertex3f(panel.Width, panel.Height, 0);
  34.  
  35.   glTexCoord2i(fTexture2.Width, 0);
  36.   glVertex3f(panel.Width, 0, 0);
  37. glEnd;
  38.  
  39. // Deactivate Blending
  40. glDisable(GL_BLEND);


And this for the OnTimer.
Code:
  1. if fBlendDir then begin
  2.   fBlendFaq := fBlendFunc + 0.025;
  3.   if fBlendFaq >= 1 then
  4.     fBlendDir := False;
  5. end else begin
  6.   fBlendFaq := fBlendFunc - 0.025;
  7.   if fBlendFaq <= 0 then
  8.     fBlendDir := True;
  9. end;


fBlendDir is an Boolean and fBlendFaq is single. fBlendFaq should change from 0 to 1 and elsewhere. So you should see an smooth blending over the images.

Please initiale BlendDir with True and BlendFaq with 0. And make sure you dosn't use the Depthfunc. Use FormCreate after you have created the OpenGL context.
Code:
  1. fBlendDir := True;
  2. fBlendFaq := 0;
  3. glDisable(GL_DEPTH_TEST);


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 21, 2006 14:43 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
I've told you something about "texturemanager" in the very first post. Maybe now it's the right time to write one.

A texturemanager has 2 main goals: 1. avoid long load times, 2. make texturusage as confortable as possible.

An idea for an texturemanager could be:

A class wich has 1 main function: "BindTexture(string name)".
This function does the following:
- checks if the texture was loaded bevor
- if no, it loads the texture and stores it in a list
- binds the texture


So when you whant to use a couple of textures you just have to write bindTexture("myTex.jpg"). Isn't this easy?
You even can tune your menager and sort the list of textures by the time they where used. So the recently used textures are the first in the list. This will speed up the search for existing textures.
Or you can limit the length of the list. So only X textures are resident in memory at the time. All odd textures a freed.

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 21, 2006 16:46 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
I have some undefinied variable or function(?)
"fBlendFunc" is undefinied.

I cannot see any increment to this variable in the code where
it is increased/decreased.

About texture manager:
Yes. Thank you for this suggestion. I intended to write it too.
I hope i can make it in Delphi.
I'm writing in C++ Builder , but luckily Delphi is pretty similar.

I wish to make some kind of animation from pictures.
I wish to have smooth video clip effect.
These images will be like frames from movie.

I was thinking about this idea long ago, but now i have time to play with this.
and.. luckily i have found this forum and people who really help me!!


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mär 22, 2006 09:35 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
hello?:)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mär 22, 2006 09:59 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Yes. It was my mistake i mean fBlendFaq. Replace fBlendFunc with fBlendFaq and then you should have an smooth animation.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mär 22, 2006 10:15 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
wow. GREAT. what an effect!
Thanks so much!


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mär 25, 2006 17:12 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
Hello

I have some more questions and i kindly ask you to answer:)


Are JPG textures being uncompressed in memory?

i have loaded 20 x 900KB jpg bitmaps to memory using:

Code:
  1.  
  2.    private
  3.    mytextures: array[0..100] of TglBitmap2D;
  4.  


it takes enormous amount of RAM, like 150- 500 MB \":)\"
How to pack this in memory or force OpenGL to work on
compressed textures?

I have found:
tf32Bit tfCompressed = is there a way to decide on the compression ratio?
Beautiful images after setting tfCompressed become low quality.

I have found 2:
using TMemoryStream table [0..100] to load textures during FromCreate and then
loading textures from stream every time new frame is needed ( in onTimer Procedure)
makes framerate much slower like 3 fps. I have Athlon FX55 + 1 GB of DDR400 running 6.2 GB /s

I'm thinkig what to do..

huge memory consumption vs less memory consumption but slow speed

I must be conceptually doing something wrong...

2.
Changing opacity of application
Code:
  1.  
  2. Form1.AlphaBlend:=true;
  3. Form1.AlphaBlendValue:=0;
  4.  


causes error that "texture must be .. of 2"

I thought it would be cool to have transparent Form1 and only display pictures
in the OpenGL window.. but that error above..


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Mär 26, 2006 10:08 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
2. Yes. Thats right. Wehne you use AlphaBlend you will loose your Hardwaresupport of OpenGL ans all is rendered with the micosoft implementation. An these sucks really. So dont use AlphaBlend

1. These Textures are Really Big. You cant load all Textures at the same time. As JPG they are really small but in the Memory they where like BMPs. The Compression of OpenGL ist an lossycompression but dont compareable with an JPEG. The Image will only reduced to 1/4 or 1/8 of there initiale size. When you set the Format ftCompressed they will compressed. If supported.

I think you should try to reduce the Size of the Images. Or loading smaler tiles. And the important thing is to load the Textures if you need them. But dont load it every frame. This isnt a really practice and you see its really slow.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Mär 26, 2006 11:38 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
I have run some tests.

1. When i load all jpgs to an array[0..100] of TglBitmap2D it works like a THUNDER.
but memory? usage 200-400 MB of RAM.
For me it would be ok, but i wanted to show this to other people with slower PCs.
How it is possible that 500KB images, 12MB total size uncompress to 200-300MB of RAM. strange.
Even if i had 30 frames, 4 MB per bmp it would end in 120MB of used memory.
But where are the remaing 200-300MB of RAM? Do you have any idea what is going on?

2. When i load jpgs only when i need them, straight from TMemoryStream array or disk, my program takes max 20-40 MB of RAM which is
acceptable, but the speed of "animation" is sloooow.

I even tried preloading 20 frames ahead when current frame is 20,40,60 so it would slow down during certain
frames only and take less memory, but it is not easy to implement.

Is there any other way to load textures to memory without them being uncompressed to .BMPs ?

Also do you know if DirectX technology could make these things faster when all images are loaded as textures??

What speed & ram usage would be in DirectX ?

I'm curious if DX works differently in this topic.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 08:14 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
In DirectX i think you have the same Problem. This is not an problem of OpenGL. Its an problem of your data.

The images on your disk are very strong compressed, but when you load it the image must be uncompressed. Thats the reason why the images gettting so big. When you load them with an Memorystream you only copy the data of the files into memory. When you load them they also must be uncompressed. And the uncompressing takes some time. I don't know why the size is 200 MB instead of 120.

You must reduce the resolutions of the images. To reduce the quality a little bit is the only way to get an compromis between speed and memory usage. When the images are smaller you can load them at the startup and you will be happy.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 10:15 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
900KB ... Thats huge! (for an JPG-image)

I think Lossy is right. But the preloading could help you, too. If you just whant a dia-show or something, it would be enough to load the one more picture as you need.

The windows picture Viever does this, too. But they store the pics in the RAM. I don't know how they do this, without trashing the whole RAM.

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 10:34 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
I am thinking of creating multithreaded application to test preloading.

When for example i try to load 1 or 2 frames ahead, the program will by locked anyway
.. no matter if i load 1 or 5 frames.

This then should probably be done in separate thread/threads with value set in main thread so the main
program should wait till some frame thread completes.

but this is a little complicated;)

It is a big surprise for me that even 400KB jpeg x 20 frames causes program to take 300MB of RAM.
it is unbeliebable even if it uncrompress such frame 20x.

Do you have your own idea how to make frame preloading?
I think the best way to begin is to store all jpgs in TMemoryStream

then it should do some things with frames in 30ms OnTimer event

Tell me if you have time to talk with me. I do not wish to interrupt your work.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 11:03 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Now let us cut for a moment. We dosnt know whats your plan is. Explain it to us, please. What kind are these pictures? What resolution they have? And the important thing. What picture changing frequency you want to use?

I think the images came from an digitalcamera. They must have an resulotion of 2048 * 1536 or something in this region. When you want to draw these images on an cube in the middel of the screen the image will only take max 1024x1024 pixels.

For understanding. The jpeg is an compression angorythm that based on looseness. You can create jpgs with 2048*2048 pixel that only use 20kb of disk space. But when you want to use ist as textur i requires 12 mb of memory. When you strip down the resotution to 1024*1024 it will only use 3 mb.

It may be that you graphics card hasn't enough memory so they can't upload all images. When this happens opengl stores thes images in the clientmemory. When you also hold the images in an memory you doubled the memory usage. Normally the glBitmap shouldn't hold the data. After GenerateTextures they will free the memory.

For threadings. Not to fast please. if you wants to draw 20 of these images in an second so i can told you that dosn't work. The decompression of an jpg takes some/much time.

To reduce the resolution of the images you also can load the images into an TBitmap or TJpegImage an resample it. And from an TBitmap you can load it to the glBitmap to use is as texture. But this depends on your plans.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 11:21 
Offline
DGL Member

Registriert: So Mär 19, 2006 12:30
Beiträge: 29
My plan is to animate digital camera images like you said.

One can think - borrow 1080P camera to do the trick, but...quality of digital camera is what i need.
Operating on 2000x1500 is crazy like you said, but i wanted to test my PC to its limits;)
I need to use 1600x1200 images.

I think i will end up using TMemoryStream and slower speed, but less system resources.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 12:26 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Im wrong. I have tested some bit an i mean i have some bottle necks found. The Laoding of an jpeg is quick. Such 1-3 ms if windows had the data in the cache else you need 50 ms. This is an fact you can turn of with threaded loading in an memorystream. The biggest thing is to transfer the data into an Bitmap so i can load it with my glBitmap. This takes about 350 ms and this in an really Problem. This is an fact that slows down the whole pc.

The real quick imageviewer irfanview needs abou 200ms to load an jpg. For 5fps its an little bit to slow. I don't know any faster way to load the images.

The transfer to opengl is real quick. Sometimes. When i using texture_2d as target they takes 500ms but i have an really old driver and the support of non power of two texture are really bad. With texture_rectangle as target the image is transferes within milliseconds. Nothing to talk about it.

The problem with the jpg conversion is really bad because its to deep to change it. With gdi you have the same problem. I don't know how i can speed up this.

Sorry that i dosn't have an better answer for you.


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 61 Beiträge ]  Gehe zu Seite Vorherige  1, 2, 3, 4, 5  Nächste
Foren-Übersicht » English » English Programming Forum


Wer ist online?

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.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.010s | 14 Queries | GZIP : On ]