Contribute to thiagopsilva/Apostila-android development by creating an account on GitHub. Veja grátis o arquivo Apostila PyOpenGL enviado para a disciplina de Sistemas In this new from import * format, we can use OpenGL module commands. in due course. 2. Introduction OpenGL (Open Graphics Library) is a cross- platform, hardware-accelerated, apostila CPA 10 Uploaded by Marcella Costa.

Author: Tojashakar Aragar
Country: Turkmenistan
Language: English (Spanish)
Genre: Love
Published (Last): 9 March 2009
Pages: 321
PDF File Size: 8.67 Mb
ePub File Size: 14.83 Mb
ISBN: 932-5-92689-241-1
Downloads: 30435
Price: Free* [*Free Regsitration Required]
Uploader: Voodoogrel

Enviado por Bruno flag Denunciar. There are apostia, such as Scite that are free and also work well. Python comes with its own editor called Idle. You can use that. You can even write Python code in a text processor and run the code from the command prompt by typing: I learned to save my work early and often after that.

The import statements add extra functions to this basic set of commands. With the exception aplstila import sys, these are import statements with a somewhat different format than the one used in the first program import string.

In this new from GLUT preface in a similar fashion as string in the Super-3 program. If we simply used import OpenGL.

GL, then every time we used an OpenGL. GL command, we would need to write for example: Much simpler, don’t you think? We will usually only need a couple of commands from this module, so we do not need to use the from Likewise, in the Super-3 program we only needed one string function string.


Having all the OpenGL commands available will save time!

To summarize, each of the from OpenGL statements adds new commands to Python. There are OpenGL commands. GLGLU commands.

OpenGL Programming/Stencil buffer

You will know when you are using commands from each specific OpenGL module by looking at the first few letters of the OpenGL command. The def keyword marks the beginning of a function block of code in Python. Functions are segments of code that act as a group or family of commands.

Note the two indented lines after def draw:. The indents mark these lines as belonging to this particular function. First, it uses a GLUT command to draw a wire teapot with a size of 0. Second, the glFlush statement “flushes”8 the drawing to the screen so we can see it. Finally add these lines, making certain to line them up even with the left-hand margin.

The first line, glutInit sys. In this program, the display function is def draw. Ditto for if statements and for loops. Later we will learn how to avoid glFlush by using something called buffering. If you indent these commands, Python will think they belong in the def draw: We could have created a def picasso: You should see something that looks similar to Figure 4.

When we created the graphics window, we did not specify anything about the background, so GLUT simply copied everything from the screen location into the window and then drew the teapot on top of the whole mess.


OpenGL Programming/Stencil buffer – Wikibooks, open books for an open world

Move the window around with your mouse left-click on the caption bar, hold the mouse button down, and move the window. You’ll see that the background moves with the window! We can easily fix this by adding one line of code. Remember to indent at the same level as the other two lines in this function! Save the program and run it again. You should now see something like Figure 4. Move this window around with the mouse and everything works as expected.

Finally, we are going to add two more lines to our first program. Click on the line that contains the glutInitDisplayMode command. Press the “End” key on the keyboard or click at the end of this line. Press “Enter” twice to make room for the following two lines of code. These lines allow us to specify the size of the graphics window x pixels on a side and the initial location of the window, which is 12 This statement obviously clears the screen.