Results 1 to 4 of 4

Thread: OpenGL Coord System Beginner Question

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    charleston, IL
    Posts
    6

    OpenGL Coord System Beginner Question

    Hi. I'm a very new beginner to OpenGL, and I was wondering how to use glLoadMatrix()with glFrustum() to use real coordinates to set up the screen so my cubes stay cubes instead of changing to rectangles. I want to do this by having my coordinate system (0,0,0)-(640,480,800).

    I also want to be able to convert the depth of a point -lets say (40, 40, 15)- to a 2D coordinate -like that point being (50, 50)-, and I want a 3D coordinate from a 2D coordinate at a specific z value, like to find the max (x,y,z) that still is visable on the screen - (640,480).

    I'm pretty desprate to using a forum to find out how this is done, so any websites you can find will be very useful. The biggest thing that troubles me is setting up the coordinate system. The other things I know well enough. I have LaMothe OpenGL book if you know of anything in there that could be of help. Sorry for being such a beginner and about not wanting to convert my programming to OpenGL's native coordinate system.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    365

    Re: OpenGL Coord System Beginner Question

    You can specify/set up any coordinate system you like. I suggest you find some information on how "viewing" works in a 3d world. Here is a link to the opengl programming guide. Check out chapter 3.
    http://www.dcc.unicamp.br/~lmarcos/c...mc603/redbook/

    After that, download and play with nate robbins projection and transformation tutorials. They are great! http://www.xmission.com/~nate/tutors.html

    not wanting to convert my programming to OpenGL's native coordinate system.
    The only thing "native" with OpenGL's coordinate system is that it by default is a right handed coord.sys. and has the camera facing down the z axis at the origin. With some transformations you can change this to whatever you want.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    charleston, IL
    Posts
    6

    Re: OpenGL Coord System Beginner Question

    Thanks, roffe, for the link. I hate being a beginner in C++ when my mathmatics work using the console or qbasic (scientific calculator basic as well). I still have a problem setting up the projection matrix and understanding matrix's, based on them being constants, while I want to use them with variables.

    I am basically trying to set up a Cad like enviroment in which each pixel is being taken into account, and each decrease of z results in viewpoint square being reduced by one pixel wide on each side to a single pixel being z = 1. I want artificial depth from my qbasic programs math to work inside opengl. Scaling and zooming is the only way I want of making depth.

    What I want is |z/(MaxZ * MaxX), 0, 0, 0|
    |0, z/(MaxZ * MaxY), 0, 0|
    |0, 0, z, 0|
    |0, 0, 0, 1|
    but the values in the matrix must be constants, thus each call to glVertex3d(...) needs each value calculated before sending the param's though. I have taken calculus, so this shouldn't boggle my mind to much, it's just using constants rather than variables that doesn't make sense to me yet. If you know of a link that deals with matrix's, and what each value in a matrix represents, I would be most greatful.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    charleston, IL
    Posts
    6

    Re: OpenGL Coord System Beginner Question

    GLfloat Matrix =
    {2.0f / MaxX, 0.0f, 0.0f, -1.0f,
    0.0f, 2.0f / MaxY, 0.0f, -1.0f,
    0.0f, 0.0f, 0.0f, -1 / MaxZ,
    0.0f, 0.0f, -1.0f, MaxZ};

    // thus,
    // NewX = (x * 2 / MaxX - 1.0f) *
    // ((MaxZ - z) / MaxZ);
    // NewY = (y * 2 / MaxY - 1.0f) *
    // ((MaxZ - z) / MaxZ);
    // NewZ = -(MaxZ - z) / MaxZ;

    I want to use this with glMatrixMode(GL_PROJECTION); glLoadMatrix(Matrix);, but I haven't had a computer that has C++ on it, so if anyone can figure out for me if this works / how to correct it, I would be most greatful.

Similar Threads

  1. Opengl es very beginner question
    By eshvartz in forum OpenGL ES
    Replies: 1
    Last Post: 11-26-2011, 07:49 AM
  2. OpenGL ES beginner question
    By opengles82 in forum OpenGL ES
    Replies: 1
    Last Post: 09-24-2009, 11:40 AM
  3. OpenGL ES beginner question
    By jfazekas in forum OpenGL ES
    Replies: 2
    Last Post: 11-06-2008, 10:54 AM
  4. Replies: 1
    Last Post: 03-18-2004, 05:10 PM
  5. Coord system question.
    By LostInTheWoods in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-16-2002, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean