Jump to content
  • Advertisement


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


Dynamic Scrolling Surface using D3D8

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

Here''s what I''m trying to do: I want a scrolling 2D surface, implemented by a large surface where only a portion of the surface appears at one time. The surface needs be built on the fly every frame, or maybe upon initial creation of the surface. (I know how to do it using just a static image loaded from the hard disk.) This sorta thing is everywhere e.g. smoothly scrolling information in a window, etc. I''m not quite sure how to do this, but intuition tells me it shouldn''t be that hard. I''m guessing I can do it using ID3DXSprite and ID3DXSurface somehow? Maybe rendering to a texture? If anyone can tell me if I''m on the right track or point to some information on how to do this, that would be fantastic. I''ve searched the net for tutorials on how to do this and haven''t found anything, which is weird because it''s such a common feature with every UI. Anyways, thanks for your help guys, this one has been bugging me for quite a while.

Share this post

Link to post
Share on other sites
Here''s how I''d go about handling this:

At load time, render the surface you want to a texture, and make a quad big enough to hold your entire desired surface. (if you''re using text, this would have ALL the text in it, more than what''s visible at once).

Now, you could just use a transformation matrix to set the quad''s position and the bit of he surface will be rendered to it''s desired location.

The real trick is getting the rest of the surface not to show.

If you''re using a big graphic UI, which you render around the surface anyways, you could just render the surface first, and then the UI will just cover the bits you don''t use.

If you don''t, you could always just use clear to erease the parts you don''t want to show.

This poses no real problem unless you have two of these scroll boxes close enough to eachother that the unused part of one shows up over the other.

To solve that you could use Z-buffering but that would end up slowing it down quite a bit.

That''s my idea anyhow. Good luck .

Share this post

Link to post
Share on other sites
Oh, by the way, you could always use a quad which is the size of the desired scrollbox and then use the V and U atributes to change where the texture is drawn (I beleive it shouldn''t fold the unused parts back onto the quad). At any rate, since you''d only need to modify the V and U when someone scrolls, this method should provide better results when no one is scrolling, but slower results in the scroll itself. Also, it''s a bit more difficult to program.

Share this post

Link to post
Share on other sites
Careful now! There is one problem to using a texture ''large enough to hold your picture'' and drawing it: Many older video cards only support up to 256x256 pixels per texture, and newer ones are also limited. (albeit to bigger textures)

Making 2D with Direct3D is an art, a start would be to read this excellent article: http://www.gamedev.net/reference/programming/features/gui/

Now, I''ve taken the time to build a class that can load a very large BMP, and splits it according to a ''tile size''. (I used 256x256 to allow older cards to use my program) And when I rendered something, it wasn''t a quad with a texture, it was that class I made. The source of inspiration for that class was this guy''s code: http://www.mvps.org/directx/articles/splash_screen.htm

(Note one small error of his: He didn''t initialise the D3DFORMAT, I advise on using the active backbuffer''s format at all times)

When you''ve ''tiled'' your large surface, you''re saved! You can even load and render only the needed parts of your tiled thingamajig.

Hope this helps.

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!