Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Graham, posted on May 28, 2001

Image Description, by Graham

this is a screenshot from my game in development, which i [eventually] intend to turn into a full game, ill just have to hire some others to do my media (textures, modelling etc) anyways, onto the techy stuff

first the console, the heart of my game. the console consists of an output and input (displayed in a dos console for servers and an on-screen display for users and clients). when an input is proccesed, it splits up the char* to match the command to a list in a hash table. commands are added with a name and a function inside my code (yay function pointers) as are variables. theyre either added beforehand as actual variables (pointers to screenwidth/height etc). this great console allows me to test stuff quickly and easily. oh and it loads cfg files too :]

next the terrain; (everyones doing it! <-- ive given in to peer pressure) the whole map is tile based, with a grid of 4x4 heightmap per tile. when a tile is drawn, it matches up the corners with the adjacent tile, so theres no gaps(theres a bit on this at the end) i load an image and get the average greyscale and set the height of that particular tile's heightmap. rather than pre-determine the normals i work them out on-the-fly as in the future the heightmap will be changed (destructable :D)

as for drawing, ive recently switched to a new "scaledistance" (its a varible in my console) so, (based on the viewdistance/culling distance and the scaledistance) the further away the particular tile being drawn is, the lower quality the tile (tiles per tile :) with just a level of 1,2 and 3. this has helped me speed up the cfgs for lower range gfx cards :]

lastly, what i render, rather than a basic for(x=0) for(y=0) pair of loops, i worked out a new method for what i should draw; i have a grid of bytes (the same size as the amount of tiles existing on the map) and work out a bounding rectangle of tile that should be drawn based on the viewdistance, and less behind and to the side etc. then i just use a floodfill algorithm to fill in the grid. this works a treat, saves a lot of cpu time, and is very efficient :]

ive moved onto bringing in the networking stuff now (the site has a quick mention on how to use it) and its going fine.

the *only* problems i have are that the method of the floodrender (as i call it :) is that i cant to a total tri-strip render (its just per-tile atm). Also when the scale changes, you can see gaps in the terrain as not as many points match up (in-betweens of the heigtmaps on the tiles). my other problem is my programmers art syndrome :]

anyone feedback is much appriciated and any solutions would also be cool.

the latest demo is avaible (and updates to the site) at :]

-- Graham at deadpenguin dot org
-- icq 13548542

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

May 28, 2001, 05:28 PM

What computer did you use to make the screenshot?
I am down to 14-15 fps on a PIII 500 TNT2 ultra.
Perhaps you should see if you could squeeze a bit more fps out of your engine (or perhaps I should go get me that gForce).

Anyway, good luck on your job search, and good luck on your game programming project.


PS. Your program makes my mousepointer act weird when multitasking.


May 28, 2001, 05:35 PM

Looks like a cracking base engine to build stuff upon there - very cool. I like the idea of consoles - being able to experiment without a re-compile must be really handy.

As for gaps in the tiles, you need to break up the lower detail tile's adjacent edge with the higher detail tile (if that makes sense). I know, thats not really much help.. :) - Have a look for a paper called GeoMipMappng by Willem De Boer (not sure if the name is spelt right... sorry) - If I remember correctly it deals with this problem really nicely.

The flood fill approach sounds quite good - I remember someone mentioning it before though. I'm gonna try out the demo now, and see how it looks!

good work,

zed zeek

May 28, 2001, 05:43 PM

a console, the heart of a game?
i love the picture on your site obviously holly is the computer controlling the console
-command vid_restart not found
-command vid_restart not found
-vid_restart (oh *that* command)
--kill window
whoops just had a closer look its restartvid not vid_restart bad boy zed :)

perhaps a quadtree would be a quicker/better method, for seeing whats on the screen. also those do look like cracks between the higher and lower tesselated meshes on the righthand screenshot.

btw kurt when i posted i got a message thread id already exists please report this bug.


May 28, 2001, 06:18 PM

Reaches a constant 22 fps on my KyroII/PIII-910 system. Is it intended, that noise.bmp is the only terrain texture? If so, why? This is the ugliest texture i've ever seen. I replaced it with a grassy one and it looked way better. You are putting your work into a bad light by using such awfull art.

Evil Bill

May 28, 2001, 07:04 PM

Looks pretty good, i like the console :) Gets 22fps on my PIII 500 GeForce2. It really buggers up somewhat with multitasking though, as MadCow said.



May 28, 2001, 07:39 PM

Why is it so slow?


May 28, 2001, 09:44 PM

Nice job you did, but the other posters are right. It is wwwayyyy to slow. I tested it on an old 450 mhz voodoo 3 computer and I was getting about 8 fps on average. You probably need to recheck your math and try to optomize it. My suggestion would be to add a function that counts the number of polygons being drawn. Since you have a console, this should be a cinch. Another thing you might want to check for is to see if you really are using a HAL device and not RGB emulation.


May 28, 2001, 09:58 PM

Cool, but i guess that you're only in the very early stage of you're engine : on my PIII OCed @ 840Mhz with geforce 2 mx, your engine runs @ 35 FPS with 11000+ polygons, my own engine runs @ 60 FPS with 40000+ polygons (2 TMUs, 1 light, fog enabled).
Vertex Arrays and Triangle strips seem to be the way (see the forums @


May 28, 2001, 10:25 PM

Ok, this is really freaking me out. I linked to your page LAST NIGHT from the virtualhideout case mod gallery, and happened to take a look at your software page and see an older screenshot of this same program. NUTTY! It's a small web after all. :)



May 28, 2001, 10:38 PM

a little too slow, but i think i know why, although i used t&l alot with OpenGL i found that if you recalculate normals alot on the fly the framerate takes a huge hit, havent figured out why. also make sure you don't actually recalculate normals each frame that could also have something to do with the low fps. simple way to fix predetermine normals per tile for each lod, then memcpy(as needed) them into one huge lockable array, much faster that way, at least it was for me.

George Ziniewicz

May 28, 2001, 11:14 PM

Code runs (as it opens) 48-52 fps on my 1 gig athlon w/ geforce2.

I remember working with you on your console text blackborder problem in the ng, you didn't mention how you fixed it, was I correct about improper/no alpha-encoding in your texture loader?

Looking down allowed me to see missing chunks of mesh.

good luck,

Tim Auld

May 29, 2001, 02:05 AM

Ugh.. function pointers. Try abstract interface callbacks (assuming you are using C++)! Then you can have individual objects register commands, variables, whatever with the console. My console allows objects in the game to register key bound commands (e.g. fire primary weapon). The cool thing about this is that it allows the user to modify the key bindings without the object caring; it just sees that it's command Id has been triggered (it provides input abstraction). You can modify bindings and variables per object directly, and still have single variables associated with whatever controls them.

Something cute that I did was make the visual appearance of the console itself accessible via variables. So you can set the background texture, the background vertex colours, the text colour, etc. via variables. Type set conpos 100 and the console will automatically scroll to that position. Console input without the command character is a chat string sent to other clients (so it's quite central to my game also).

There is also an inactive mode - it allows you to see console output without having input focus on the console. The key bindings also take this into account. For example the screenshot key works both in the game and the console, but a fire key works only in the game, and the history and auto-complete keys are console only.

Ok, sorry for ranting but the console is quite a fun thing for a programmer to write :)


May 29, 2001, 06:26 AM

right, time to answer some questions etc :]

the mouse is a bit funky at the moment, designed for full screen i guess, its a bit jerky, gotta look into that still, but it captures correctly (if your getting over 20fps the mouse is useable)

my computer is a creaf geforce mx on a duron 750@950, and a geforce sdr on a dual celeron 466

stoo: yeah, the console is *really* usefull for testing by just typing set bleh 1 etc in the console to switch over to a different mode etc of what ive gotta test :]

zed zeek: ive changed most of the names to reflect their q3 counterparts now ;) and listvars and listfuncs list all the availbe vars/funcs :]

Brainiac: oops, didnt mean to leave that in, it was a test to see how many tiles a pixel covers. heres where the console comes in useful:
unloadtexture map
loadtexture map calculon.bmp
and the texture is changed :]

George Ziniewicz: it was from the glgentex(), i was loading with RGB (in the form of "3" so i didnt notice it) instead of RGBA (the 2nd param i think)

yeah, its kinda slow, after a lot of commenting out etc, i found it was the amount of tiles im drawing that slows it all down, rather than the normal calculation (im not using cosf or sinf yet either)

at the moment, im only using a tiny amount of tri_strips and im still working on the floodfill algo so that i can turn much more of it into one strip

i dont know if many of you read the description, but if you want it a lot smoother, goto the default.cfg (or type it in the console) and change the scaledistance and viewdistance(dont set that to less than 6 otherwise the floodfill leaks) so, in the console, youd type
set scaledistance 1
set viewdistance 6
and youll get a much faster (but not so detailed) heightmap


May 29, 2001, 08:26 AM

15 fps on PIII-450, Riva TNT2 Ultra, 384Mb RAM.
You probably should change the ground texture, just making it green would please the eyes more =)


May 29, 2001, 08:27 AM

I probably should add that that was in 1280x1024x32 =)


May 29, 2001, 08:35 AM

sorry,i try all the key,but the console did not appear...


May 29, 2001, 10:08 AM

onlyriver: for the UK keyboards its the ` underneath the esc key, im imagining that its over on the right for US keyboards.

that reminds me to add a bind for the toggleconsole.

oh, and im 18 today(29th) everyone ;] didnt think the image would fit in in time for it


May 29, 2001, 10:51 AM

Use a tree for the console, not a hash table.

If you use a ternary tree, you can get tab-completion and/or tab listing of commands as seen in Quake3.

Each node has a letter, the letter to match at the current position in the string.

When you type a letter, you traverse the left or right child to find the node whose letter you match. You then descend the center child and start with this node as the tree for the next key that is typed.

Then, tab-completion is just recursing down the left subtree and tab-listing is an inorder listing of the leaves in the current subtree.

I'll give an example.

You have a tree with Quake-like commands. Perhaps the root node is 'c'.

An 'r' is typed. r > c therefore go right. The next node might be 'r'.
Match. Descend center node. Note this subtree as the working tree. (Perhaps the node is '_'), with no left or right children.

Then if you press tab, you follow the left child if there is one, and descend the center if there isn't. Or for tab listing, recursively follow the left, then the center, then the right, and chuck any leaves you find to the console.

NB. if backspace is pressed, you return to the parent.

I advocate this system because most people are going to have no idea what your console commands are - this will help them out.


May 29, 2001, 01:44 PM

Do you guys know what makes the mouse pointer and multitasking in general slow down when using DirectX 8? I bet this program uses DirectX 8... anyway, I'd like to figure this stuff out SO I CAN FINALLY MAKE APPS THAT DONT MAKE PEOPLE'S COMPUTERS SLOW DOWN DRASTICALLY. Ah. I said it. I think I knew the answer at one point, but now I forgot. Is it that I Present() too much? :-)



May 29, 2001, 02:19 PM

no idea, i personally dont have that problem, and theres NO usage of directx at all in this game

maybe its a video card/dib refresh thing


May 29, 2001, 03:45 PM

Happy Birthday :-)



May 29, 2001, 08:46 PM

not trying to rag on you or anything, but.. um.. hint. that's not a game. that's a really slow landscape with a console.


May 30, 2001, 04:04 AM

I haven't noticed any slowdowns when coding input stuff for directx 8 when running release stuff, when debugging there is that annoying 5-10 second delay but that is fixed through a registry fix.

The registry fix is in the dx8.1 beta sdk, they've added a thing to fix the slowdown of the mouse when debugging code in win 2k, basically just a registry fix (the bug is not in whistler they also mention).


May 30, 2001, 10:06 AM

Could you tell me more?

I seem to be having this problem.



May 31, 2001, 06:02 AM

Well i was only guessing at what your problem was and guessed that it only happened while debugging.

Well the fix that microsoft made for the dx8.1 beta sdk was a way to activate emulation mode for directinput.
They did not recommend end users to use this fix, only developers.

That was sort of odd I thought since i haven't experienced any problems when just running the code and that statement from microsoft tells me that end users might have that problem.


June 03, 2001, 11:38 AM

This program is shit. Why would you want to "show off" such a piss poor program? I get 20 fps with my geforce and a PIII 500 mhz, and 384 RAM. Unless you have a bunch of Sleep(10); commands all over your code, there's no reason I should get 20 fps with a bunch of flat shaded polys, and a 20 poly "thing" that you drive around. Go read some tutorials about basic game design, and programming...

This thread contains 26 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.