Archived

This topic is now archived and is closed to further replies.

Drizzt DoUrden

Game Speed - Just Curious

Recommended Posts

I was just curious as to why when I make a small game like Pong, its incredibly slow, yet Baldurs Gate can draw 25 2D character bitmaps and very detailed backgrounds and it still runs pretty fast on my 200mhz cpu? The only logical reason I could think of is assembly, but I mean... how much of a difference could it really make? I've been thinking about this since I started OpenGL, and I never really had the chance to ask anyone (I don't know anyone who knows the answer), so here is the big question for those who know. Also, why is it that 3D applications run faster than 2D ones? Is it because of my video card? Thanks for any responses. Edited by - Drizzt DoUrden on December 17, 2001 9:23:06 PM

Share this post


Link to post
Share on other sites
it probably doesn''t have [much] to do with assembly... they are just better programmers than you (hey, don''t get mad, they''re better programmers than me too).
i heard that newer video cards are concentrating on 3D a lot, and newer ones either don''t, or soon won''t (i don''t know because i just read this in some other forum) support hardware 2D crap. i guess you can tell that i am no expert in this...

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
What resolution are you running your pong game in? Most games like Baldur''s Gate run in 640x480 mode; I know Starcraft does. Also, having some real big picture would slow down your game since it absolutely blows away your fill rate.

Share this post


Link to post
Share on other sites
you say you are using opengl, yet you mention how baulders gate does fast 3d graphics. maybe its just me, but you are using the wrong api. also baulder''s gate if i remeber correctly ran in 8bit pallette mode which is MUCH faster then 16bit or higher. also since this is an older game, it most likly used dos for direct VRAM access.

so if you want to get comparible speed. you must:
1. use directdraw7
2. dont EVER read from VRAM
3. keep the resolution to 640x480
4. keep color depth at 8bit

that should be a good start.
the main reason 3d apps run faster, is because the 3d accelartor have more percieved video bandwidth due to archtecture. since when filling in the polys nothing except the triangle information and textures go across the bus. if done properly this transfer of data is only for the vertices required for the screen with some extras while the textures are kept in VRAM. now the card does all VRAM access internal across its own bus and does not have to go over the reletivly narrow apg/pci bus. this is why high res games are possible using 3d accelerators vs using software rendering which requires transfer the entire screen to the video card. you could of course make 2d apps that run faster then the 3d counterparts if you do many direct access effects which require messing with the video data at the pixel level which is limited on 3d hardware (pixel shaders are somethign entirly different and currently will not allow many effects possible in a pure software mode).

krez, video cards stopped increasing support for hardware 2d stuff awhile ago. which is why directdraw never got alphablending and rarly was updated (technically directdraw4 supports alphblending, but thats a special release meant for wince pdas). this is also why microsoft stopped including directdraw in directx8 since there was no need (just query for directx7 and you are set).

Share this post


Link to post
Share on other sites
My guess is because they have a large team of very experienced, highly paid developers working on it around the clock, with access to little tricks learnt through years developing software.

Share this post


Link to post
Share on other sites
quote:
Original post by a person
maybe its just me, but you are using the wrong api.


Not to start another (X vs Y) flamewar, but yes, it''s just you.

Seriously, Drizzt - there''s a lot of things you can do wrong in OpenGL. Some really silly things such as only setting rendering states as little as possible, grouping similar primitives, changing texture bitdepths, and setting low-quality high-speed rendering options can help more than you think.

Sometimes, also, you''ll find that certain primitives are just too slow. Are you using textured quads to draw bitmaps, or are you using the pixel transfer functions? If the answer is the latter, try moving to the former!


People might not remember what you said, or what you did, but they will always remember how you made them feel.

Share this post


Link to post
Share on other sites
quote:
Original post by a person
you say you are using opengl, yet you mention how baulders gate does fast 3d graphics. maybe its just me, but you are using the wrong api. also baulder''s gate if i remeber correctly ran in 8bit pallette mode which is MUCH faster then 16bit or higher. also since this is an older game, it most likly used dos for direct VRAM access.



Baldur''s Gate isn''t that old. It used DirectX.

Share this post


Link to post
Share on other sites
Yeah... there are so many minor mistakes or oversights a programmer can make, so that code looking very similar can actually execute a lot more slowly. If Pong is running slowly, I am sure you have done something ''wrong'' somewhere

Share this post


Link to post
Share on other sites
You have to be very careful with your programming when your dealing with graphics... AND games. Small changes can make huge differences. Now, your problem is that you really need to sit down and find those small changes. If you are using VC++ I recommend that you become familiar with the profiler. Also, concentrate on your innermost loops. For example, you have a game loop with a loop to draw characters with a loop to draw rows of pixels with a loop to draw single pixels. Concentrate on that loop drawing pixels, until it can''t possibly get faster (this is a great case for assembly) then concentrate on the loop drawing rows of pixels (may still need assembly) and so on.

Also you can add it up to see how many times you''re hitting those loops... I''ve had loops hit 300,000 cycles per frame... sometimes more. Another thing is to become a do-it-yourselfer. It''s easy to use someone elses generic code to do a simple task but when that generic code has to take into account display, system settings, alignment of the planets and the whereabouts of Hoffa''s corpse, your program gets bogged down.

Back in the day I''d write game code in a matter of a few hours and then spend the next two weeks optimizing (of course, this was in the DOS days and puters were slow, I won''t even get into the headaches of my Apple II days).

Anywayz, getting to my point... there''s a huge difference between the code ya get out of a book and the code you spend two weeks to a month slaving over... and Baldur''s Gate, I''m sure, is a pretty far cry from the code in any How-to book.

I seriously suggest (if you''re really interested in game programming) that you sit down and hack that code, dig into your system, find out what all that "black box" code is really doing, remove the code you don''t need, revise the fundamental way you''re doing things and learn assembly... assembly is very easy, especially for most purposes and worth the effort if you want that lightning fast code =)

- Jay



Many of the truths we cling to depend greatly on our own point of view

Get Tranced!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If your opengl app is running windowed, make sure your desktop isn''t set to 8bit/256 colour mode, opengl really doesn''t seem to like that, at least on my card...

Share this post


Link to post
Share on other sites
How much memory does your video card have? If it is an old 1mb model it won''t be able to do anything higher than 640x480x8bpp without resorting to using system memory for the invisible page. Copying from system to video memory is slowwwww. Running on my P120 laptop (Compaq LT5280) w/1mb video an app that does nothing but clear the screen and display a frame counter (using a backbuffer) runs at 60fps (vsync of the LCD) at 640x480x8 and at 12fps or less at any higher resolution.

Share this post


Link to post
Share on other sites
just because baldur''s gate used dx, does not mean it did not run in 8bit mode. though it could have very well used 16bit modes (my memory is a bit fuzzy on that). it definatly runs in 640x480.

Share this post


Link to post
Share on other sites
I recently had this problem with opengl - and i think i know what you're doing wrong.

Make calls to glBegin() and glEnd() only when you absolutely have to. I wrote a 2d game in opengl running at 15fps - it was calling glBegin() about several hundred times per frame. After some thinking i got it calling glBegin() about 10 times per frame, and my fps shot up to 100.

Try to use display lists wherever possible.

Also remember that if you call glBegin() within a display list "compilation" it is called every time the display list is used.

Edited by - Spiral on December 20, 2001 9:51:21 AM

Share this post


Link to post
Share on other sites
quote from interplay''s faq on baulder''s gate:
quote:

Q: What is the minimum system requirement to play Baldur''s Gate?
A: Currently the minimum requirement is a P120 with a 2meg video card and 16 Megs of RAM. This system spec plays VERY well and is not a minimum that says "I can boot the game up" but "I can actually play" system. You will notice definite improvements if you have a better system. With more RAM, you will see more varieties of animation on the screen at once; with more hard drive space, you will have to wait less for loading from the CD when you enter a new area. With a faster processor, the frame rate should improve and pathfinding should improve. If you have 4 meg of video card memory we plan to implement 24-bit graphics, which should improve the realism to the maximum level. We recommend a P166 with 32 meg of RAM for optimal performance.



you may be speaking of a newer version of baulder''s gate. i am speaking of the first one. the max color depth that baulder''s gate supported was 24bit and only if you had 4meg of video memory. increasing to 32bit depth would bring the vram requirments passed 4meg. since it would require 25% more memory and not look any better.

Share this post


Link to post
Share on other sites
Well, I still don't get it. I mean, my point is that Baldurs Gate was programmed to work on computers that are even under 200 mhz(thats what I have), and it is huge, so one small mistake in OpenGL shouldn't really give me trouble to the point where I can't move the window.

Even the code I take *directly* from the "OpenGL Game Programming" book is pretty slow, so I guess that it is more to the fact that I have a slow computer. But still, if a large 2D game can run with very litte "lag", then I think an SDL application where two boxes collide should run pretty damned fast.

Maybe I should make less global variables and stuff. I'll figure it some day, I always figure it out when I need to .

How much of a difference does assembly make in a program anyway? And what kind of assembly would I want to learn if I was working with Windows, SDL, and OpenGL? (I have seen like 5 different types and that confused the heck outta me)

And one other question. Is it so much faster to load a bunch of 32x32 bitmaps opposed to a 640 by 480 bitmap? I would think so but I dont seeaa difference.

Edited by - Drizzt DoUrden on December 20, 2001 4:09:00 PM

Share this post


Link to post
Share on other sites
If other opengl applications are running slow it could also be your opengl drivers. Older cards are known for there horrible opengl drivers. This, and/or some improper technique could cause your system to crawl =)

"Programmers - The next generation of Mathematicians"
~Michael Sikora

Edited by - guardian_light on December 20, 2001 4:10:09 PM

Share this post


Link to post
Share on other sites
because baldur''s gate was made in canada! that''s why it''s better...

seriously, as said before, the coders who worked on bd or any other professional game are GOOD. they spend a long time profiling their code, squeezing out every last drop of efficiency (ideally, this is not always the case).

also, any 3d application has a hugely more complex rendering pipeline then a 2d game. the processor (either cpu or gpu) has to do transformations and lighting for instance...2d is generally a straight blit. 3d also generally brings with it more complications especially in areas of lighting, collision detection, and animation (calculated in realtime).

and by the way, assembly does make quite a big difference, usually. it is most effective in getting the programmer to simplify and make more efficient their algorithms. you should try coding a huge switch statement in assembly...you might rethink it after a couple hours...

but why is your pong slow compared to a polished game? it could be your drivers, it could be the api, but likely if you are an inexperienced programmer you are not doing things very efficiently. i would suggest that if you are doing this as a learning experience, don''t worry. efficient code (in my experience) is generally not much fun to work with.

<(o)>

Share this post


Link to post
Share on other sites
For The Love of God:
BALDUR''S GATE ISN''T 3D.

I think I can say with authority, the performance difference between your SOFTWARE-RENDERED, VECTOR 3D Pong game and the RASTER-RENDERED, ISOMETRIC Baldur''s Gate is due to this fact.


Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

"What I see is a system that _could do anything - but currently does nothing !" - Anonymous CEO

Share this post


Link to post
Share on other sites
Drizzt DoUrden said:
"I mean, my point is that Baldurs Gate was programmed to work on computers that are even under 200 mhz(thats what I have), and it is huge, so one small mistake in OpenGL shouldn''t really give me trouble to the point where I can''t move the window."

You can''t move the window? It sounds like your program
isn''t processing Windows messages often enough - if at all.
Make sure something like the following appears in the main
game loop:


TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message


If not, check out nehe''s OpenGL tutorials to see an example
of how to process Windows messages in an OpenGL game. They''re at http://nehe.gamedev.net/


Steven Borkman
Home Page: http://www.acsu.buffalo.edu
Video Game Page: http://www-student.cse.buffalo.edu/~borkman/projects/game/index.php

Share this post


Link to post
Share on other sites
quote:
Original post by Magmai Kai Holmlor
For The Love of God:
BALDUR''S GATE ISN''T 3D.

I think I can say with authority, the performance difference between your SOFTWARE-RENDERED, VECTOR 3D Pong game and the RASTER-RENDERED, ISOMETRIC Baldur''s Gate is due to this fact.


Magmai Kai Holmlor




LOL. My Pong game is 2D, too, thank you very much.

It moves the window, it just moves it incredibly slowly, and my frame rates are always low. I''ll figure it out some day. But I have a few questions:

Is it slower to load a 320x320 bitmap, or to load a bunch of 32x32 bitmaps untill it reaches 320x320?

How do "scrolling background" games work, when it comes to loading the background? Are there any tutorials on it? Or is it simple logic that I just haven''t made my way to yet?

Share this post


Link to post
Share on other sites