#### Archived

This topic is now archived and is closed to further replies.

# Texel/Pixel conversion?

This topic is 5853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am making breakout, and I have my paddle, ball and block textures on a 256 x 256 bmp texture and. The image is 120 pixels wide and 20 pixels long, so since the U and V coords have to be between 0.0 and 1.0, I use a triangle strip and calculate my four coords and my texture for the paddle is in the top left corner of the 256x256 texture, so my array is as follows: coord1: x = 290 y = 570 u = 0.0f v = (20.0f / 256.0f ) coord2: x = 290 y = 550 u = 0.0f v = 0.0f coord3: x = 390 y = 570 u = 100.0f / 256.0f v = 20.0f / 256.0f coord4: x = 390 y = 550 u = 100.0f / 256.0f v = 0.0f The U and V calculations are the 100 wide by 20 tall texture segment in the 256 x 256 texture, but for some reason, the paddle doesn't come out quite right. Any ideas on what I'm doing wrong? Is there a better way to do coordinates on a texture? Much greatness is achieved thru perseverance and faith. [edited by - Paladin__ on November 4, 2002 4:09:06 PM]

##### Share on other sites
Do I lose graphic quality when the app goes fullscreen? Could this cause the distortion?

I tried bilinear filtering, and it looked better, but blurry.

Any other advice on texel/pixel conversions?

Much greatness is achieved thru perseverance and faith.

[edited by - Paladin__ on November 4, 2002 4:09:57 PM]

##### Share on other sites
Try the triangle filter for best effect.

##### Share on other sites
or you could use directdraw...

___________________
~Analazon

##### Share on other sites
Sorry, I''ve been studying Direct3D for so long that I want to start 2D with Direct3D, so that I can make 3D games as well as 2D games and be well versed in the Direct3D area of study.

I have nothing against DirectDraw, but I don''t care to learn it when I can accomplish the same with Direct3D and have the avenue open to do 3D if I''d like.

Much greatness is achieved thru perseverance and faith.

##### Share on other sites

I've struggled much with this problem in the past. Other GameDev'ers helped me out with mine, so I'll pass along what I learned from them.

(1) Turn off all filtering before rendering your textures. So:

    g_pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_NONE );g_pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_NONE );g_pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE );

(2) Offset the x and y coordinates of your triangles' vertices by -0.5 so that the rasterizer has an easier time of translating texture pixels ('texels') to screen pixels.

So, using your example, coord1 should become:
x = 289.5
y = 569.5

I didn't go over your uv values with a fined-tooth comb, but you appear to be using the right calculations for those values.

Finally, you are using transformed vertices, not untransformed vertices, right?

Without seeing an actual image of the results you're getting, I can't offer much more than that. Good luck!

--Hoozit.

----------------------
Check out my game demo and resume at
www.fivestory.com/projects/game.

[edited by - HoozitWhatzit on November 5, 2002 1:54:47 AM]

##### Share on other sites
Thanks HoozitWhatzit, I''ll give that a shot after work. I AM using transformed vertices, so hopefully this is all I''ll need.

I did read about subtracting 0.5 finally, and my problems are down to one row of pixels on the first row turning on and off based on the position of my paddle.

I will try the filter thing when I get home and see if that helps.

How does this affect when my ball moves? Since the left screen is at 0.0, won''t I have issues when my ball tries to bounce off of that? (Guess I''ll either bounce 0.5 inside the border, or 0.5 outside).

Much greatness is achieved thru perseverance and faith.

##### Share on other sites
quote:

How does this affect when my ball moves? Since the left screen is at 0.0, won''t I have issues when my ball tries to bounce off of that? (Guess I''ll either bounce 0.5 inside the border, or 0.5 outside).

That would probably be the solution; although, if the ball is moving fast enough, no one will notice if you don''t align it!

--Neil.

----------------------
Check out my game demo and resume at
www.fivestory.com/projects/game.

##### Share on other sites
ok, works for me, thanks for your help.

Nice site btw. Played your demo game this morning. Very well done.

Much greatness is achieved thru perseverance and faith.

##### Share on other sites
If it looks okay in Windowed mode, and not in fullscreen. try checking what colors your using in Fullscreen.
For example, if your using 32 bit on your desktop, your program will use 32 bit if your running windowed. But fullscreen might only use 16 bit, that can be your problems.

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633308
• Total Posts
3011294
• ### Who's Online (See full list)

There are no registered users currently online

×