glTextures or not?

Started by
3 comments, last by nplex 16 years, 2 months ago
i'm not exactly familiar with the benefits of using glTextures... at the moment i've developed various applications which do image manipulation and particle motions and haven't really come to see a reason to use gltextures. despite what i think because obviously i could be wrong, since so many people do use them i figure there must be a reason. is there a performance benefit or something to using textures? also, soon i plan on taking advantage of shaders in my graphical applications through which i'm learning a lot of stuff in mathematics. and from what i read in studying in to gpgpu is that the mentality the programmer should take is that all information is processed in the format of a 2d array versus a 1d array on cpus. (i hope i didn't recite this incorrectly.) so i can see how it would be convenient to use textures since maybe the full screen of information will be already formatted correctly? ... is it then only a convenience? or is there a performance gain? i'd love it if someone could say a few things on the subject to help me understand clearer. thanks a bunch!
Advertisement
The big advantage is that you can keep images resident on the video card. This helps when you are redrawing a 3MB image 60 times a second as you do not eat up all your bus bandwidth. Another nice thing is that you get bilinear and trilinear filtering for free.

And yes, you can address the the texture as a 2D array, though i clearly remember doing this on the CPU as well.
just to clarify what i meant MaliciousDigit

what i meant is that the cpu doesn't process information as a '2d' object, it's translated to N[2*W+H] (1d array), etc for nD arrays.

i read this is the reason why you don't need to loop through each x and y coord on a gpu because it's physically designed to be a '2d information processing architecture.' (or how ever you want to say it.)

cpu : for(int x=0; x<width; ++x) { for(int y=0; y<height; ++y) { math } }

gpu : math

if anyone's still confused about what i meant i'll just go find a citation.


but what about if i'm drawing particles on a 2d plane constantly? not rendering a '3mb image,' what if i'm drawing a thousand points in different places all of the time, should i still worry about glTextures? or just keep going as i am and just work on using gpgpu?

i ask because i read about people "drawing to textures" and i don't understand why they draw triangles and stuff to glTextures, can someone explain the reason behind that?

is it for the bilinear and trilinear filtering?
The reason for drawing to a texture would usually be so it could be wrapped around geometry like a regular texture very easily. For example, you may draw the scene onto each of the faces of a cube map for dynamic environment mapping, or use it to create an image of a character on a virtual TV screen.

If you're not using textures what are you using to draw images? If you're using glBitmap or glDrawPixels, that is very inefficient for real-time rendering, because the image data has to be taken from the system RAM (usually slower than video RAM which may be something like 2GHz) and passed to the graphics card over the CPU bus. However, with textures residing on the VRAM, it simply goes from VRAM to GPU.
I do this;

glBegin(GL_POINTS);
glColor4f(r, g, b, a);
glVertex2f(x, y);
glEnd();

is this also inefficient for real time rendering?

does it make sense when i say i want to do the math on the gpu and have the results effect how i draw points on the screen this way? or is that not the 'way it works'?

This topic is closed to new replies.

Advertisement