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?
blitting *itexture
-
- Posts: 13
- Joined: Tue Jul 19, 2011 10:17 am
- Location: Eindhoven, NL
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: blitting *itexture
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.
-
- Posts: 13
- Joined: Tue Jul 19, 2011 10:17 am
- Location: Eindhoven, NL
Re: blitting *itexture
Hi hybrid, I mean something like: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.
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?
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: blitting *itexture
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?
Is that really what you meant?
-
- Posts: 13
- Joined: Tue Jul 19, 2011 10:17 am
- Location: Eindhoven, NL
Re: blitting *itexture
Hi hybrid, no, not really. I'm using 2D not 3D. Here it is now: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?
1) The irrlicht window is created
2) The image is placed in memory
3) The image is drawn via the video driver
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.
Re: blitting *itexture
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.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: blitting *itexture
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.
Re: blitting *itexture
I too have missed a simple blit function between two ITextures.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: blitting *itexture
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.