Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Projection & Rasterization issues

This topic is 3085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to do a simple raster (only shapes, no light, no colors) for an occlusion test. I give 3 points (on the screen coordinates) to the raster and it draws the polygon.
So, before i need to process my 3d polygons vertices on object coordinates and convert them to screen coordinates, i google'd, search and stuff and came up with an algorithm that is similar to the gluProject (which i found on mesa source).

gluProject documentation: http://www.opengl.org/sdk/docs/man/xhtml/gluProject.xml

x y z w
v = (object.x, object.y, object.z, 1.0)
P = Projection Matrix
M = ModelView Matrix
Viewport = (0, 0, 512, 512)

v' = P x M x v
v' = v' / v.w // We divide every xyzw by w, this step is not in the gluProject documentation.

screen.x = Viewport(0) + Viewport(2) * (v'.x + 1) * 0.5
screen.y = Viewport(1) + Viewport(3) * (v'.y + 1) * 0.5
screen.z = (v'(2) + 1) * 0.5


Well, after that, my problem is the following:

When i have an scenario like:
  • is a polygon and C is a camera, and > is the frustum

    [****] > C

    Everything is ok, the screen values are inside and the triangles get draw. But if i rotate along Up Axis, the polygon starts to disappear, the points get outside the screen, for instance: A point starts poping out for the right, and tends to get positive, and grow bigger bigger (no big problem), but it gets to a point where it is on the LEFT side of the screen... Am not sure what is really happening or how to fix it. Any help would be really usefull.

    Some screens:

    This is when i start rotating and things are good.

    This is when i rotate more the camera and things get screw up: http://dl.dropbox.com/u/7600660/bad.png
    Notice that the points get to the left side. (the points that are in the left side, should be on the right side)


    Share this post

    Link to post
    Share on other sites
    Sign in to follow this  

    • 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!