Archived

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

Sephwrath

2d in 3d. Wot's... Uh the deal

Recommended Posts

Hi. I''ve just started looking into porting my game from direct draw to direcxgraphics (dx8). And despite searching the forums I find I still have some questions. Ok first up,. currently I am trying to draw a large trinagle strip for each row of tiles. I figured this would be faster and someone said somewhere that if you store all your tiles in one texture then you can just change the texture choords to draw the different tiles using triangle strips. Ok sounds good in theory however I realised before I even started typing that unless I had some way of setting different texture coords for some vertexes; namely the ones in the middle ie beteen two tiles that there was going to be a horrid texture stretchy/warpy mess. So is there a way of doing this or do I have to resort to triangle lists or just use a triangle strip for one tile. Next question... Single-pass Multitexturing, is it no good for this sort of application? Because so far I havent heard of anyone using it. To do several tile layers it seems it would be faster than going through the tiles 2 or 3 times. My plan was to have several base tiles that are basically square 32*32 textures and then use another texture space(?) to store some alpha masks that I could use to blend them together, probably about 3/4 layers max. Obvoiusly this ould be quicker if I could texture each tile in one pass. What do you think will this work? Is there a better way? Thanks guys. Sephwrath.

Share this post


Link to post
Share on other sites
quote:
Original post by Sephwrath
Ok first up,. currently I am trying to draw a large trinagle strip for each row of tiles. I figured this would be faster and someone said somewhere that if you store all your tiles in one texture then you can just change the texture choords to draw the different tiles using triangle strips. Ok sounds good in theory however I realised before I even started typing that unless I had some way of setting different texture coords for some vertexes; namely the ones in the middle ie beteen two tiles that there was going to be a horrid texture stretchy/warpy mess. So is there a way of doing this or do I have to resort to triangle lists or just use a triangle strip for one tile.

The D3DPT_TRIANGLELIST is the only way to draw your row of tiles, with one call to drawPrimative(). With my project, Genus, I thought I would be funny and draw each tile individually as a trianglefan. But that's just me.
quote:

Single-pass Multitexturing, is it no good for this sort of application? Because so far I havent heard of anyone using it. To do several tile layers it seems it would be faster than going through the tiles 2 or 3 times. My plan was to have several base tiles that are basically square 32*32 textures and then use another texture space(?) to store some alpha masks that I could use to blend them together, probably about 3/4 layers max. Obvoiusly this ould be quicker if I could texture each tile in one pass.

Um... I don't think I understand- you want each tile to be a combination of multiple textures? I think this one might be a little over my head, because I see no benifit in doing it this way.
---email--- Tok ----surf----
~The Feature Creep of the Family~

[edited by - Tok on August 11, 2002 12:19:33 AM]

Share this post


Link to post
Share on other sites
Hello. Thanks for taking the time to reply.

quote:
The D3DPT_TRIANGLELIST is the only way to draw your row of tiles, with one call to drawPrimative().


Hmm I was afraid of that... My dreams of using large triangle strips have been shattered. Oh well.

The question about the multi texturing still stands. I know it can be done but is it a good thing to do in this sort of application. I mean the only other suggestion I have seen when using maps with more than one layer is to draw more quads over the top. I have about three layers in my game so surely drawing three times the quads would be a waste of time and space. If i could place more than one texture on the same quad and blend them using an alpha mask.

BTW I downloaded your game - looks like it could be fairly cool with a bit more work. However I have one piece of advice. Dont for the love of god use the windows messaging loop to get in-game user input, it''s bloody slow. Use either GetAsyncKeyState() or direct input. Only use the windows messaging for non time critical functions like pausing or exiting the game.

Thanks agian for the reply.

Sephwrath.

Share this post


Link to post
Share on other sites
quote:
Original post by Sephwrath
However I have one piece of advice. Dont for the love of god use the windows messaging loop to get in-game user input, it''s bloody slow. Use either GetAsyncKeyState() or direct input. Only use the windows messaging for non time critical functions like pausing or exiting the game.



Bad advice. GetAsyncKeyState() is the worst thing you can use for keyboard input. It does not allow multiple keypresses. The windows message loop works just fine for keyboard control, if it is done right. Or use DirectInput.

---
Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
You can change tiles using triangle strips. Make sure you generate degenerate triangles by changing texture coordinates but keeping the same vertex positions as you switch from one tile to another.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
quote:
Bad advice. GetAsyncKeyState() is the worst thing you can use for keyboard input. It does not allow multiple keypresses. The windows message loop works just fine for keyboard control, if it is done right. Or use DirectInput.


Point taken. However using GetAsyncKeyState() the way I have used it in the past (with multiple keys??) is works a hell of a lot better than whatever method he was using with the message loop (I played the game). And in the past when using the message loop I have found it to be slow as well. Granted using direct input is probably the sensible option how do you use the message loop right??

And back on topic - siaspete. Thanks. I'm not quite sure what you mean but I'll look into it.

Sephwrath.

///////////////////////////////////////////////////////////////
//edit
CaptainJester - I just found another post where you have answered the keyboard question so no need to worry I now know what you are talking about. I'll have to try it out.

Thanks

Sephwrath

[edited by - sephwrath on August 13, 2002 10:29:21 AM]

Share this post


Link to post
Share on other sites
Sorry if this is brief, but you''d render your triange strips like this...

http://www.opengl.org/developers/code/sig99/advanced99/notes/node18.html

Look at figure 10.

Draw 4 verts per tile (NOT TWO!) so the last vertices for one tile and the first vertices for the next tiles overlap. The invisible triangles that are generated are called degenerate because they don''t produce any visible pixels on screen. Ideal for hiding texture coordinate changes!

Hope this helps. This approach is also ideal for rendering text.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites