Sign in to follow this  

A Triangle and Some Text = SLOW?

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

Hello, I am using Direct3D 9 on a Windows Xp machine.

Could some one list the most common problems for just a triangle and some text to be slow? With just the triangle on the screen, it goes at 1-2 fps (so says my fps calculator). When I stop drawing the triangle, it says that it's running about 10fps faster. My computer can normally run decent games at 50-60fps. What are the common problems for this? I zeroed out "all" of the problems with the window wrapper (I think), so I highly doubt that it's still the window stuff.

Any suggestions? Just ask for a snippet of source-code and I'd be happy to provide it. To get started, this is the primitive class at it's current state:

#include "ColorVertex.h"

template<typename TVertex> class primitive
{
private:
ID3DXMesh* my_primitive;
TVertex (vertex)[3000];
ushort (index)[9000];
ushort vertex_count;
ushort index_count;

public:
primitive()
{
vertex_count = 0;
index_count = 0;
my_primitive = 0;
}

void add_vertex(const TVertex &p_vertex)
{
vertex[vertex_count] = p_vertex;
++vertex_count;
}

void add_index(ushort p_index)
{
index[index_count] = p_index;
index_count ++;
}

bool complete()
{
TVertex* vertex_buffer;
ushort* index_buffer;

if (FAILED(D3DXCreateMeshFVF(vertex_count/3, vertex_count, D3DXMESH_WRITEONLY, TVertex::get_format(), device, &my_primitive)))
{
return false;
}

my_primitive->LockVertexBuffer(D3DLOCK_DISCARD,(void**)&vertex_buffer);

for (auto this_vertex = 0; this_vertex != vertex_count; ++this_vertex)
{
vertex_buffer[this_vertex] = vertex[this_vertex];
}

my_primitive->UnlockVertexBuffer();

my_primitive->LockIndexBuffer(D3DLOCK_DISCARD,(void**)&index_buffer);

for (auto this_index = 0; this_index != index_count; ++this_index)
{
index_buffer[this_index] = index[this_index];
}

my_primitive->UnlockIndexBuffer();

return true;
}

void render()
{
my_primitive->DrawSubset(0);
}
};

Share this post


Link to post
Share on other sites
I am a total idiot, this was the problem:

#define hardware false
#define software true



Supposed to be:

#define hardware true
#define software false



So that this:
return initialize(null,p_name,p_width,p_height,windowed,hardware);


...works with this:
if (render_mode == true) device_type = D3DDEVTYPE_HAL; else device_type = D3DDEVTYPE_REF;

Share this post


Link to post
Share on other sites
In case you're not already aware; you shouldn't be using the REF device at all, unless you're trying to test something that your graphics card doesn't support, or you think you've found a driver bug.

The REF device isn't designed as a software rasterizer, it's a reference rasterizer. It's not supposed to be fast, it's supposed to be 100% correct, and it doesn't exist unless you have the SDK installed (I.e. it won't be available on end user machines).

Share this post


Link to post
Share on other sites
Quote:
how do I limit my programs to a stable FPS?

There are several ways. One simple approach is to setup a high res timer outside your run loop ( see QueryPerformanceCounter and QueryPerformanceFrequency ).

With a call to QueryPerformanceFrequency, calculate the number of counts per frame for the desired frame rate.

Set a float next_time to 0.

In your run loop, get the current count (QueryPerformanceCounter) and see if it's greater than next_time. If yes, then do your rendering and set next_time = current_time + numCountsPerFrame. If no, Sleep(0).

Share this post


Link to post
Share on other sites

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