blitting *itexture

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

blitting *itexture

Post by abrams.b.a »

Good morning everybody,

Does irrlicht have any sort of technique for grouping textures under one surface?

When working with SDL or pygame you blit the images to a surface, so if you have a map of tiles you can add the images to that surface and only have to worry about bliting that surface to something else. Though the only thing I've found is draw2dimage() where I'd have to pass each texture I want to draw every frame to that function.

For anybody that has already done something like this, what technique have you used, or is drawing only the active tiles each frame possible?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: blitting *itexture

Post by hybrid »

If you mean rendering many times different parts of a texture, you can use the draw2dimagebatch function. This takes one texture (atlas/sprite bank) and lets you render arbitrary parts defined via the rectangle list it also takes as parameter.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: blitting *itexture

Post by abrams.b.a »

hybrid wrote:If you mean rendering many times different parts of a texture, you can use the draw2dimagebatch function. This takes one texture (atlas/sprite bank) and lets you render arbitrary parts defined via the rectangle list it also takes as parameter.
Hi hybrid, I mean something like:
Image

I already thought about grouping the tiles together in sets of 5x5 or some size and deactivating the ones that aren't being rendered on the screen, but since I don't know of anything like the above, I'd have to call draw2dimage for each individual tile, I was wondering more or less of the idea of a surface exists in irrlicht?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: blitting *itexture

Post by hybrid »

To be honest, this explanation made things worse... This looks like you want to texture a plane mesh. Well, just do that. Create a plane mesh, set your texture in the matertial, render the plane. Should give you the results as shown above, assuming you use a texture scale of 2.
Is that really what you meant?
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: blitting *itexture

Post by abrams.b.a »

hybrid wrote:To be honest, this explanation made things worse... This looks like you want to texture a plane mesh. Well, just do that. Create a plane mesh, set your texture in the matertial, render the plane. Should give you the results as shown above, assuming you use a texture scale of 2.
Is that really what you meant?
Hi hybrid, no, not really. I'm using 2D not 3D. Here it is now:

1) The irrlicht window is created
Image
2) The image is placed in memory
Image
3) The image is drawn via the video driver
Image
Image

This is ok, but when I make a map of tiles for example, I have to call draw2dimage() each time to change the position of my map, and for what can be quite possibly over 100, this is a bit tedious. My thinking is if you've ever used SDL or pygame, when you want to place an image on the screen, you blit it. You create a surface and draw the texture to that surface. Then if you have lets say a handful of images on one surface, you only have to blit the bigger surface to move it around, or etc etc.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: blitting *itexture

Post by devsh »

you want to use a screen quad for that with UV coords bigger than 1.0, then the texture will repeat. Simple easy and HW accelerated properly.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: blitting *itexture

Post by hybrid »

You can also use the draw2dimagebatch function for this. It's perfectly allowed to render the same part many times. You can also create a 2d polygon and render it, which is mainly what the common screen quads do. Depends a little bit on the required flexibility. Since it looks like a pretty regular pattern, it's probably easy to calculate tex coords in case you need to replace certain tiles. However, your screen quad would have to provide enough vertices (at least as many as you have tile corners). With the batch render you're completely free, as you have source and destination rectangles. In case you really just want to fill the background, a single quad with texture repeat would be the simplest, though.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: blitting *itexture

Post by hendu »

I too have missed a simple blit function between two ITextures.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: blitting *itexture

Post by hybrid »

Though this is a very different thing than what was searched for in this topic. Well, blitting those parts into the texture would of course also work, but also waste tons of memory.
Post Reply