• Advertisement

Archived

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

Strange problem tiling using D3DX

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi again, I''m really stuck now. I have my tile routine up and running, but it seems to display the first tile in the top left corner, and then it skips a tile. Very strange! I''m cutting all my RECTs properly and it''s really drivin'' me nuts! I''m using 64x64 tiles... I see the first one in a rect of (0,0,63,63), and then then one that is supposed to be right to the right of it should be the original rect of (64,0,127,63) but it''s actually (128,0,191,63)!! Has anyone had this problem before or am I just a complete moron here...? Much Thanks.. Anthony

Share this post


Link to post
Share on other sites
Advertisement
I''m not exactly sure what you''re saying. So, if you wouldn''t mind, could you send me the .exe. I can''t program this stuff, but I may be able to understand what''s wrong.

"Remember, I'm the monkey, and you're the cheese grater. So no messing around."
-Grand Theft Auto, London

"It's not whether I win or lose, as long as I piss you off"
-Morrigan, Super Puzzle Fighter II Turbo

Share this post


Link to post
Share on other sites
Without seeing your code I can''t find it for you. But I can tell you how to find the problem. It seems that you are doing an extra increment at the beginning (most problems occur at the beginning or end), in order to find out what is happening, try stepping through your code. Obviously this won''t work if you are working with fullscreen and don''t have multi monitor support. So... Print out your main variables into a file at critical sections in the code to see where the unwanted change is occuring.


Rock on,
- Tom

Share this post


Link to post
Share on other sites
Post up the section of the code that cuts up your bitmap into RECT''s for blitting. It''s probably just a silly arithmatic mistake. I hope you figure out what''s going on.

Martin

Share this post


Link to post
Share on other sites
OK. The spacing might get a little messed up here, but I''ll try my best to get the indents looking good. Here''s what I have so far... this portion of code creates new nodes in the linked list. Each node in the linked list holds an individual 64x64 texture. The AddTexture function is listed below this code segment.

// Loop and create textures cutting from the proper RECTs
// (XCount and YCount are the tile numbers)
for (YCount = 0; YCount < TexDown; YCount++)
{
for (XCount = 0; XCount < TexAcross; XCount++)
{
if (IsEmpty()) {
texhead = new TextureNode; textail = new TextureNode; hErr = texhead->AddTexture(lpdd, lpd3d, szImage, &XCount, &YCount);
if (FAILED(hErr))
return(hErr);
texhead->SetNext(NULL); textail = texhead; }
else
{
TextureNode *temp = new TextureNode; hErr = temp->AddTexture(lpdd, lpd3d, szImage, &XCount, &YCount);
if (FAILED(hErr))
return(hErr);
temp->SetNext(NULL); textail->SetNext(temp); textail = temp; }
}

-------------
// Here''s the AddTexture function that loads the a specific
// RECT from the bitmap

HRESULT TextureNode::AddTexture(LPDIRECTDRAW7 lpdd, LPDIRECT3DDEVICE7 lpd3d, LPSTR szImage, __int8 *tilex, __int8 *tiley)
{
// LOCAL VARIABLES
HRESULT hErr; // error handler
CHAR LogoFile[100];
RECT srcRect;
RECT destRect;

destRect.left = 0;
destRect.top = 0;
destRect.right = 64;
destRect.bottom = 64;

// Store this current tile X and Y number in our node variables
TileX = *tilex;
TileY = *tiley;

// Create the texture
// I tried using the D3DXCreateTexture call and I got so many DDERR_UNSUPPORTED... so I''m stuck with this call... very wasteful

sprintf(LogoFile, "%s%s", "c:\\raovios\\graphics\\other\\", "blanktex.bmp");
hErr = D3DXCreateTextureFromFile(
lpd3d, NULL, NULL, NULL, NULL, NULL, lpddsTex, NULL, LogoFile, D3DX_FT_DEFAULT);
if (FAILED(hErr))
return hErr;

// Get our bounding box to cut from ready
srcRect.left = (TileX * 64);
srcRect.top = (TileY * 64);
srcRect.right = (srcRect.left + 64);
srcRect.bottom = (srcRect.top + 64);

hErr = D3DXLoadTextureFromFile( lpd3d, lpddsTex, D3DX_DEFAULT, szImage, &destRect,&srcRect, D3DX_FT_LINEAR);
if (FAILED(hErr))
return hErr;

return S_OK; // Success.

}

-------------

I really don''t know why I couldn''t use the D3DXCreateTexture function. That was also very strange. If it would be more helpful to but an image online of what it''s -supposed- to look like and the way it''s showing up, let me know and I''ll post it ASAP.

Again - thanks.

Anthony

Share this post


Link to post
Share on other sites

  • Advertisement