Archived

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

JWalsh

D3DXSprite or mapping mode problem

Recommended Posts

JWalsh    498
Heya, Ok, here''s my problem; I''m writing a Pong tutorial called GDPong that utilizes DirectX 8.1. I decided to use the D3DXSprite functionality and just blit to the screen. The problem I''m having is that the image of the paddle is 200 pixels tall, and the client rect is set up to be 600 pixels tall, but when I set 3 paddles next to each other in sequence they dont add up to 600. You''d think that if the paddle is 200 tall, then when I position the top left corner at 400, it would touch the end of the client rect, instead it goes well beyond. I thought this would be due to the fact that the menu, etc...at the top subtracts from the client space, but that''s not the problem. As I said before I can draw the first box at 0,0 and then I can draw the next box at like 25, 200 and the second paddle actually starts about 3/4 of the way through the first. Let me know if you have any ideas or suggestions, I''m tapped out. Here''s some quick code to see how I''ve set things up: // Client initialization g_hWnd = hWnd = CreateWindow( szAppName, "GDPong Version 1.0", WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME ^ WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 806,629, NULL, NULL, hInstance, NULL); // Direct3D initialization ... D3DPRESENT_PARAMETERS dpp; ZeroMemory(&dpp, sizeof(dpp) ); ... dpp.Windowed = true; dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; dpp.hDeviceWindow = g_hWnd; dpp.BackBufferFormat = dm.Format; ... // Sprite and Texture intialization D3DXCreateSprite(g_pD3DDevice, &g_pSprite); D3DXCreateTextureFromFile(g_pD3DDevice, "paddle.png", &g_ptPaddle); D3DXGetImageInfoFromFile("paddle.png", &g_ImageInfo); // Drawing the image g_pSprite->Draw(g_ptPaddle, NULL, NULL, NULL, 0, &Player.pos, 0xFFFFFFFF); Best Regards, Jeromy "Maverick" Walsh ------------------------ "The question isn''t how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" -Boondock Saints

Share this post


Link to post
Share on other sites
JWalsh    498
I found the problem. The D3DXSprite interface takes a pointer to a texture. All textures must be a power of 2. Since mine were not, they were being scaled to the next larger power of two.

Best Regards,
Jeromy "Maverick" Walsh
------------------------
"The question isn''t how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" -Boondock Saints

Share this post


Link to post
Share on other sites