Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    18
  • comments
    19
  • views
    14718

SDL, Land of the Dead, and Ultimate Game Design

Sign in to follow this  
jdaniel

387 views

I spent this week reading the SDL library documentation and porting my engine from glut to SDL. I thought seriously about porting the code directly to the WinAPI and using OpenAL for sound, but finally decided to use SDL for various reasons. The most important being the portability to LINUX.

I have a fairly competent rendering engine at the moment and some rudimentary level editing tools in place. Basically, the code has full support for OBJ files, including textures in png format and materials.

The rendering loop consists of a nested red-black tree traversal. The top level tree holds material objects. Each of these objects contains the material properties and a pointer to another tree of faces. So the final rendering loop looks something like this:


  


myfaces = localobj->getFacesJRB();

// construct a texture JRB and initialize the appropriate textures
jrb_traverse(tempmaterials, mymaterials)
{
thismaterial = (obj_material *)tempmaterials->val.v;
if(thismaterial->texture_name != NULL)
{
if ((jrb_find_str(newtextures, thismaterial->texture_name)) == NULL)
{
localtexture = (GLuint *)malloc(sizeof(GLuint));
*localtexture = pngBind(thismaterial->texture_name,
PNG_NOMIPMAP, PNG_ALPHA,
&localpnginfo,
GL_REPEAT, GL_LINEAR, GL_NEAREST);
if (*localtexture == 0)
{
printf("Can't load texture file: %s\n", thismaterial->texture_name);
exit(1);
}
newtex = new Texture(*localtexture, strdup(thismaterial->texture_name));
jrb_insert_str(newtextures, strdup(thismaterial->texture_name),
new_jval_v((void *)newtex));
}
numTextures++;
} // end of texture name null conditional
} // end of jrb materials traverse



if (shadeMethod == GL_SMOOTH) {
// compile the display list
glNewList(*mydisplaylist, GL_COMPILE);

// traverse the materials jrb
jrb_traverse(tempmaterials, mymaterials)
{
thismaterial = (obj_material *)tempmaterials->val.v;
myfaces = thismaterial->faces;

// set material properties
glLightfv(GL_LIGHT0, GL_AMBIENT, thismaterial->Ka);
glLightfv(GL_LIGHT0, GL_DIFFUSE, thismaterial->Kd);
glLightfv(GL_LIGHT0, GL_SPECULAR,thismaterial->Ks);
glMaterialf(GL_FRONT, GL_SHININESS, thismaterial->Ns);

if (thismaterial->texture_name != NULL)
{
temptextures = jrb_find_str(newtextures, thismaterial->texture_name);
newtex = (Texture *)temptextures->val.v;
glBindTexture(GL_TEXTURE_2D, newtex->mytexture);
}
else glBindTexture(GL_TEXTURE_2D, 0);

// traverse the face jrb
jrb_traverse(tempfaces, myfaces)
{
thisface = (obj_face *)tempfaces->val.v;

switch(thisface->face_format)
{

case VERTEX:
case VERTEX_NORMAL:

glBegin(renderMethod);
for( j =0; jpolygonSize; j++)
{
glNormal3fv(&thisface->face_normal_array[(thisface->normal[j]*3)]);
glVertex3fv(&localobj->obj_vertex_array[(thisface->vertex[j]*3)]);
}
glEnd();
break;

case VERTEX_TEXTURE:
case VERTEX_TEXTURE_NORMAL:

glBegin(renderMethod);
for( j =0; jpolygonSize; j++)
{
glTexCoord2fv(&localobj->obj_texture_array[(thisface->texture[j]*2)]);
glNormal3fv(&thisface->face_normal_array[(thisface->normal[j]*3)]);
glVertex3fv(&localobj->obj_vertex_array[(thisface->vertex[j]*3)]);
}
glEnd();
break;

default: printf("\nlogic error in createDisplayList\n"); exit(1);

} //end of swtich

} //end of face traverse

} // end of material JRB render traverse

glEndList();
}







I've abstracted the OBJs into a WorldObject class and I've abstracted the "level" into a MyWorld class. I also have basic openGL picking enabled, so the mouse cursor can be switched from "cursor on the screen picking mode" or classic first person shooter mode... very similar to how World of Warcraft is setup.

I'm satisfied with the controls. Everything is responsive and fluid. No third person camera views are available yet, only first person with mouse-look.

I've read up on collision detection and have thought about the next step in code development.

I also got a hold of Ultimate Game Design - Building Game Worlds by Tom Meigs. It has nothing in depth mathematically or anything about programming but it appears to be a clear guide through the game publishing process and a high level tools overview. I believe I will benefit from reading it.

I may be receiving some of the Game Programming Gems books as a birthday present soon (Nov. 6). I also might be getting Dark Watch for the XBox from my lovely wife.

I also bought a copy of Land of the Dead for the PC this weekend. This game is a huge amount of fun and I would recommend it to anyone that is looking for a solid budget title ($19.99). It has something different to offer me. The first scene on the farm was awesome. The zombies move slowly, but there are a lot of them. And a .22 rifle that holds 4 bullets and a 6 shot revolver takes time to reload. And ammo is rare. You can run indoors and close the doors to slow them down, but they will slowly punch through. It is great fun and I think anyone that is interested showed go out and support these guys and buy a copy. It is the closest I've seen yet to replicating the classic zombie movie nightmare.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!