Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

206 Neutral

About Quak

  • Rank
  1. hi, I use color picking to be able to select triangles in my ogl application. for user feadback I simply redraw the triangles that have been selected in a different color. while the user is in selection mode, the original unselected image is stored in an auxiliary buffer and copied over into the back buffer (glCopyPixels) before rendering the selected triangles. the problem is that I can not see the selected triangles (not even z-fighting artifacts) without clearing the z-buffer first. I have tried PolygonOffset and DepthOffset (maybe not correctly?) without succsess. maybe the glCopyPixels messes with the z-buffer? I have no idea right now where I could look for the cause of the problem, do you have any suggestions? here is some code I'm using: if(!selectionMode) drawColorBuffer(); //draw the image into GL_AUX0 glCopyPixels(0, 0, ww, wh, GL_COLOR); //copy image from GL_AUX0 to GL_BACK if(selectionIndices){ //draw selected triangles //glClear(GL_DEPTH_BUFFER_BIT); glLoadMatrixf(cam.getModelMatrix()); glEnable(GL_BLEND); glColor4f(1.0f, 0.0f, 0.0f, 0.25f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, triangleList->glVertices); glDepthRange(0.0f,0.9f); glDrawElements(GL_TRIANGLES, selectionIndices, GL_UNSIGNED_INT, selectionIndexList); glDepthRange(0.1f,1.0f); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); }
  2. Hi, I render two triangles to the screen and after that I read the depth buffer of opengl like that: glReadPixels( 0, 0, 640, 480, GL_DEPTH_COMPONENT,GL_FLOAT, (void*)dbuf ); To verify I print the values in dbuf to a file. However the values read from the depth buffer appear to be wrong. where no geometry is rendered the depth value are all 1.0. the depth values covered by the triangles is around 0.98. I would have expected 0.0 for no occlusion and much smaller values for the occluded regions as the triangles are close to the origin. any ideas what I could be doing wrong ? before rendering I clear the depth and color buffer btw. Thanks for your help, quak
  3. It comes after the code I posted. I moved the opengl code after setVideoMode() and now glGenBuffers returns 1. GL_VERSION is 2.1.2. Thank you very much for your fast replys, now I can sleep well :)
  4. My code looks like this: int main( int argc, char* argv[] ) { if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 ) return -1; g_engine.init( 512, 512 ); ... } void Engine::init( const uint resX, const uint resY ){ glEnable( GL_TEXTURE_2D ); glGenBuffers( 1, &pbo ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, pbo ); glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, 2048*2048*4, 0, GL_STREAM_DRAW_ARB ); ... }
  5. glGetString(GL_VERSION) returns <NULL>. If I call GLeeInit() and GLeeGetErrorString() afterwards, it returns "GL extension querying failed". I am sure that my driver and hardware supports buffer objects because I can run different applications that use them.
  6. Thanks, that worked. I included GLee.h and GLee.c in my project and I link against OpenGL32.lib. Linking against GLee.lib resulted in a "cannot find LIBC.LIB" error. However, if I use glGenBuffers it returns 0 which is wrong of course. I am using VC Express 2005 by the way.
  7. Yes, I know about Glee, however if I include the header additionally to my SDL_OpenGL.h I can't compile because of redefinitions. If I comment out these definitions in the SDL header I can compile but gleeInit() fails.
  8. hi, I have written an OpenGL application using SDL. Now I'd like to extend my application with pixel buffer objects. However I was not able to compile the code because glGenBuffers/glBindBuffer/glBufferData: identifier not found. I put #define GL_GLEXT_PROTOTYPES in front of #include SDL_OpenGL.h and was able to compile but not link my code because glGenBuffers/glBindBuffer/glBufferData: unresolved external symbol. How can I get this to work ? tahnks, quak
  9. Quak

    taylor series

    There is no problem with your approach, I've just wondered if there was a way to do it even faster. I've actually implemented your suggestion now, so thanks for that.
  10. Quak

    taylor series

    Yes right, but I still would have to calculate f(x) and f'(x) separatley. It is not possible to do something like that: f(x)=f(0)+k*f'(x), is it? thanks, quak
  11. Quak

    taylor series

    hi, I have a function f(x) which can be approximated by the taylor series: f(x)=f(0)+f'(0)x+f''(0)x²/2!...+f^(n)(0)x^n/n! I can precompute the constants Fn=f^(n)(0)/n! and use the Horner scheme to arrive at an efficient approximation: f(x)=F0+x*(F1+x*(F2...+x*Fn)) Now I also need f'(x). Unfortunately f'(x)!=F1+x*(F2...+x*Fn) beacuse of the different faculties. So my question is if there is a way to compute f(x) and f'(x) with a taylor series simultaneously. thanks, quak
  12. Assuming my k=4 because the 4th derivative f(4)(x)=0 then the supremum would simplify to max{ |f(2)(z)|1/2, |f(3)(z)|1/3 } right? How would I now solve for z, assuming I'm only interested in the interval 0<z<1 ? Use a guess value from the interval and if the test fails determine a better value for z and test again?
  13. Hi, I use Newton's Method to solve f(x)=0. In order to find a good initial guess I would like to use the Alpha-Test method descriped on Mathworld . However the information provided there is rather incomplete so I would really appreciate it if you elaborate on this method a bit. Explaining the "sub" notation to me would already be a good start. Thanks, quak
  14. Quak

    parallelepiped construction

    Do I have to clarify ? Or do you think the math is correct and there must be a programming error somewhere ? EDIT: pseudo code for my parallelepiped contruction algorithm vec3 pointset[POINT_NUM]; vec3 basis[3]; //basis vectors of parallelepiped (normalized) float mindist[3];//min distance of a point from the point set to the plane x*basis[j] = 0 (plane contains origin) float maxdist[3];//max distance... for( i=0; i<POINT_NUM; i++ ){ for( j=0; j<3; j++ ){ tmp = DotProduct( basis[j], pointset ); //distance of point pointset from plane x*basis[j] = 0 mindist[j] = min( mindist[j], tmp ); maxdist[j] = max( maxdist[j], tmp ); } } //midpoint of parallelepiped (intersection of 3 planes) midpoint = ((mindist[0]+maxdist[0])*0.5)*CrossProduct(basis[1], basis[2]) + ((mindist[1]+maxdist[1])*0.5)*CrossProduct(basis[0], basis[2]) + ((mindist[2]+maxdist[2])*0.5)*CrossProduct(basis[0], basis[1]) / (DotProduct(basis[0]*CrossProduct(basis[1],basis[2])); [Edited by - Quak on November 2, 2006 8:13:44 AM]
  15. hi, this is my second post concerning parallelepipeds, so I quote my definition of a parallelepiped from there: Quote:I have a set of points and 3 normal vectors(n1,n2,n3) which can be anything but parallel. These 3 normal vectors represent 3 planes containing the origin. The min and max distances of all points to the 3 planes are evaluated and used as offsets for the 3 planes from the origin which gives me 6 planes: 0 = (n1*x) - min1; 0 = (n1*x) - max1; ... 0 = (n3*x) - max3; These 6 planes form a parallelepiped that encloses all points. To find the midpoint of the parallelepiped I compute 3 more planes: 0 = (n1*x) - (min1+max1)/2; 0 = (n2*x) - (min2+max2)/2; 0 = (n3*x) - (min3+max3)/2; The intersection of these 3 planes is the midpoint of my paralellepiped. However this doesn't seems to be always correct. In some cases points of the set I want to enclose in the parallelepiped are slightly outside the bounding volume. Here is a picture to give you an example. I have marked the points with a red circle which are outside the parallelepiped(the white net is defined by the points, the blue box is the parallelepiped). I have checked for precision errors but this is not the case. Can you see any mathematical flaw in the definition of my parallelepiped which could explain the error ? thanks, quak
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!