Jump to content
  • Advertisement

TomasH

Member
  • Content Count

    382
  • Joined

  • Last visited

Community Reputation

360 Neutral

About TomasH

  • Rank
    Member
  1. Quote:Original post by AfroFire first off - whenever you do any rotations or anything with the camera make sure you change the matrix mode to GL_PROJECTION, then switch back to GL_MODELVIEW to move lights around ,etc... Mmmm... no. The projection matrix should only define the type of projection (so to speak), meaning glFrustum, glPerspective, glOrtho etc. Think of it as the matrix stack that is used to choose the lens for your camera (but not the position/orientation of it). The modelview matrix is used for all rotations and translations, whether you consider them moving the camera, an object or a light source. Perhaps posting some code would help?
  2. (You can't do this particular conversion with the color matrix - sorry for the misinformation, don't know what I was thinking :))
  3. Hmm... Might the problem not be that the GLUT mouse callback is only called when a mouse button is pressed or released, not when it's held down? If that's the case, then move the code for drawing the string to your display function. (Although that's what it sounds like you're already doing in your description, just not in the code you posted). Also, a glutPostRedisplay() in the end of the mouse callback (at least when button==GLUT_MIDDLE_BUTTON) would probably be a good idea. If you already draw the string in your display function (when mid_mouse_down is true), then make sure that you're not transforming the coordinates in a way you don't want to - remember that the coordinates sent by glRasterPos are transformed by both modelview and projection matrices.
  4. The "best" way would be to do this before you transfer the texture to OpenGL. I.e. before you've done glTexImage2D, you either loop through the pixels and check for 00FFFF00 and alter them, or you setup the color matrix to do this conversion for you. (If you do it with the color matrix, remember to set it to identity after you've transfered the texture(s) with glTexImage2D). If you really need to do this for a texture you already transfered, use glGetTexImage to fetch the texture, and then do the conversion as above.
  5. TomasH

    OpenGL render in black and white

    Quote:Original post by Malchivus ... or you could just use the color matrix to rescale the rgb values. The color matrix is applied to pixel transfers, like glDrawPixels and glTexImage2D, not "normal" rendering. To use it in this case you'd have to render the scene, copy to a texture and render again. A shader should work fine, though.
  6. TomasH

    OpenGL shade model

    There's no averaging done, the color comes from a single vertex. There's a table in the man page that shows this: ------------------------------------- Primitive Type of Polygon i Vertex ------------------------------------- Single polygon (i≡1) 1 Triangle strip i+2 Triangle fan i+2 Independent triangle 3i Quad strip 2i+2 Independent quad 4i ------------------------------------- So a single polygon gets its color from the first vertex. Triangle i (counting from 1) in a strip gets its color from vertex i+2 in the strip, and so on.
  7. What's up with me getting logged out these last days?? Anyway, AP above was me :)
  8. Ok, here's (what I think is) the problem. In your draw function, you set up your camera for the scene. Then you push it and (in the gui drawing code) create a new transformation (that glTranslate again). Obviously, after drawing you pop the matrix again... So when the callback is called, the modelview matrix contains the wrong information - the viewing transformation for the scene, not the gui. What you could do is save the modelview matrix after you've set the gui transformation (in GDEM_GUI::drawGui()) and use that for the call to gluUnProject. Some other, unrelated comments: * I'm pretty sure you don't need a glutPostRedisplay() in your resize function - Glut will redraw anyway. * You set the last three parameters to gluLookAt to 0.0, 1.0, 0.0. These parameters are supposed to be the camera's up, not the worlds. Just setting them to 0,0,1 will give you problems if your view is parallell to the y-axis. * Your near and far planes are quite far apart (1.0 and 20000.0). If possible - i.e. if your scene allows it - I'd recommend moving them as close together as possible to get the best z-buffer precision you can. Hope you get it to work now :D
  9. Ok, so basically that glTranslatef is your viewing transformation. That means that the array model (in convert_pixels) should look like this: 1.0,0,0,0, 0,1.0,0,0, 0,0,1.0,0, -0.75,0.75,-3.0,1.0 so that's one thing you could check.. Another thing you could check (and/or post) is how you setup your projection matrix. Don't know if that has anything to do with the problem, but you might as well take an extra look at it.
  10. TomasH

    normal maps

    Well... There's DOT3-bump mapping (GL_ARB_texture_env_dot3), if that's what your looking for?
  11. Well, I can't see anything obviously wrong.. The thing I can think of is that you should check that the matrices you send to gluUnProject are correct (as I posted in the above-mentioned thread).. Other than that, there's always the standard trick of trying to reduce your program to smallest/simplest possible code that shows the problem and see if you can figure out what's wrong (or if not, you could post some code and see if someone else can tell.) Good luck :)
  12. Well, you clear the depth buffer before reading from it, meaning you'll always get the same value from it.. Remove the glClear. Also, %d is for printing integers. You should use %f when printing the elements of "win" (since they are floats) Topic on gluUnProject
  13. glutPassiveMotionFunc is what you want. To convert from screen coordinates to world coordinates, use gluUnProject. (Search the forum or google for more info.)
  14. Yes, I think it would work fine. For more interesting effects, you could check out glFogCoord (available as an extension and in 1.4, if I recall correctly). The less efficient way you mention (blending a quad over the screen) might be worth it if the quad has a nice texture. Like Perlin noise, for example.
  • 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!