A Triangle and Some Text = SLOW?

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 on other sites
Locking and unlocking the vertex buffer; when and how do you do it? Are you using hardware or software acceleration?

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 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 on other sites
Okay. By the way, how do I limit my programs to a stable FPS? Now it runs at 300fps, I want it to go at 60fps...

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).

Create an account

Register a new account

• Partner Spotlight

• Forum Statistics

• Total Topics
627686
• Total Posts
2978637

• 12
• 14
• 12
• 10
• 12