6 Replies - 659 Views - Last Post: 30 July 2012 - 03:00 AM Rate Topic: -----

#1 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

OpenGL - some commands I don't get

Posted 27 July 2012 - 02:10 AM

Okay, so I got this crazy idea that I wanted to learn some OpenGL, and I wanted to use Python, because... I like Python a lot. I managed to get it up and running, and make a script which displays a black square on a white background - so far so good.

I've been roaming the internet in my search for tutorials, and most of what I found is outdated and badly written. The most useful thing I found for Python was an example program on a random blog - that and google got me a long way, as well as some C++ tutorials, even though I use different libraries (pygame instead of GLUT). Over the last few days, I've gone from stuff like this tutorial looking like gibberish to actually being able to skim the code and know what it does.

I've got two problems right now. First, every single tutorial I've found says that the following code is super important, but doesn't say what it does:

glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()



As I understand it, there are three matrices (projection, modeview and texture) and glLoadIdentity() sets the current matrix to a standard value (the identity matrix). Can anyone explain what exactly each matrix describes? The best I've been able to find is stuff like this:

GL_MODELVIEW
Applies subsequent matrix operations to the modelview matrix stack.



Doesn't really tell me a lot...

My second problem is that I can't find a good tutorial for vbo's or shaders, which I understand is something I ought to learn. Is this even something I should look at as a beginner in OpenGL, or should I focus on simpler stuff? Can anyone point me at a good tutorial (preferably Python, but C++ is ok too)?

Is This A Good Question/Topic? 0
  • +

Replies To: OpenGL - some commands I don't get

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,208
  • Joined: 14-February 08

Re: OpenGL - some commands I don't get

Posted 27 July 2012 - 02:51 AM

You can't really get a better description than this

http://www.songho.ca..._transform.html

...and I would focus on learning the basics before jumping into shaders or VBO's.

Hope that helps :)
Was This Post Helpful? 1
  • +
  • -

#3 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

Re: OpenGL - some commands I don't get

Posted 27 July 2012 - 02:55 AM

Thanks! I'll be reading :-)
Was This Post Helpful? 0
  • +
  • -

#4 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 586
  • View blog
  • Posts: 1,301
  • Joined: 24-April 12

Re: OpenGL - some commands I don't get

Posted 27 July 2012 - 07:41 AM

I've never seen Python code, and I haven't seen a lot of OpenGL code, and it's been forever since then.

But I can make a pretty good guess at what those are.

The view matrix is essentially "your camera". You can change it's position and facing direction with this. I could go into the details on how this works, but that's basically all you need to know to make use of it a lot of times.

The projection matrix is vaguely similar to lenses on a camera. What it "actually" does is convert your 3D world into 2D pixels on a 2D computer screen. It will give you a field of view, which is sort of like wide angle, normal, or zoom lenses. And it will give you a near and far clipping plane (which if you really wanted to take the camera analogy foward you might compare to the focal plane although that's not what it does). Anything closer than the near clipping plane won't be drawn. Anything further than the far clipping plane won't be drawn.

You may also have a world matrix for every object in your scene that stores the sizing, positional, and orientation information for that model. Again, I could go into the technical details of how a world matrix mathematically translates from model space to world space, but to get started you just need to know that it controls your model's placement in the 3D world.
Was This Post Helpful? 0
  • +
  • -

#5 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

Re: OpenGL - some commands I don't get

Posted 27 July 2012 - 10:45 AM

Thanks, both of you! I'm beginning to figure this out... I even made me a rotating pyramid:

Attached Image
Was This Post Helpful? 0
  • +
  • -

#6 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 586
  • View blog
  • Posts: 1,301
  • Joined: 24-April 12

Re: OpenGL - some commands I don't get

Posted 27 July 2012 - 10:55 AM

Cool!
Was This Post Helpful? 0
  • +
  • -

#7 Java Student  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 481
  • Joined: 05-February 10

Re: OpenGL - some commands I don't get

Posted 30 July 2012 - 03:00 AM

Good job! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1