Texture Pointer?

BlitzMax Forums/MiniB3D Module/Texture Pointer?

BLaBZ(Posted 2012) [#1]
I have a pixmap I'm using for a texture that's constantly changing.(Same width/height just different RGBA values)

Is there a way to have a texture continually point to a certain pixmap?

So I don't have to keep calling "CreateTexture\LoadTexture"

Thanks


ima747(Posted 2012) [#2]
No. Textures have to be uploaded to the graphics card to be displayed, you can make changes in VRAM on the graphics card like you can to system memory.


SLotman(Posted 2012) [#3]
Have you tried altering TTexture.pixmap directly to see if changes show?
(It's just a regular bmax pixmap, so...)


BLaBZ(Posted 2012) [#4]
I'm don't known opengl from a hole in the wall, but I believe these two lines convert the pixmap to a texture

glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
				glTexImage2D GL_TEXTURE_2D, mip_level, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixmap.pixels


Do you know how I'd go about changing the texture in VRAM?


ima747(Posted 2012) [#5]
You can't change it in VRAM. That's the trouble with 3D acceleration, you don't have direct access to the back buffer or any other texture buffers.

You can do lots and lots of other fancy things, like render to a texture directly which is crazy fast... but you can't get pixel level access to anything on the graphics card, to change it at that level you have to change it in system memory and re-upload it to the graphics card (some of the key lines of which you've pulled out above).


AdamRedwoods(Posted 2012) [#6]
The pixel buffer is used to offer DMA access from memory to the video memory. It requires tapping into opengl extensions to get it working, so most likely opengl 1.5 or above.
http://www.songho.ca/opengl/gl_pbo.html


The alternative is to use glTexImage2D() and see how much it'll slow down the system.
You can use glTexSubImage2D() to modify only a portion of the texture, but requires knowledge of the pixel pitch.

Oh... in regards to miniB3D, it's pretty easy. just use the raw opengl calls.

local mytexture:TTexture = Load or whatever.
glBindTexture mytexture.gltex[0]
glTexImage2D(), etc..., pixmap.pixels

Last edited 2012