Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

197 Neutral

About BraXi

  • Rank
  1. NeHe wrote nice tutorial about creating terrain from height maps, which was later ported to Java, you should probably read this: http://nehe.gamedev.net/tutorial/beautiful_landscapes_by_means_of_height_mapping/16006/
  2. BraXi

    Weird rendering bug

    Nevermind, I found it was caused by other function in my engine.
  3. Hello, I've recently ran into trouble regarding rendering of Q3 BSP. So I've readen all important data from bsp and checked all pointers to data from mesh and I'm trying to render level with vertex arrays. Somehow, instead of level I'm seeing weird planes (picture below): http://s6.ifotos.pl/img/bug3JPG_xnaxrhn.JPG And this is what I'm trying to render: http://s4.ifotos.pl/img/radiantsh_xnaxsns.JPG At the rendering stage I'm rendering only brushes (polygon groups built from triangles) with this function: void BSPMesh::RenderPolygonFace( int faceIndex ) { tBSPFace *pFace = &m_pFaces[faceIndex]; glVertexPointer( 3, GL_FLOAT, sizeof(tBSPVertex), &m_pVerts[pFace->startVertIndex].vPosition ); glTexCoordPointer( 2, GL_FLOAT, sizeof(tBSPVertex), &m_pVerts[pFace->startVertIndex].vTextureCoord ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); if(0) { glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, m_textures[pFace->textureID] ); } glDrawElements( GL_TRIANGLES, pFace->numOfIndices, GL_UNSIGNED_INT, &m_pIndices[pFace->startIndex] ); glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); } I'm using OpenGL 2.0 on a Nvidia GF 7600GS - yeah it's pretty old card.
  4. Thank you wqking ;) I owe you one Complete code and projects for VC++2010 are here: http://www.braxi.org/stuff/dll_library_cpp.rar
  5. @wqking I tried to make pointer but it seems i cannot cast value of getprocaddress to a pointer, it would require diferent cast and to be honest it can't compile on VC++2010. compiling failed with error message that it cannot be converted (i've changed my vars to pointers as well), error is highligted: GetAPI_t *GetAPI; [...] GetAPI = (GetAPI_t*)GetProcAddress( library, "GetAPI" ) At the moment I'm at school but i will upload my newer code as soon as i get back.
  6. So I was experimenting with DLL files and i though about sharing dynamic array of objects between DLL and EXE. The only thing worth studying was quake 3, which loaded DLL to call game rules and manage objects, while EXE was only providing some data-access functions (for example rendering). After studying the code I've written test application in C that would load DLL file and share specified variables with program. I was a bit confused when once set variables were unable to update, for example i've initialized myVar with value of 1 and later tried to change it 2. For some reason, value wasn't updated in EXE. I'd like to know how can i link dll dynamicaly so i can update variables in EXE with DLL. I will attach some code here to show what i mean. //This code is shared by both DLL and EXE in a "shared.h" #include <iostream> #include <windows.h> using namespace std; typedef struct { void (*TestDLLFunc)(); int testVal; int *testArray; } libExport_t; typedef struct { int simpleVal; } exeExport_t; typedef libExport_t (*GetAPI_t) (exeExport_t); libExport_t DLLCode; exeExport_t EXECode; // DLL code #include "shared.h" void TestFunc() { printf( "This message was sent from DLL\n" ); printf( "EXECode.testVal = %i\n", EXECode.testVal ); //this printed value 2012 // this is supposed to update array for EXE DLLCode.testArray = new int[4]; //c++ for( int i = 0; i < 4; i++ ) DLLCode.testArray = i; Sleep( 100 ); DLLCode.testVal = 2; } libExport_t GetAPI( exeExport_t import ) // dll's entry point { EXECode = import; //initialize exe functions for dll DLLCode.TestDLLFunc = TestFunc; DLLCode.testVal = 1; DLLCode.testArray = NULL; return DLLCode; } // EXE code #include "shared.h" HINSTANCE library; void LoadTestLibrary( const char *name ) { GetAPI_t GetAPI; printf( "Loading %s\n", name ); library = LoadLibraryA( name ); if( library == 0 ) printf( "LoadLibraryA(\"%s\") failed\n", name ); if( ( GetAPI = (GetAPI_t)GetProcAddress( library, "GetAPI" ) ) == 0 ) { printf( "Couldn't retrieve vaild adress\n", name ); } EXECode.simpleVal = 2012; DLLCode = GetAPI( EXECode ); if( !DLLCode ) printf( "DLL not loaded\n" ); } int main() { LoadTestLibrary( "test.dll" ); DLLCode.TestDLLFunc(); Sleep( 200 ); // just to make sure everything chaged if( DLLCode.testArray != NULL ) { for( int i = 0; i < 4; i++ ) printf( "array element is: %i\n", DLLCode.testArray ); } // this should be 2 printf( "DLLCode.testVal = %i\n", DLLCode.testVal ); return 0; }
  7. BraXi

    Rendering concept

    Yeah it worked ;) Occasionaly there's only a little diference in performance between my <poor> method and yours.
  8. BraXi

    Rendering concept

    Thanks for feedback, I'm currently using pointers in my array and ATC your idea seems to fit into my engine. I can't write too much in this post now because I'm about to go somewhere. I will reply when i test your method. Thanks again ;)
  9. BraXi

    Rendering concept

    I mean changing item order, it could take some time if I'm right.
  10. BraXi

    Rendering concept

    Thanks for idea but doesn't array changing result in performance drop?
  11. Hello, I have one concept idea for rendering and I'm not sure if it's good technique and if there any better. At initialization i made array with 4096 slots for objects that later will be rendered in 3D mode (players, monsters, props) and to add object to screen i use: (pseudo code) Object *obj = spawnobject(); obj->origin = (0,0,0); obj->modelIndex = 4; <- the model i want render obj->show = true; obj->deleteTime = currenttime + 3000; <- time in miliseconds spawnobject() is searching for free slots in object array and returns pointer to object. That way i don't need to add objects to list each time i redraw scene, which i think is faster than creating array of objects each time. At rendering stage i do this: for( i=0; i < max objects; i++, object++ ) { if( !object->used ) continue; if( object->deletetime >= current time ) { deleteobject( object ); continue; } <at this stage I'm determining which object is visible and if everything is ok i render actual model at given origin> } To delete objects i simply memset() all values and change object->used to false to free the slot. Is this method okey? Maybe you have better ideas? I wonder if there are better methods and i would like see your feedback.
  12. BraXi

    Game Engine Programming

    I suggest you to start your work in following order: Simple window with initialized DX renderer Image loader / Material Manager Timer Input Camera Model loader / Model Manager Shader Manager (load & compile hlsl shaders and use then im rendering) Collision detection/physics, i suggest You to use free physics library, Newton Physics is good and free for commercial products Entity manager to dynamicaly create and delete objects (for example. guns, medkits, enemies etc), this should be running at constant 30fps so it will be easier to update games over network User Interface (menus, huds...) Sound engine, OpenAL should be good enough to give it a try Particles & effects Post processing Networking and prediction This is enough to create a game, rest will depend on what else you need. I'm still creating engine for my game and so far it took me 5 months and im fighting with optimilizations and networking, networking is the worst thing you will have to deal with.
  13. I've prepared simple code to help you with creating and rendering VBO, i hope this helps you. If it doesn't work then check your projection and modelview matrices and make sure you aren't using core profile of GL 3.0+. [source lang="cpp"]typedef struct vert //32 bytes per vertex { float origin[3]; float normal[3]; float uv[2]; } vert_t; #define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i)) unsigned int vbo; //this is our vbo id void InitVBO() { int numVerts = 3; vert_t *verts = new vert_t[numVerts]; //add some verticles verts[0]->origin[0] = -2.0f; verts[0]->origin[1] = 0.0f; verts[0]->origin[2] = 0.0f; verts[1]->origin[0] = 2.0f; verts[1]->origin[1] = 0.0f; verts[1]->origin[2] = 0.0f; verts[2]->origin[0] = 0.0f; verts[2]->origin[1] = 3.0f; verts[2]->origin[2] = 0.0f; int size = (int)(numVerts * sizeof(vert_t)); //this is required by VBO // create and bind vbo glGenBuffersARB( 1, &vbo ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB ); glBufferSubDataARB( GL_ARRAY_BUFFER_ARB, 0, size, &verts[0]->origin[0] ); //bind data to buffer // dont need verticles in ram memory anymore, unless you want to modify them at a later time delete[] verts; } // this is how we draw VBO // I didn't mention GL_COLOR_ARRAY but i think you will know how to implement it when you look at this code. void DrawVBO() { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo ); // bind our VBO for drawning glVertexPointer( 3, GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(0) ); glNormalPointer( GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(12) ); glTexCoordPointer( 2, GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(24) ); glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); } // delete vbo buffer when you don't need it anymore. void DeleteVBO() { if( !vbo ) return; glDeleteBuffersARB( 1, vbo ); }[/source]
  14. Well now i'm in another trouble, my objects became transparent, i like how the lights blend but the rest should be solid. btw. thank you Radikalizm for idea, i will try doing it your way.
  15. Thanks Hedanito, it worked ;) This shows how i render the lighting: -[set blending] -[bind lighting shader] --[for each visible light] ----[send lightPos, radius and color to shader] ----[render quad] -[unbind shader] PS. sorry for double post, my connection lagged a bit.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!