..drawrect with texture UV..

BlitzMax Forums/BlitzMax Programming/..drawrect with texture UV..

Naughty Alien(Posted 2010) [#1]
..how to draw specific part of texture, based on UV, on to DrawRect with given size?? I want to use it for my bitmap font system, so im wondering, how should i slice piece of bitmap(font bitmap) based on UV i provide and draw that over DrawRect ?


slenkar(Posted 2010) [#2]
my unofficial glmax2d in the code archives can do that

its also got a font bitmap system and you can do gradients on text


Naughty Alien(Posted 2010) [#3]
..do you mind to provide link, please...I wanna try and see how it goes..I have done it with quads, but unfortunately, i have some issues with engine, when turn on postprocessing, and i cant figure out whats the catch, so i wanted to try with plain Bmax commands..


slenkar(Posted 2010) [#4]
http://blitzbasic.com/codearcs/codearcs.php?code=2612


EOF(Posted 2010) [#5]
Nice code Slenkar!

I have tided it up a bit and fixed a few bugs. Do you know how to implement the GLZoom feature?


NOTES:
1) Import bah.libxml commented out so that you don't need extra libraries
Also the LoadImageFont() block is commented out
DrawText is still usabe. It will fall back to using the GLDrawText helper function

2) DrawRect and DrawOval both have an optional flag for drawing hollow or solid (default) variants. I replaced DrawCircle with DrawOval to match the BlitzMax command

The only other thing I want to see is SetLineWidth but I don't know much about OpenGL
DrawPoly() should be easy enough to add





slenkar(Posted 2010) [#6]
thanks for adding glzoom,

couple of questions out of curiosity

1.why does loadanimimage do 'resetverts'?
2.why is loadimagefont remmed out?
3.why is the module command commented out?

good job overall just wondered about those points before i copy and paste it to the code archives


EOF(Posted 2010) [#7]
Hi Slenker,

thanks for adding glzoom
I haven't added a GLZoom (I would not know how to) but was hoping you or some other GL Wizard could implement this one.


1.why does loadanimimage do 'resetverts'?
It's just a handy way of reducing the code, since there was a duplicate block of code there doing exactly the same thing as LoadImage, CreateImage (that is, setting up the verts as 0,0,imagewidth,imageheight)

2.why is loadimagefont remmed out?
This just allowed me to get the code running without having to rely on exteral 3rd party libs

3.why is the module command commented out?
I have no minGW installed so cannot re-compile as a module. Instead, I save your code as "uGLGraphics.bmx" then import and go ..
' Unoffical OpenGL graphics test

Strict
Framework BRL.Blitz
Import "uGLGraphics.bmx"

InitGL 400,300,0,20  ' windowed at 20 FPS



N(Posted 2010) [#8]
Why don't you just use DrawSubImageRect and convert your UV coordinates to image coordinates?


slenkar(Posted 2010) [#9]
ok i copied the code over to the archive