Archived

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

mickey

hello, tiling in d3d8, best way?

Recommended Posts

say i have a breakout clone? worst scenario is, each blocks is different.., so how can i improve this? for(x = 0; x < sizex; x++) for(y = 0; y < sizey; y++) { switch(map[x][y]) { case REDBLOCK: SetTexture(REDBLOCK) DrawBlock(...) // mesh block case BLUEBLOCK: SetTexture(BLUEBLOCK) DrawBlock(...) // mesh block case GREENBLOCK: ... and a dozen lot more! } } so ehm., best route to go for this? many thanks,

Share this post


Link to post
Share on other sites
Hi...

Hmmm.. Why not

for(x = 0; x < sizex; x++)
for(y = 0; y < sizey; y++)
{
{
SetTexture(map[x][y])
DrawBlock(...) // mesh block
}
}


// Javelin
-- Why do something today when you can do it tomorrow... --

Share this post


Link to post
Share on other sites
hiya, that won't work, coz SetTexture needs an address and i can't possible enum them,

but anyway, the problem is still there..,

additional question:

does lighting interfere with texture stage states?
why does my lighting goes away when i declare this stage?

SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );

what i have to do is, declare it like this
SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );

?? i thought TextureStageState job's is to manipulat the two arguments that you supply, ie, COLORARG1 and COLORARG2, ALPHAARG1 and ALPHAARG2?

many thanks,





[edited by - mickey on July 30, 2002 10:10:52 AM]

Share this post


Link to post
Share on other sites
create a list for all diffrent block types, each containign a list of blocks with that color.

then... (pseudocode )


      
for each blocktype
set blocktypetexture

for each block in blocktype
drawblock



the only problem is, that you will have to store coordinates if you''re depending on the x and y values of the two for loops, but It''s faster to do so. (you could pump them into vertex arrays and use indices for the blocks.. would speed things up even more

ok,
hope that helped,
cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states )

Share this post


Link to post
Share on other sites
I have coded a kind of sprite system that deals with that kind of problem.
I have two classes, CSprite and CSpriteList.
When I send a call to CSpriteList::Render the function will gather the transformed vertices of each sprite, group them by textures and render them.
But since I did not yet complete my text drawing function I have no idea if this method is good for performance.

Im Anfang war die Tat...
Faust

Share this post


Link to post
Share on other sites