Advertisement

COBRA READ THIS

Started by April 06, 2001 06:29 PM
1 comment, last by steveharper101 23 years, 7 months ago
I am in the process of constructing my own halflife level loader. I have already got the various lumps loaded but don''t know how to render the verticies to the screen. They cannot be rendered directly to the screen can they do you have to use the faces lump? I only want to get level gemotry up first so i''m not bothered about lighting and such like because it complecates things Thanks
Okay....... I assume that your question is simply "how do I draw it all to the screen", so here's a reply to that question ( if I got it wrong, just say so ).

U CAN actually just draw them to the screen, once you have a vector face value for each node... ( which you should have already from taking in the lumps from the bsp ).


Then what you do is create function to look at all of the nodes and mark which ones are visible.. ( i.e within FOV and facing you to some degree ).


Then you simply create a command that would look something like this.


rendervisiblefaces()
{
for(int faces = 0; faces < visible_faces.max(); faces++) {
face_t* f = visible_faces[faces];
while(f) {
renderface(f);
f = f->next;
}
}
}


That uses a command called renderface() that would look like this.

NOTE: ( i'm up my step-dads at the mo, so I don't have the code in-front of me, so this one will have to be in pseudo/c )

renderface(const face_t *f)
{
bind textures to faces ( using something like f->bindtextures ). I assume you can write your own texture binding code.
enable texturing. ( glEnable(GL_TEXTURE_2D) )
glDrawArrays(f->type, f->first, f->count)
}

Dont be intimidated by the glDrawArrays bit, it is an OpenGL extension that says this...
"typedef void (APIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);"


U are simply then inputing your face values into that by using f-> for the input variable.



Then in your main drawing loop, simply do rendervisiblefaces().


I hope that's helped.. if not, just say... I'll have the whole half-life loading code for download soon, so then you'll be able to see it.

~Cobra~

Edited by - Cobra on April 6, 2001 10:24:24 PM
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Advertisement
When is your site coming online??

This topic is closed to new replies.

Advertisement