Sign in to follow this  

How do you suggest to implement this.

This topic is 4296 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 want to draw a graph of an array of values in direct3D. Actually it suppose to be a graph of the FPS, so it will change every frame. How do you suggest for me to do this? Should I create a texture, draw into that texture and draw that texture as a sprite into the screen buffer? Or should I try draw directly into the screen buffer? Thanks in advance.

Share this post


Link to post
Share on other sites
Just draw it directly to the screen using lines (or quads). You can keep last N measurements of the FPS in the circular buffer and then draw it using few calls.
This should be faster than render to texture approach. And it will not waste any texture memory and will save you context switch.
I don't know DX, but you should be able to draw it using 2 calls: one for the part of the buffer from oldest measurement in the buffer to the end of the buffer and second call will draw from the beginning of the buffer to the oldest entry. It will look like this:

buffer: ===============|========= (| is the oldest entry)
draw: ^ this goes first
^ and this part is second

To update buffer just overwite oldest entry with the new measurement and move "start pointer" one to the right. When you get to the end of the buffer, just wrap it around.
This way buffer update will be very fast (no reallocation).

HTH

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you nuts?!!?

You render a series of lines one pixel in width..... using the line primitive.

Share this post


Link to post
Share on other sites
If you want to do a graph whereby the area under the graph is shaded, use a triangle strip. Just alternate between a point on the graph (a sample) and the corresponding point on the axis. Using a triangle strip instead of lines will avoid any issues with gaps between lines and also allows you to scale the graph up/down more easily.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you nuts!?!?!

You're trying to tell me that using two triangles to render a one pixel thin line is better than rendering a one pixel thin line with the line primitive?!!?! And how exactly is it easier to scale up and down, it's the same thing in both cases!!

I'm going home..... you guys are all nuts.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Are you nuts!?!?!

You're trying to tell me that using two triangles to render a one pixel thin line is better than rendering a one pixel thin line with the line primitive?!!?! And how exactly is it easier to scale up and down, it's the same thing in both cases!!

I'm going home..... you guys are all nuts.


Uhh... I'm pretty sure a line primitive is just a very thin triangle under the covers anyways.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Are you nuts!?!?!
No.

Quote:
You're trying to tell me that using two triangles to render a one pixel thin line is better than rendering a one pixel thin line with the line primitive?!!?! And how exactly is it easier to scale up and down, it's the same thing in both cases!!
I should have mentioned that I was referring to horizontal scaling, but yes, I'm saying that using triangles to render a series of vertical lines between which there are supposed to be no gaps is better than generating a load of vertical line primitives. The hardware is optimized for triangles, not lines.

Quote:
I'm going home..... you guys are all nuts.
Don't let the door hit ya on the way out.

Share this post


Link to post
Share on other sites

This topic is 4296 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this