Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Another flag to Gosu::Image creation to handle it single
- - By bestguigui Date 2015-09-27 09:52
Hi Jlnr !

Would it be possible for you to add a flag to the options, when we create a Gosu::Image, so that Gosu handles it as a single OpenGL Texture, and not optimized in a mixed 1024² texture ? Because if your current way is really good when we use the left/right/top/bottom methods, it's not easy to specify :
- a portion that is different of one tile size
- to repeat a texture (impossible in fact, we have to add some geometry to handle it, or maybe I miss a way to do it).

For example, we're working with a woman on a map editor, and we have a spritesheet where we want to be able to pick a rectangular (not necessary square) selection of tiles, to handle it as a single 3D sprite. We provide to the user a pixel based selection, so for example we could take 24*16 based anywhere on the spritesheet, so we can't use Gosu::Image.load_tiles for that. We would rather go with and want to specify a special portion of it to display a really specific quad. So we need to provide opengl with coordinates from 0.0 to 1.0, not from gl_tex_info.left to gl_tex_info.right, for example.

Using Gosu::Image#to_blob, I managed to recreate the texture, but it takes some time on launch, so maybe it would be a lot more efficient if Gosu could load it like this directly if asked on the options.
Parent - - By jlnr (dev) Date 2015-09-27 17:38
I've created a new GitHub issue here:

But here's a workaround you can try in the meantime:

If you load the image using, then use image.subimage(x,y,w,h) to create a Gosu::Image representing a portion of the image, and then call gl_tex_info on the new (sub-)image, you should get the correct u/v values (0.0 to 1.0) in .left/.right/.top/.bottom.
You only need to take care not to create an image >1022x1022px with, because when an image is split up across several textures, subimage and gl_tex_info won't work.
Parent - - By bestguigui Date 2015-10-03 15:18
Hi !

The problem with your solution is that you handle my issue during the loading phase. What I would like is to handle the size in the actual drawing, so that I can load my texture as a whole single image, and then to draw it on irregular not square portions. :)

I don't want to create sub images, but rather drawing the same cropped / doubled and so on.
Parent - By jlnr (dev) Date 2015-10-03 16:31
Creating subimages is probably cheap enough that you can do it in every tick. Images are not much more than a refcount to the texture, plus u/v values.
Doubled is not possible right now, though :(
Up Topic Gosu / Gosu Exchange / Another flag to Gosu::Image creation to handle it single

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill