What is the fastest bitmap/texture to texture copy with stencil/Mask? - Graphics
This is a discussion on What is the fastest bitmap/texture to texture copy with stencil/Mask? - Graphics ; Hi all,
I'm an old C64 demo programmer (assembler) and I would like to program demos
on PC, using OpenGL.
I just a have one small question (for now).
What is the best way to do the following, regarding speed.
...
-
What is the fastest bitmap/texture to texture copy with stencil/Mask?
Hi all,
I'm an old C64 demo programmer (assembler) and I would like to program demos
on PC, using OpenGL.
I just a have one small question (for now). 
What is the best way to do the following, regarding speed.
I want to copy "sprites" from a bitmap or OpenGLTextures to another
OpenGLTexture, so I can use it in my scene. (Stencils/masks are a must)
I have looked at glCopyPixels and glCopySubImage2D.. Are there other
options?
I have read that TexturMaps can be copied into the fast memory on the
graphics card, true?
If true what "copy" commands work direct with this memory? (via the GPU)
What to use?
Hope someone out there knows what to use.
- Henning
-
Re: What is the fastest bitmap/texture to texture copy with stencil/Mask?
On 2007-09-11, Henning Mortensen <henning@mocka.dk> wrote:
> I'm an old C64 demo programmer (assembler) and I would like to program demos
> on PC, using OpenGL.
> I just a have one small question (for now). 
Welcome to the "modern" demoscene 
> What is the best way to do the following, regarding speed.
>
> I want to copy "sprites" from a bitmap or OpenGLTextures to another
> OpenGLTexture, so I can use it in my scene. (Stencils/masks are a must)
>
> I have looked at glCopyPixels and glCopySubImage2D.. Are there other
> options?
>
In general you want to avoid copying pixels around. Use textured quads
to place images on screen, and keep your images in textures. So just
load any images you may need on startup, keep them in textures, and work
from there.
You can't easily copy pixels between textures, but the need rarely
arises. What's very common though is to render into a texture. You can
either render regularly to the framebuffer and then do a
glCopyTexSubImage2D call to put the part of the framebuffer you want
into a texture, or render directly to a texture using either a
system-specific pbuffer approach (GLX. WGL, etc) or preferably the
GL_EXT_framebuffer_object extension, which is very versatile and nicely
designed in my opinion.
> I have read that TexturMaps can be copied into the fast memory on the
> graphics card, true?
> If true what "copy" commands work direct with this memory? (via the GPU)
Yes, texture maps are kept in texture memory (on systems that have it),
and can be used for texture-mapping primitives extremely fast. Also
copying the framebuffer to a texture with glCopyTexSubImage2D, does not
generally incur any bus-transfer penalties AFAIK.
P.S. since you're doing demo-effects, check out GLSL for programmable
pixel/vertex processing. You can perform many deformations, image
processing etc algorithms extremely fast, entirely on the GPU with them.
--
John Tsiombikas (Nuclear / Mindlapse)
nuclear@siggraph.org
http://nuclear.demoscene.gr/
-
Re: What is the fastest bitmap/texture to texture copy with stencil/Mask?
Henning Mortensen wrote:
> I want to copy "sprites" from a bitmap or OpenGLTextures to
> another OpenGLTexture, so I can use it in my scene.
> (Stencils/masks are a must)
I'd like to know, why you want to have redundant textures? I see
no real reason, why to have multiple textures with the same
content.
If you like to compose new textures, then of course it makes
sense and I can you suggest the use of glCopyTexImage if the
texture object hasn't been created yet. If you only want to
update glCopyTexSubImage easyly outperforms it.
And then there are of course Framebuffer Objects, that allow to
attach a texture as a framebuffer on which drawing operations
are performed (that texture cannot be used with that drawing
operations of course, that would be kinda an infinite recursion
then).
> I have looked at glCopyPixels and glCopySubImage2D.. Are there
> other options?
glCopyPixels, just like glDrawPixels is considered obsolete and
should no longer be used in new applications. And they're slow.
> I have read that TexturMaps can be copied into the fast memory
> on the graphics card, true?
> If true what "copy" commands work direct with this memory? (via
> the GPU)
All. OpenGL drivers will take care, that the textures are always
there, where they can be accessed most efficiently. Either way
you upload a texture, it will end up in fast memory.
The difference between the ways how textures can be uploaded is
in the speed of the upload. E.g. glTexImage is the slowest, as
the whole thing has to be prepared beforehand. And in most cases
properly used Pixel Buffer Object provide the fastest uploads,
though in some certain situations I reached top performance with
good old glTexSubImage.
Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith@jabber.org, ICQ: 134682867
-
Re: What is the fastest bitmap/texture to texture copy with stencil/Mask?
On Sep 11, 7:05 pm, "Henning Mortensen" <henn...@mocka.dk> wrote:
>
> I want to copy "sprites" from a bitmap or OpenGLTextures to another
> OpenGLTexture, so I can use it in my scene. (Stencils/masks are a must)
>
Look at the WGL_ARB_render_texture extension.
This allows you to use any OpenGL functions to
modify an existing texture.
--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.
-
Re: What is the fastest bitmap/texture to texture copy with stencil/Mask?
Hi all,
Thanks for the fast responds.
It seems that I still think too much in Pixel manipulation.. Just have to
get use to the optimized 3D hardware. 
If I do as you suggest and fx. use quads to display all my sprites, then
what is best?
One HUGE texture with all the sprites data (where I just have to get the
textur map coords in the right place) or hundreds of small textures with
individuale sprites?
Thanks again,
- Henning
-
Re: What is the fastest bitmap/texture to texture copy with stencil/Mask?
On Sep 12, 6:30 pm, "Henning Mortensen" <henn...@mocka.dk> wrote:
>
> If I do as you suggest and fx. use quads to display all my sprites, then
> what is best?
> One HUGE texture with all the sprites data (where I just have to get the
> textur map coords in the right place) or hundreds of small textures with
> individuale sprites?
>
Textures have size limits, 1024x1024 works almost
anywhere. 2048x2048 is risky (might not work on
some machines).
--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.
Similar Threads
-
By Application Development in forum Adobe illustrator
Replies: 8
Last Post: 06-28-2007, 06:36 AM
-
By Application Development in forum Graphics
Replies: 1
Last Post: 04-18-2007, 08:58 PM
-
By Application Development in forum Graphics
Replies: 0
Last Post: 12-28-2006, 07:29 AM
-
By Application Development in forum Graphics
Replies: 2
Last Post: 12-14-2006, 06:36 AM
-
By Application Development in forum Graphics
Replies: 2
Last Post: 09-18-2006, 07:22 PM