• Advertisement

Archived

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

Stars and such

This topic is 5742 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

I''m probably gonna sound like an idiot, but here''s my problem anyway: I want to make a scrolling starfield (with stars at different depths) where stars that reach the bottom of the screen loop back to the top to make it seem like it is scrolling forever. My problem: is there a way to implement this in Direct3D 8 without constantly locking and unlocking a vertex buffer filled with the coordinates of the stars? Things are not what they are.

Share this post


Link to post
Share on other sites
Advertisement
Well, you could use matrices (assuming you're using untransformed coordinates). Just have a single star that you draw many times at different positions (or a set of stars, each at different depths).

But personally, I'd just go with the lock - you'll only need to lock the buffer once per frame, which shouldn't kill performance (much), and you'll then be able to draw all the stars with one Draw[Indexed]Primitive call, which is good (in theory, if you call Draw[Indexed]Primitive with anything less than 200 vertices/indices, then it will take just as long as if you had drawn 200 verts)

EDIT:: This may have been better in the DirectX forum.

Hope that helps,

John B

[edited by - JohnBSmall on May 31, 2002 4:50:54 PM]

Share this post


Link to post
Share on other sites
Imagine a tape twice as wide as your screen, and the screen moving along that window, jumping back to the beginning when it reaches the end. (screen pos = fractional part of ( Xgame / screen width ))


------------------------
* | * * | * *
|* * |-> * *
| * * |* *
------------------------


The stars will appear to move from right to left. To avoid a discontinuity when you go back to the beginning, make it so the 'left screenful' of the tape is the same as the 'right screenful'.

To do so, just render your stars twice, one being translated by the width of the screen. Now, you move the screen along this track by doing an appropriate translation (-Xpos of the screen) before starting to render the stars.

Hope it was clear. Your star coordinates never change, you just move the 'view window'

Edit: clarified the 'render twice'

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on May 31, 2002 5:43:30 PM]

Share this post


Link to post
Share on other sites
Thanks a lot for the replies.

Fruny: That's a great idea. Thanks.

Things are not what they are.


[edited by - myme15 on May 31, 2002 5:40:48 PM]

Share this post


Link to post
Share on other sites

  • Advertisement