|
Author Topic:   Source Code Samples
Glide
New Member
posted February 03, 2001 12:06 PM            
Does anyone have basic source code for getting a scene up and running using DX8 and C++? I have been researching this for months now, and I need a little push. All the samples I have found so far have been OpenGl versions, and I haven't been able to get GLUT installed yet. Just a basic heightmap and texture scene is all I need to get to the next level.

Any help would be much appreciated.

IP:

Lithium
Member
posted February 05, 2001 09:04 AM         
I don't know what you mean by a 'scene' (terrain?), but don't overlook
the DX8 SDK samples. The billboard example in the SDK has a camera flying
over textured terrain. And heightmaps by themselves are not dependent on
what API you use, so I don't see why you can't use them from any open-source
OpenGL demo. It should be fairly easy to remove and use the code.

IP:

Glide
New Member
posted February 06, 2001 11:10 PM            
Thanks, Lithium! Don't know how I missed that one.

IP:

Lithium
Member
posted February 07, 2001 09:31 AM         
Well, whatever, just trying to offer some advice, even if you have already seen
that before a million times.

This is the heightmap code I use in its simplest form. There is nothing special
about it since every demo I've seen uses something similar.


#define HEIGHTMAP_SIZE 1025
BYTE *heightmap=NULL;

int
Load_Heightmap() {

heightmap = new BYTE[HEIGHTMAP_SIZE * HEIGHTMAP_SIZE];

FILE *File = fopen("heightmap.raw", "rb");
fread( heightmap, sizeof(BYTE), HEIGHTMAP_SIZE * HEIGHTMAP_SIZE, File );
fclose(File);

return 1;
}


int
Get_Height(int x, int y) {

return heightmap[ x + (y * HEIGHTMAP_SIZE) ];
}

IP: