Run your program once more and notice that you only see 2 lines, one from (-1.0, 1.0) to (1.0, 1.0) and the other from (1.0, -1.0) to (-1.0, -1.0). Because we dont make it too big so we use ribs of 2. What you will see is a dark green line that goes from upper left corner to bottom right corner of the window. Now compile and run your program (F5 Vs.Net ShortCut).
#Opengl coords code
You have to put it in the base code in the glDraw function where I commented As you saw the uint mode was GL_QUADS this is for drawing quads but there are times when you want to draw a line you will do it like this. Now we got that covered we can start with drawing in OpenGL.Īs you may saw in the previous article all drawing is done between glBegin(uint mode) and glEnd(). and it will show all the functions in it. this because all functions are in if you have Visual Studio. Please Note: Every gl command is prefix with GL. NOTE: that the OpenGL coordinate system is also called a left handed coordinate system because you can make the same coordinate system with your left hand try to figure it out. We start at the upper left corner and we go clockwise to the upper right corner then to the botto right corner and at last the down left corner. If we want to make a rectangle with an overall length of 2 we do it like this. So to make a 2d rectangle we have to specify 4 corners. The OpenGL supports another coordinate the so called w coordinate this is for dividing all the coordinates and it will be somewhat like this ( x/w, y/w, z/w ) but this isnt a very common used coordinate. That is why we used glTranslatef(0.0f, 0.0f, -6.0f) so we draw at a minus 6 coordinate to make it visible for us.
![opengl coords opengl coords](https://i.stack.imgur.com/se8yY.png)
At default youre looking at the negative z direction. The OpenGL coordinate system uses y x and z where 0,0,0 is the precise middle of the screen. For drawing in 3D you need at least 3 coordinates because you need to go in dept. You probably know that OpenGL draws in 3D coordinate system, while GDI+ is a 2D coordinate system. The value of x and y on the upper left corner is 0,0, that means the starting point of GDI+ coordinate system is upper-left corner.
![opengl coords opengl coords](https://www.puredevsoftware.com/blog_images/opengl_texture_coords.png)
As we all know the GDI+ coordinate system has only an x and a y coordinate where x is the horizontal and y is the vertical. OpenGL doesnt use the same coordinate system as GDI+ uses. I wont go in much detail about the OpenGL coordinate system but I will tell you what you need to get the point in my following articles.
#Opengl coords how to
In the article OpenGL using csGL I already showed you how to draw simple graphics objects. Second I want to explain how we can draw stuff on the screen. Of course I cant explain everything about it but this is what you will need to get the point in the following articles. First of all, I would like to cover the OpenGL Coordinate System. In this article I want to explain couple of more things.
#Opengl coords windows
Last time we created a Windows Forms application with an OpenGLControl on it so our OpenGL could draw a box.
![opengl coords opengl coords](https://www3.ntu.edu.sg/home/ehchua/programming/opengl/images/GL_2DViewport.png)
Hi and welcome back to one more article about OpenGL.