bovinedragon

Members
  • Content count

    64
  • Joined

  • Last visited

Community Reputation

122 Neutral

About bovinedragon

  • Rank
    Member
  1. glsl depth offset

    I have a depth map texture that I want to use as a depth offset per fragment, but it is giving me view dependent results. I tried gl_FragCoord.z plus offset, but it gave incorrect results. I read that the depth buffer is not linear or something? What would be the proper way to do this.
  2. measuring FPS

    actually i spoke too soon, it still says 60 fps. this seems to work tho, is this a good way to do it? timer.start(); scene->render(); glFinish(); timer.stop(); render_timer=timer.getTimeInSeconds(); SwapBuffers(hDc);
  3. measuring FPS

    thanks scratt, just what i was looking for. I think i will try that seperate cpu timer just for fun too.
  4. measuring FPS

    would doing something like this provide accurate fps? start_timer(); render(); end_timer(); SwapBuffers(hdc); i am wondering because dont render commands(im using opengl) return immediately, even if the graphics card is not done rendering, which would make this show faster fps than actual if my app has a graphics card bottleneck?
  5. measuring FPS

    When i measure my fps, it caps at 60 fps, which is what it is displaying at, but how do i measure the actual rendering fps, like 130 or whatever it is,. This is what I currently have for my main loop, i am using windows. This is a timer class i found, and then my main loop: ####### TIMER CLASS ####### struct ProfTimer { void start(void) { QueryPerformanceCounter(&mTimeStart); }; double GetDurationInSecs(void) { QueryPerformanceCounter(&mTimeStop); LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); double duration = (double)(mTimeStop.QuadPart-mTimeStart.QuadPart)/(double)freq.QuadPart; mTimeStart=mTimeStop; return duration; } LARGE_INTEGER mTimeStart; LARGE_INTEGER mTimeStop; }; ######## my main loop ########## bool quit=0; ProfTimer timer; double render_time=0.016; timer.start(); while ( !quit ) { // check for messages if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // handle or dispatch messages if ( msg.message == WM_QUIT ) { quit = TRUE; } else { scene->postMessage(&msg); TranslateMessage( &msg ); DispatchMessage( &msg ); } } else { glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); scene->render(); render_time=timer.GetDurationInSecs(); glprint(1.0/render_time,0.0,0.0); SwapBuffers( hDC ); } } }
  6. OpenGL Making a better push button.

    ive heard of "glui", never used it tho http://glui.sourceforge.net/
  7. Particles

    I do not have a graphics card that supports GLSL, its old :( that extension looks useful, ill try using that What kind of culling techniques are there for particles. I would just sort them from to back, and render them in that order. Is that good? Any good articles maybe?
  8. Particles

    In a particle engine what is the fastest way to render particles? If the particles are small images, you would have to use two billboarded triangles. Since it is so little vertexes, things like vbo seem like overkill. Is there any way faster than just intermediate mode, or is culling the only way to speed it up.
  9. OpenGL model "instancing" with opengl

    glrotate/gltranslate, then draw vbo
  10. Introduction, and Geo-wars grid effect,

    I made a geo wars clone as my second game i made. For the grid I had a node at each of the points, with a position and a velocity. All of the nodes were connected to their "at rest" position by a spring, with no forces from node to node. When there was a bullet/hole, all the nodes within a certain distance of it would accelerate away/toward it. I posted the game/source on my site, but keep in mind, it was my second game i ever made, so it is REALLY poorly written and undocumented, but maybe you can get something ideas at least. http://bovinedragon.freehostia.com/games/vector.php
  11. resizing texture

    it works now, i am using c++, its just the code i am using is apparently c, work fine with new, thx
  12. resizing texture

    It is still crashing on the gluScaleImage, I am not sure how to make the buffer, I tried the way that the normal textures are made. also Seems to be a c-style way of doing it, should i be doing this with new and delete? #define tot_textures 20 GLuint texture[tot_textures]; int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[tot_textures]; // Create Storage Space For The Textures memset(TextureImage,0,sizeof(void *)*tot_textures); // Set The Pointer To NULL if ((TextureImage[0]=LoadBMP("Data/grass.bmp")) && (TextureImage[1]=LoadBMP("Data/ice.bmp")) && (TextureImage[2]=LoadBMP("Data/sword.bmp")) && (TextureImage[3]=LoadBMP("Data/bark.bmp")) && (TextureImage[4]=LoadBMP("Data/tree.bmp")) && (TextureImage[5]=LoadBMP("Data/brick.bmp")) && (TextureImage[6]=LoadBMP("Data/roof.bmp")) && (TextureImage[7]=LoadBMP("Data/rock.bmp")) && (TextureImage[8]=LoadBMP("Data/skyclouds.bmp")) && (TextureImage[9]=LoadBMP("Data/chest.bmp")) && (TextureImage[10]=LoadBMP("Data/goldbag.bmp")) && (TextureImage[11]=LoadBMP("Data/warrior.bmp")) && (TextureImage[12]=LoadBMP("Data/weapshop.bmp")) && (TextureImage[13]=LoadBMP("Data/hosshop.bmp")) && (TextureImage[14]=LoadBMP("Data/shop.bmp")) && (TextureImage[15]=LoadBMP("Data/golem.bmp")) && (TextureImage[16]=LoadBMP("Data/hellpig.bmp")) && (TextureImage[17]=LoadBMP("Data/water.bmp")) && (TextureImage[18]=LoadBMP("Data/screen.bmp")) && (TextureImage[19]=LoadBMP("Data/icons.bmp"))) { Status=TRUE; glGenTextures(tot_textures, &texture[0]); for (int loop=0; loop<tot_textures; loop++) { AUX_RGBImageRec* buffer; //Is this the way to make the buffer? memset(buffer,0,sizeof(void*)); //should i use new? not familiar with memset gluScaleImage(GL_RGB,TextureImage[loop]->sizeX,TextureImage[loop]->sizeY,GL_UNSIGNED_BYTE,TextureImage[loop]->data,TextureImage[loop]->sizeX/4,TextureImage[loop]->sizeY/4,GL_UNSIGNED_BYTE,buffer); //CRASH glBindTexture(GL_TEXTURE_2D, texture[loop]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, buffer->sizeX, buffer->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer); free(buffer->data); } } for (int loop=0; loop<tot_textures; loop++) { if (TextureImage[loop]) // If Texture Exists { if (TextureImage[loop]->data) // If Texture Image Exists { free(TextureImage[loop]->data); // Free The Texture Image Memory } free(TextureImage[loop]); // Free The Image Structure } } return Status; // Return The Status } And also, is there any difference in using GLuint, and unsigned int?
  13. resizing texture

    The program is crashing, so i dont think i am accessing the data right. This is what my load texture code is, its from a nehe tutorial #define tot_textures 20 GLuint texture[tot_textures]; int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[tot_textures]; // Create Storage Space For The Textures memset(TextureImage,0,sizeof(void *)*tot_textures); // Set The Pointer To NULL if ((TextureImage[0]=LoadBMP("Data/grass.bmp")) && (TextureImage[1]=LoadBMP("Data/ice.bmp")) && (TextureImage[2]=LoadBMP("Data/sword.bmp")) && (TextureImage[3]=LoadBMP("Data/bark.bmp")) && (TextureImage[4]=LoadBMP("Data/tree.bmp")) && (TextureImage[5]=LoadBMP("Data/brick.bmp")) && (TextureImage[6]=LoadBMP("Data/roof.bmp")) && (TextureImage[7]=LoadBMP("Data/rock.bmp")) && (TextureImage[8]=LoadBMP("Data/skyclouds.bmp")) && (TextureImage[9]=LoadBMP("Data/chest.bmp")) && (TextureImage[10]=LoadBMP("Data/goldbag.bmp")) && (TextureImage[11]=LoadBMP("Data/warrior.bmp")) && (TextureImage[12]=LoadBMP("Data/weapshop.bmp")) && (TextureImage[13]=LoadBMP("Data/hosshop.bmp")) && (TextureImage[14]=LoadBMP("Data/shop.bmp")) && (TextureImage[15]=LoadBMP("Data/golem.bmp")) && (TextureImage[16]=LoadBMP("Data/hellpig.bmp")) && (TextureImage[17]=LoadBMP("Data/water.bmp")) && (TextureImage[18]=LoadBMP("Data/screen.bmp")) && (TextureImage[19]=LoadBMP("Data/icons.bmp"))) ) { Status=TRUE; glGenTextures(tot_textures, &texture[0]); for (int loop=0; loop<tot_textures; loop++) { glBindTexture(GL_TEXTURE_2D, texture[loop]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data); } //*********my atempt to resize the first texture********** GLuint buffer; gluScaleImage(GL_RGB,256,256,GL_UNSIGNED_INT,&texture[0],32,32,GL_UNSIGNED_INT,&buffer); } for (int loop=0; loop<tot_textures; loop++) { if (TextureImage[loop]) // If Texture Exists { if (TextureImage[loop]->data) // If Texture Image Exists { free(TextureImage[loop]->data); // Free The Texture Image Memory } free(TextureImage[loop]); // Free The Image Structure } } return Status; // Return The Status } I am guessing that you cant have the same input and output source, so i put a buffer. Do i have to format the GLuint buffer into a texture before i can work with it? And how would i copy the buffer into the original "texture[0]"
  14. resizing texture

    If i have my textures already loaded, and they are 256x256, how can I resize them with code to be something else, like 128x128? i found gluScaleImage, but i cant get it to work, is this what i need to use?
  15. Lighting + Color

    When i use lighting, it overrides my glColor3f();, and shows white to black only. Is there a way to use lighting with glColor3f();