A Triangle and Some Text = SLOW?

Started by
4 comments, last by Buckeye 13 years, 5 months ago
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);	}};
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
Advertisement
Locking and unlocking the vertex buffer; when and how do you do it? Are you using hardware or software acceleration?
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;
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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).
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...
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement