🔒 Locked
Comments on the Lesson2Tutorial draft
Advertisement
Original Post
Hello everybody, after deciding to really start writing during our meeting, I finally put my first draft of lesson02 into the wiki. It's not yet finished and not spell and grammar checked, but it's teh first lesson that's online, hehe.. Any comments, hints, or is something missing, bad explained or whatever? Please constructive critizism...(I know my English isn't perfect) [Edited by - Caste on August 16, 2006 12:26:50 PM]
Very nicely done :) To the point and fits the spec. Things to discuss follow.
I think this should be right handed system. I think this might confuse some readers; particularly those without a strong math background. While I definitely agree that some mathematical topics require some detailed coverage, the right handed system is probably not one of them. Specifically because most if not all three dimentional systems are right handed.
In the past, the units used in GL have been quite confusing to beginners. Perhaps a bit more elaboration. See my edit at the end of the reply for details.
Should we elaborate on color theory or maybe link to an external explanation?
...At this point in my reply I kinda got a bit carried away with minor edits and some rewording. You'll find the cumulation of my work at the end of this post. But before that we should discuss the use of strips. In the past, the use of triangle strips and strips in general have been confusing. Perhaps we can discuss the use of strips when we do our tutorials on ortho mode or one of the later tutorials? And now for the edit...
I'm concerned that my edit needs to explain the code a bit more. I hope it helps with your revisions :)
Cheers,
- llvllatrix
Quote:
These represent a point somewhere in a lefthanded coordinate system which OpenGL internally uses.
I think this should be right handed system. I think this might confuse some readers; particularly those without a strong math background. While I definitely agree that some mathematical topics require some detailed coverage, the right handed system is probably not one of them. Specifically because most if not all three dimentional systems are right handed.
Quote:
The distances in this coordinate system are just units, no meters or feet or anything else. The size of a unit depends on the size of the objects drawn.
In the past, the units used in GL have been quite confusing to beginners. Perhaps a bit more elaboration. See my edit at the end of the reply for details.
Quote:
Where each component is a color value between 0 and 1, where 1 means full intensity.
Should we elaborate on color theory or maybe link to an external explanation?
...At this point in my reply I kinda got a bit carried away with minor edits and some rewording. You'll find the cumulation of my work at the end of this post. But before that we should discuss the use of strips. In the past, the use of triangle strips and strips in general have been confusing. Perhaps we can discuss the use of strips when we do our tutorials on ortho mode or one of the later tutorials? And now for the edit...
Quote:
= Lesson 02 - Drawing simple shapes =
After having learned how to set up OpenGL we'll now try to draw things on the screen.
In OpenGL coordinates are specified through 3 floating point values known as the x-,y- and z-coordinates:
''image under construction''
In this diagram, something must have negative z-value to be visable. Distances in OpenGL are arbitrary. Unlike the real world, there are no set units. Instead, you decide how large one unit is in relation to the things you draw.
''2 images under construction''
In the past, beginners have had trouble understanding the concept of units in OpenGL. Examples follow which explain this concept. If you understand it, feel free to skip the examples. If you are still confuesd after the following examples, finish the tutorial. This concept is easier to learn with practice.
Example 1:
In the first example, we are trying to draw a house. We will arbitrarily pick meters (approximately 1 yard) as our unit. We decide to make the house 10 meters tall. Next we decide to make a person standing beside the house. It would be inappropriate to make the person 10 meters tall because he would be the same size as the house. Instead we will use 2 meters for the height of the person.
Example 2:
We are trying to draw a car and a bus. Like the previous example, we will be using meters. We decide to make the car 2 meters long and make the bus twice as long as the car or 4 meters. Unfortunately, when making the bus we accidently make it 40 meters long instead of 4 meters. Instead of shrinking the car down, we can make it bigger. If we scale the car so that it is 20 meters instead of 2, it will look correct compared to the bus. We can do this because the units in OpenGL are arbitrary.
Example 3:
We are trying to make a keyboard and mouse. We make the mouse 1 unit long. Again, we can do this because units are arbitrary. However, we run into a problem when we are trying to make the keyboard. How big should it be? It should be large enough to look correct when compared to the size of the mouse. If we make the keyboard's width five times the length of the mouse or 5 units then it should look correct when compared with the mouse.
OpenGL uses ''states'' to handle most internal settings. This type of system is called a '''state machine'''. For example, if you set the color to blue then everything you draw will be blue until you change the color. States like color can be set to a value. Other states can be enabled({{{glEnable()}}}) or disabled({{{glDisable()}}}).
One of those states which we will use in this lesson is color. It is enabled by default and can be changed with {{{glColor3f(float red, float green, float blue)}}} Each parameter is a value between 0 and 1, where 1 means full intensity and 0 mean no intensity.
Another state we change is the shading model. This defines whether colors are interpolated nicely (GL_SMOOTH) across our shape or not (GL_FLAT).
To get a nice result we use {{{glShadeModel(GL_SMOOTH)}}}
Now let's get to the fun stuff: '''drawing shapes'''[
]
At first we have to tell OpenGL that we want to draw something, and the kind of shape (''primitive'') we want to draw. This is done using {{{glBegin(*primitive type*)}}}
Primitives can be points(GL_POINTS), lines(GL_LINES/GL_LINE_STRIP), triangles(GL_TRIANGLES/GL_TRIANGLE_STRIP), quadliterals or short quads(GL_QUADS/GL_QUAD_STRIP) and polygons with more than 4 edges(GL_POLYGON). OpenGL will use triangles to draw all of the primitives mentioned. For example, if you cut a square (quad) diagonally, you get two triangles. It is fastest to use triangles to draw your shapes. If you use any other primitive, OpenGL will have to convert the geometry into triangles.
The points of a triangle or square are called ''vertices'' (singular: vertex). Vertices are used to tell opengl how to draw a primitive. You can pass one vertex to OpenGL with this command: {{{glVertex3f(float x,float y, float z)}}} To tell OpenGL that you are done with drawing, you call {{{glEnd()}}}.
Between the glBegin/glEnd pair, you specify the vertices that make up the shape. This way of sending geometry information to OpenGL is called immediate mode. The vertex information is immediately passed to OpenGL when drawing. The number of vertices depend on the type of primative being drawn. For example, if you are drawing a triangle, you can specify three vertices. OpenGL will then create a triangle between these three vertices. You can also specify six vertices. OpenGL will then use the first three to create one triangle and the next three to create a second triangle.
I'm concerned that my edit needs to explain the code a bit more. I hope it helps with your revisions :)
Cheers,
- llvllatrix
Thx a lot, sometimes I just didn't know how to express something in english so it became too complex...
I'll copy some of your sentences, if you agree..
My 2 images under construction will be explaining exactly what your examples did (I even started painting a house and a person.. Where did you know that from? [wink])
Oops, I mixed up the coordinate system of OpenGL and Direct X, so I don't need to mention it, you're right!... but my sketch will show a screen with the thee axis to show the user how to position objects.
Shall I explain glClear and glClearColor as well or will that be done in lesson01?
[Edited by - Caste on August 17, 2006 2:25:26 AM]
I'll copy some of your sentences, if you agree..
My 2 images under construction will be explaining exactly what your examples did (I even started painting a house and a person.. Where did you know that from? [wink])
Oops, I mixed up the coordinate system of OpenGL and Direct X, so I don't need to mention it, you're right!... but my sketch will show a screen with the thee axis to show the user how to position objects.
Shall I explain glClear and glClearColor as well or will that be done in lesson01?
[Edited by - Caste on August 17, 2006 2:25:26 AM]
Quote:
Original post by Caste
Shall I explain glClear and glClearColor as well or will that be done in lesson01?
The goal of lesson01 is getting up the window as defined in the functional specifications. So I would say yes you should explain them.
Quote:
Original post by Caste
I'll copy some of your sentences, if you agree..
Sure :)
Quote:
Original post by Caste
but my sketch will show a screen with the thee axis to show the user how to position objects.
Be sure to show the location of the camera so that users will know why things have to be negative to be visable.
Cheers,
- llvllatrix
I added the images...
Take a look at them https://opensvn.csie.org/traccgi/NeHeDev/wiki/Lesson04Tutorial
The ClearColor explanaton will follow
Take a look at them https://opensvn.csie.org/traccgi/NeHeDev/wiki/Lesson04Tutorial
The ClearColor explanaton will follow
If you'd like, you can simply use my edit and insert images. It has been spell checked and checked for grammer. All it should need is example code.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement