Ozwald

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Ozwald

  • Rank
    Member
  1. Well, I can safely eliminate anything about the camera transform, as I have camera control code. I can also eliminate glBegin/glEnd, as OpenGL >= 3.x has those functions depreciated and removed. I am not performing any culling (As it's just a field of points, no polygons right now), and I'm not enabling/using any lighting. I appreciate the help, but I don't think those suggestions will work, however, I will try removing the camera code (force the camera in one direction for now) and just trying to render one triangle. Hopefully that will help me trouble shoot some more. Thanks, -Ozwald
  2. Yes, the screen is blank. I'm checking glGetError after every gl* call I make, and am getting no errors at all. Right now, it's just rendering points, so even the order shouldn't matter, so I'm really confused. Thanks, -Alex
  3. Hi, Ladies and Gents, So, I've been working on a project that requires me to automatically generate terrain (procedural generation), so I've been working towards that, but I've ran into a rather irritating roadblock: I can't get OpenGL to render my data. I've done all the OpenGL error checking I can, and also tried the tool, "gDEBugger," and haven't been able to find the issue (although I'll admit that I'm not 100% sure how to use gDEBugger). You can find my project on [url="https://github.com/mrozbarry/procworld"]github[/url]. You'll need SDL 1.3 on your system to build it - sorry, the makefile is somewhat crude, as I just wanted something to get me started for now - you may have to edit it depending on your system. I've been trying to figure this issue out, and originally, [url="http://forums.libsdl.org/viewtopic.php?t=7715"]I thought that it could possibly be with SDL 1.3[/url], but it seems to be somewhere with how I'm handling OpenGL. Any help getting this to render properly would be super, Thanks, -Ozwald
  4. BSP30 rendering

    I've just gotten word that triangle strips might be helpful....any good places that I could learn about them? Oz~
  5. BSP30 rendering

    I've found some bugs in my code, so i've recoded some of it perhaps that would be more help Data structures #define _atosoft_bspfile_h_ #include <cstdlib> #include <cstdio> #include <iostream> #include <vector> #include <fstream> // BSP-30 files contain these lumps enum { LUMP_ENTITIES = 0, LUMP_PLANES, LUMP_TEXTURES, LUMP_VERTICES, LUMP_VISIBILITY, LUMP_NODES, LUMP_TEXINFO, LUMP_FACES, LUMP_LIGHTING, LUMP_CLIPNODES, LUMP_LEAVES, LUMP_MARKSURFACES, LUMP_EDGES, LUMP_SURFEDGES, LUMP_MODELS, NUM_LUMPS }; namespace bsptype { #pragma pack(4) // BSP Lumps struct tBSPLump { unsigned int offset, length; }; // BSP header struct tBSPHeader { unsigned int version; tBSPLump dir[NUM_LUMPS]; }; // BSP Entity typedef unsigned char tBSPEntity; // BSP Planes struct tBSPPlane { float normal[3]; float dist; // Plane equation is: Normal * X = Dist enum { PLANE_X = 0, // Plane is perpendicular to given axis PLANE_Y, PLANE_Z, PLANE_ANYX, // Dominant axis (axis along which projection of normal has greatest magnitude) PLANE_ANYY, PLANE_ANYZ } type; }; // BSP Mip-mapped Textures ...header struct tBSPTextureHeader { unsigned int numMiptex; unsigned int offset[1]; }; // ...body struct tBSPMiptex { char name[16]; unsigned int width; unsigned int height; unsigned int offset[4]; }; // BSP Vertices struct tBSPVertices { float x, y, z; }; // BSP Visibility typedef unsigned __int8 tBSPVisibility; // BSP Nodes struct tBSPNodes { unsigned short plane_idx; signed short children[2]; signed short mins[3]; signed short maxs[3]; unsigned short firstface; unsigned short numfaces; }; // BSP Texture Info struct tBSPTexinfo { float vecs[2][4]; // [s/t][x/y/z/offset] int miptex_idx; int flags; }; // BSP Faces struct tBSPFaces { unsigned __int16 plane_idx; unsigned __int16 side; unsigned __int32 firstedge; unsigned __int16 numedges; unsigned __int16 texinfo; unsigned __int8 styles[4]; unsigned __int32 light_offset; }; // BSP Lightmaps struct tBSPLightmap { signed __int8 imageBits[128][128][3]; }; // BSP Leaves struct tBSPLeaf { signed int contents; signed int visofs; signed short mins[3]; signed short maxs[3]; unsigned short firstmarksurface; unsigned short nummarksurfaces; unsigned char ambient_level[4]; }; typedef unsigned short tBSPMarkedsurf; // BSP Clipping nodes struct tBSPClipnode { int plane_idx; short children[2]; }; // BSP Edges struct tBSPEdge { unsigned short v[2]; // indices numbers of the vertices bounding this edge }; // BSP Surface Edges typedef signed int tBSPSurfedge; // BSP Models struct tBSPModels { float mins[3]; float maxs[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; int numfaces; }; #pragma pack() }; class bspFile { public: bspFile(); ~bspFile(); FILE* bspfile; bool bspLoad( const char* fname ); void *bspLump( bsptype::tBSPLump lump ); int bspElements( bsptype::tBSPLump lump, unsigned int typesize ); void bspUnload(); // Header bsptype::tBSPHeader head; // Entity List bsptype::tBSPEntity *entity; //Planes unsigned int numPlanes; bsptype::tBSPPlane *plane; //Texture bsptype::tBSPTextureHeader textureheader; bsptype::tBSPMiptex *miptex; //Vertices unsigned int numVertices; bsptype::tBSPVertices *vertex; //Visibility unsigned int numClusters; bsptype::tBSPVisibility *pvs; //Nodes unsigned int numNodes; bsptype::tBSPNodes *node; //Leaves unsigned int numLeaves; bsptype::tBSPLeaf *leaf; //Texinfo unsigned int numTextures; bsptype::tBSPTexinfo *texture; //Faces unsigned int numFaces; bsptype::tBSPFaces *face; //Lightmaps unsigned int numLightmaps; bsptype::tBSPLightmap *lightmap; //Clipping nodes unsigned int numClipNodes; bsptype::tBSPClipnode *clipnode; // Marked Surfaces unsigned int numMarkedsurfaces; bsptype::tBSPMarkedsurf *markedsurf; //Edges unsigned int numEdges; bsptype::tBSPEdge *edge; //Surface Edges unsigned int numSurfEdges; bsptype::tBSPSurfedge *surfedge; //Models unsigned int numModels; bsptype::tBSPModels *model; }; #endif And here is my fixed rendering code which still doesn't do much... int BSPLeaf( bspFile info, glVector camera_pos ) { int index = 0; bsptype::tBSPNodes node; bsptype::tBSPPlane plane; float distance; while( index >= 0 ) { node = info.node[index]; plane = info.plane[node.plane_idx]; distance = dotproduct( glVector( plane.normal[0], plane.normal[1], plane.normal[2] ), camera_pos ) - plane.dist; if( distance >= 0 ) { index = node.children[0]; } else { index = node.children[1]; } } return -index - 1; } bool BSPClusterCompare( bspFile info, int visCluster, int testCluster ) { if( info.numClusters == 0 || visCluster < 0 ) return true; int i = (visCluster * 8) + (testCluster >> 3 ); unsigned __int8 set = info.pvs[i]; return (set & (1 << (testCluster & 7))) != 0; } void BSPRender( glPoint campos, bspFile info ) { std::set<int> alreadyvis; std::vector<int> visible; bsptype::tBSPFaces *face; int fid; int vert; int camleaf = BSPLeaf( info, glVector( campos.x, campos.y, campos.z ) ); int f; // Begin leaf iteration :) for( unsigned int l = 0; l < info.numLeaves; l++ ) { if( BSPClusterCompare( info, camleaf, info.leaf[l].visofs ) ) { for ( unsigned int i = 0; i < info.leaf[l].nummarksurfaces; i++ ) { f = i + info.leaf[l].firstmarksurface; if( alreadyvis.insert( f ).second == true ) { visible.push_back( f ); } } } } for( unsigned int v = 0; v < visible.size(); v++ ) { face = info.face; fid = visible[v]; if( info.plane[ face[ fid ].plane_idx ] == 1) { vert = face[ fid ].firstedge; for( int edge = 0; edge < (face[ fid ].numedges / 3); edge+=3 ) { glBegin( GL_TRIANGLES ); glVertex3f( info.vertex[ edge + vert + 0 ].x, info.vertex[ edge + vert + 0 ].y, info.vertex[ edge + vert + 0 ].z ); glVertex3f( info.vertex[ edge + vert + 1 ].x, info.vertex[ edge + vert + 1 ].y, info.vertex[ edge + vert + 1 ].z ); glVertex3f( info.vertex[ edge + vert + 2 ].x, info.vertex[ edge + vert + 2 ].y, info.vertex[ edge + vert + 2 ].z ); glEnd(); } } } } Can anyone give me a hand at all? Oz~
  6. Hi, I'm loading and using bsp version 30 files (same as half-life 1) and have successfully loaded the file into data, but I'm having trouble figuring out how I'm to render this data... Here is how the data is structured: // BSP Lumps struct tBSPLump { unsigned int offset, length; }; // BSP header struct tBSPHeader { unsigned int version; tBSPLump dir[NUM_LUMPS]; }; // BSP Entity typedef unsigned char tBSPEntity; // BSP Planes struct tBSPPlane { float normal[3]; float dist; // Plane equation is: Normal * X = Dist enum { PLANE_X = 0, // Plane is perpendicular to given axis PLANE_Y, PLANE_Z, PLANE_ANYX, // Dominant axis (axis along which projection of normal has greatest magnitude) PLANE_ANYY, PLANE_ANYZ } type; }; // BSP Mip-mapped Textures ...header struct tBSPTextureHeader { unsigned int numMiptex; unsigned int offset[4]; }; // ...body struct tBSPMiptex { char name[16]; unsigned int width; unsigned int height; unsigned int offset[4]; }; // BSP Vertices struct tBSPVertices { float x, y, z; }; // BSP Visibility typedef unsigned __int8 tBSPVisibility; // BSP Nodes struct tBSPNodes { unsigned short plane_idx; signed short children[2]; signed short mins[3]; signed short maxs[3]; unsigned short firstface; unsigned short numfaces; }; // BSP Texture Info struct tBSPTexinfo { float vecs[2][4]; // [s/t][x/y/z/offset] int miptex_idx; int flags; }; // BSP Faces struct tBSPFaces { unsigned __int16 plane_idx; unsigned __int16 side; unsigned __int32 firstedge; unsigned __int16 numedges; unsigned __int16 texinfo; unsigned __int8 styles[4]; unsigned __int32 light_offset; }; // BSP Lightmaps struct tBSPLightmap { signed __int8 imageBits[128][128][3]; }; // BSP Leaves struct tBSPLeaf { signed int contents; signed int visofs; signed short mins[3]; signed short maxs[3]; unsigned short firstmarksurface; unsigned short nummarksurfaces; unsigned char ambient_level[4]; }; typedef unsigned short tBSPMarkedsurf; // BSP Clipping nodes struct tBSPClipnode { int plane_idx; short children[2]; }; // BSP Edges struct tBSPEdge { unsigned short v[2]; // indices numbers of the vertices bounding this edge }; // BSP Surface Edges typedef signed int tBSPSurfedge; // BSP Models struct tBSPModels { float mins[3]; float maxs[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; int numfaces; }; // Header tBSPHeader head; // Entity List tBSPEntity *entity; //Planes unsigned int numPlanes; tBSPPlane *plane; //Texture tBSPTextureHeader textureheader; tBSPMiptex *miptex; //Vertices unsigned int numVertices; tBSPVertices *vertex; //Visibility unsigned int numClusters; tBSPVisibility *pvs; //Nodes unsigned int numNodes; tBSPNodes *node; //Leaves unsigned int numLeaves; tBSPLeaf *leaf; //Texinfo unsigned int numTextures; tBSPTexinfo *texture; //Faces unsigned int numFaces; tBSPFaces *face; //Lightmaps unsigned int numLightmaps; tBSPLightmap *lightmap; //Clipping nodes unsigned int numClipNodes; tBSPClipnode *clipnode; // Marked Surfaces unsigned int numMarkedsurfaces; tBSPMarkedsurf *markedsurf; //Edges unsigned int numEdges; tBSPEdge *edge; //Surface Edges unsigned int numSurfEdges; tBSPSurfedge *surfedge; //Models unsigned int numModels; tBSPModels *model; This is what I have for rendering so far: int BSPLeaf( bspFile info, glVector camera_pos ) { int index = 0; bspFile::tBSPNodes node; bspFile::tBSPPlane; float distance; while( index >= 0 ) { node = info.node[index]; plane = info.plane[node.plane_idx]; distance = dotproduct( glVector( plane.normal[0], plane.normal[1], plane.normal[2] ), camera_pos ) - plane.dist; if( distance >= 0 ) { index.node.children[0]; } else { index.node.children[1]; } } return -index - 1; } bool BSPClusterCompare( bspFile info, int visCluster, int testCluster ) { if( info.numClusters == NULL || visCluster < 0 ) return true; int i = (visCluster * 8) + (testcluster >> 3 ); unsigned __int8 set = info.pvs[i]; return (set & (1 << (testCluster & 7))) != 0; } void BSPRender( glPoint campos, bspFile info ) { std::set<int> alreadyvis; std::vector<int> visible; int camleaf = BSPLeaf( info, campos ); int f; // Begin leaf iteration :) for( int l = 0; l < info.numLeaves; l++ ) { if( BSPClusterCompare( info, camleaf, info.leaf[l].visofs ) ) { for (int i = 0; i < leaf[l].numFaces; ++i) { f = i + leaf[L].firstFace; pair<iterator,bool> data = alreadyvis.insert( f ); if( data.second == true ) { visible.append( f ); } } } } for( int v = 0; v < visible.size(); v++ ) { switch( info.face[ visible[v] ].type ) { case 1: // Polygon break; case 2: // Patch break; case 3: // Meshes ??? break; case 4: // Billboard break; } } } Basically, I don't know how I would render any of them in any fashion - I'm fairly new to bsp trees and bsp30 files, so i'm not entirely sure. Any help would be appreciated Thanks, Oz~
  7. OpenGL HUD

    The coordinates using ortho mode should be the same as the window coordinates (as in if the res is 800x600, x goes 0-800, y goes 0-600) If you want true windows coords, use ScreenToClient( hWnd, POINT coords ); or ClientToScreen( <same parameters> ); Oz~ PS: glOrtho(0, winWidth, winTop, 0, -1, 1); that should fix it :p
  8. OpenGL HUD

    just print what you want to the screen...here's a routine from nehe's tutorial for printing...works just like printf in c GLvoid glPrint(GLuint glfontlist, GLfloat x, GLfloat y, const char *fmt, ...) { if( glIsList( glfontlist ) == GL_FALSE ) { // Error Report? return; } glRasterPos2f( x, y ); char text[256]; va_list ap; if(fmt==NULL) return; va_start(ap, fmt); vsprintf(text, fmt, ap); va_end(ap); glPushAttrib(GL_LIST_BIT); glListBase(glfontlist - 32); glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); glPopAttrib(); } it uses lists for the font...if you look through nehe's tutorials, and find some of the font/printing text tutorials, you find how to load such. hope that helps. Oz~ PS: int score = 50; glPrint( yourfont, 1.0f, 500.0f, "Your score is: %d", score );
  9. If my title is confusing, I'll try to explain it. Basically, I have a p3 in my laptop and an atholon in my PC. I'm writing a program on my laptop, but when i try it on my PC, it goes about 3x faster. How abouts would I make some type of delay that would adjust to the computer? if you want to take a look at the program, you are more than welcome to; it's located at this link: http://www.atosoftpp.digitalblackie.com/uploads/Hard%20Nova%20remake.rar Feel free to poke around on it. Ozwald~
  10. OpenGL HUD

    thanks, lc_overlord. That did the trick very nicely. Ozwald~
  11. OpenGL HUD

    I'm extremely new to OpenGL, but not game design (i used to use SDL). Is there any way to draw directly to the screen to do a HUD without having to use glTranslate or glRotate or anything else. Either opengl doesn't do this or I'm just looking through the wrong functions. Any insight would be awsome Ozwald~