Pixel perfect question

Blitz3D Forums/Blitz3D Programming/Pixel perfect question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This part, from the "buttons.bb"

Global GUI_cam_piv = CreatePivot()
EntityParent GUI_cam_piv,camera
PositionEntity GUI_cam_piv,-1,0.75,1


Global GUI_texture = LoadTexture("images/icons.png")

Global GUI_mesh = CreateMesh()
Global GUI_surf = CreateSurface(GUI_mesh)

	EntityParent GUI_mesh,GUI_cam_piv
	PositionEntity GUI_mesh,0,0,0
	ScaleEntity GUI_mesh,0.03125,0.03125,0.03125
	EntityTexture GUI_mesh,GUI_texture
	EntityFX GUI_mesh,1+2+32
	EntityPickMode GUI_mesh,2

Global GUI_pm# = 0.0625 * (1024.0/gwidth)
Global GUI_quad_size# = 1024.0/gwidth
Global GUI_icon_size# = 32 ; the pixel size of the icons.


I've worked out the scalings. So, using that code... you add a quad by:

add_quad(GUI_pm * b\x ,GUI_pm * -b\y,0,b\icon,0)


The parameters use the variable GUI_pm, which, when multiplied by your pixel value, give the co-ords in 3d, where to place the quad. The Y is minus because your using 3d co-ords mind, but they equate to 2d co-ords.

Now, this isn't 1 texel = 1 pixel. This is, 1 blitz unit, = 1 pixel. That's why the GUI_mesh is scaled. The last two parameters in that function are for choosing the texture co-ords, by passing an icon variable. The function will multiple that by 32, to get the image of the icon. Completely irrevant to what your wanting though :o)

Oh and:
Global GUI_quad_size# = 1024.0/gwidth


This part simply works out the difference in size, for my icons to appear the same size, regardless of the resolution. It would be the same if you were trying to draw a rect the same size in different resolutions. The scaling was based on a screen size of 1024x768.

Any questions on that code, feel free to post.