How do you suggest to implement this.

Started by
7 comments, last by superpig 18 years, 1 month ago
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.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Advertisement
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
If its a line graph, you can just use the line primitive to render a graph.
No its not a line graph.
I wanted to do for every enrty in the array a vertical line of 1 pixel width.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Are you nuts?!!?

You render a series of lines one pixel in width..... using the line primitive.
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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.
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.
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement