Jump to content
  • Advertisement
Sign in to follow this  
itz_faraz

Need help on performance problems

This topic is 4810 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 people Ive been working on a game similar to SimCity 4. Here's how it looks uptil now: Please download from here the sample exe of the game so you can help me out in the below queries. The game is built in Visual Basic 6, DirectX 8.1, using orthographic projection. Supports terrain rotation, zooming, grid lines. I am very new to graphics programming and therefore I am already facing the following problems in which Im totally lost; dont know what to do about them: 1. I think the frame rate is not good enough in respect of the current game position. Its only a terrain right now, still not enough frame rate. (well, thats what I think.. what do you think?) The whole terrain is built in TRIANGLELIST format. All the vertices are placed into a single vertex buffer and Index buffer. Is this a good idea? Because thats just it.. only a terrain and a single vertex buffer. Still the FPS is not adequate enough. What is the best way? I thought of using quadtrees but got stuck in the idea that how would I perform ray-picking on it.. because my terrain is not flat.. if I click a mountain which is in the 2nd quarter, using quadtrees it might detect it as if I clicked in the 1st quarter. 2. The FPS gets lower everytime a house is placed on the terrain. I cant understand.. everything is quite simple in my code, but the game performance shows signs of high inefficiency. 3. Ive gone through all ends to figure out how to detect which tile the mouse is over on the terrain. I finally found that out but its not working very well. Its toooo slow. I first obtain the mouse screen coordinates, normalize them, and do the necessary stuff (inverting camera matrix, determining the ray direction, etc). And just to see which tile I clicked, I go through a long loop in which I create a plane using each triangle's coordinates and check if ray intersects it or not. (two triangles make up one tile.. so in the default map the terrain is of 42x34 tiles.. makes it total 1428 tiles, ie. 2856 triangles are tested on each mousemove event.. yuck!) 4. Im also having trouble with lighting the terrain.. but thats not a big issue so I wont discuess it here right now. - Thats it.. the above are the problems Im facing about which I have no clue how to solve them. Im a newbie at graphics/directx programming so I may be wrong about what I said about quadtrees.. thats what I need help of this forum to straight out my concepts. I have turned off the Day/Night mode in the game.. actually I have turned off all the lighting effects and now Im using lit vertices. Also read the Readme.txt in the zip file to all the keyboard controls. I can also provide the source code.. please help me out especially in the ray-picking issue.. its really bugging me. I was told that visual basic 6 is not a good language to build directx apps and it is the major cause of low performance. Well I believe its true but only in respect of high/powerful games, not in my simple game engine. What do you say? Faraz Azhar

Share this post


Link to post
Share on other sites
Advertisement
The first thing that comes to mind is that you might be using the debug version DX, which would cause a large slowdown in performance. I haven't downloaded your program, the main reason it's 3:40am and I've still got hw to do.

Not sure what to say on the ray thing, right off. My brain isn't functioning too terribly well at this hour.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tarviathun
The first thing that comes to mind is that you might be using the debug version DX, which would cause a large slowdown in performance. I haven't downloaded your program, the main reason it's 3:40am and I've still got hw to do.

Not sure what to say on the ray thing, right off. My brain isn't functioning too terribly well at this hour.


Ive heard a lot of people on this forum and other places that there is an icon in the control panel which allows the debugging level and retail/debug version support for DirectX. Since I have DirectX 8.1 SDK for VB6 installed on my system and DirectX 9 is also installed (not the SDK) and Im using WinXP SP1, I dont see any icon there.

And what difference would it make in my programming if I were using Retail version instead of Debug version? Whats so special about debug version? The maximum detail about debug error that it gives is "Automation Error". Furthermore, I was told by someone else, who tried this game of mine on his system, that the FPS is low.. I dont think he has debug version installed.

Share this post


Link to post
Share on other sites
Alright, so maybe you coded it poorly. That was the first thing that came to mind. The special thing about the Debug version is that it allows you a whole lot more information on the program running. You have to output it yourself, catch you're own errors, but it allows you a whole lot more flexibility in the actual debugging process. That extra crap in there slows shiz down.

However, this doesn't really seem to be your problem. So, can't really help you too much there. I'm not a VB coder, I'm a C++ guy. All I can really say is, if your problem is determining where your mouse clicks in your world, then try a different method. I don't know what that'd be, I don't do stuff in isometric. But I love stating the obvious, so there it is.

Share this post


Link to post
Share on other sites
Just how low is your FPS. That and how many tris are you drawing? The visual basic language is slower than C++ usually, but not by such a margin that it is unusable, especially if you are using DirectX or OpenGL with hardware accelerated graphics. Look at how much you are actually drawing. Also, What are your system specs. Maybe for some reason it is drawing everything in software mode who knows.

Share this post


Link to post
Share on other sites
Are you sorting by texture?

if you arnt then the worst case scenario, is that you are doing, a SetTexture and a DrawPrimitive call for each tri/quad.

a better aproach to this, is to sort your quads based on the textures they use, this way, you can potentially render a bunch of tris with only a single SetTexture, and given that the tris will be sorted it means they are adjacent to one another in the Vertex Buffer, so you can use a single DrawPrimitive call to draw a bunch of them.

I get the feeling that you are already doing this, but if you arn't then it is likely the culprit.

Share this post


Link to post
Share on other sites
Make sure you only have the functionality you need enabled. My prog was really slow until i realised i was alpha testing every poly, i restricted alpha to only when i needed it and my fps increased by 100.

Alpha is just an example in my case, perhaps you have other things you don't need enabled. Try to batch all of your rendering, and use small textures if possible, or have multiple textures within one image, and let the tex coords sort it out.

Share this post


Link to post
Share on other sites
OK Im assuming you guys havent seen the demo yet.

All in all (excluding the GUI) I have these things which are drawn in every render call:

1. The whole terrain is in one single vertex buffer. Terrain is built on TriangleList format. So There is only one call for SetTexture and DrawIndexedPrimitive for the whole terrain.

2. Then there are two separate vertex buffers for the two side-crusts. One SetTexture call, and two DrawPrimitives (no index buffer here)

3. Then there is the background grid. It is only a single quad of a very large size and texture contains a square shape. So to create a grid, texture is repeated about 100 times on that quad. One SetTexture call and one DrawPrimitive call.

Thats it. All in all.

Im not sure about the FPS. I think the FPS is ok. Thats why I wanted you guys to check the demo and see that with the above kind of geometry, is the FPS ok or not. Thats what I wanted to ask.

I have solved the ray-picking problem.. was simple maths but couldnt figure it out. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!