playMaker

Author Topic: [SOLVED] Draw Texture anomaly  (Read 1111 times)

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
[SOLVED] Draw Texture anomaly
« on: July 09, 2014, 08:21:26 AM »
I'm encountering an anomaly when using Draw Texture to change my in game reticule between 2 states.

I have 2 GUI textures defined, both 64x64.

I draw them both to 0.5 left / 0.5 top, normalised, so that they'll appear in the screen centre. And I swap between them contextually.

One texture is scaled to 0.005 size, the other to 0.05 size.

The first displays completely correctly. I can tell this because it's on screen position matches the target of a ray I cast out of the camera. The second texture however always appears offset slightly to the right of the screen centre.

I've tried changing the source texture itself, both centring the graphic in the middle of the image and left and right justifying it. Nothing seems to fix it. The second reticule is always offset from the first.

Any idea what I might be doing wrong?
« Last Edit: July 09, 2014, 09:05:45 AM by HiFiHair »

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
Re: [SOLVED] Draw Texture anomaly
« Reply #1 on: July 09, 2014, 09:07:43 AM »
I figured it out.

The position coordinates define the top left edge of the GUI texture. I have to deduct half it's relative width from the position for the texture to be centred.

So...
For the reticule sized 0.005x0.005 I use screen position 0.4975x0.4975.
For the reticule sized 0.05x0.05 I use screen position 0.475x0.475.

This seems to have aligned everything perfectly.