Computer Graphics 2

0.0(0)
Studied by 3 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/25

flashcard set

Earn XP

Description and Tags

02 Handout 1 - Pygame and OpenGL. 🍀 - syntax

Last updated 5:55 AM on 9/6/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

26 Terms

1
New cards

Window

is a graphical interface element that displays an application’s content

2
New cards

Startup

phases of an interactive and graphics-based windowed application:

  • during this stage, objects are created, values are initialized, and any required external filers are loaded


3
New cards

Main Loop

phases of an interactive and graphics-based windowed application:

  • this stage repeats continuously while the application is running

  • consists of three (3) substages: Process Input, Update, r


4
New cards

Process Input

Main Loop:

  • checks if the user has performed any action that sends data to the computer, such as pressing keys on a keyboard or clicking buttons on a mouse


5
New cards

Update

Main Loop:

  • changes values of variables and objects


6
New cards

Render

Main Loop:

  • creates graphics that are displayed on the screen


7
New cards

Shutdown

phases of an interactive and graphics-based windowed application:

  • this stage typically begins when the user performs an action indicating that the program should stop (for example, by clicking a button to quit the application)

  • this stage may involve tasks such as signaling the application to stop checking for user input and closing any windows created by the application


8
New cards

Pygame

  • is a set of Python modules designed for creating video games

  • it is a popular Python game development library


9
New cards

to set up a window using Pygame🍀

  • use pygame.display.set_mode() method

Example:

screen = pygame.display.set_mode((500, 500))

10
New cards

Point

  • is a location in space

  • it is the most basic graphical element

  • to render a single __ on the screen, use a vertex shader


11
New cards

Rendering a single point by using vertex shader

  • Vertex Shader will consists of the following code using the OpenGL Shading Language (GLSL)

  • every shader must contain a main() function

  • manipulate coordinates in a 3D space and are called once per vertex

  • the purpose of vertex shader is to set up the gl_Position variable


<ul><li><p>Vertex Shader will consists of the following code using the OpenGL Shading Language (GLSL)</p></li><li><p>every shader must contain a <strong>main()</strong> function</p></li><li><p>manipulate coordinates in a 3D space and are called once per vertex</p></li><li><p>the purpose of vertex shader is to set up the gl_Position variable</p></li></ul><p></p>
12
New cards

void

indicates that no values are returned

13
New cards

main()

requires no parameters

14
New cards

gl_Position

  • a special, global, and built-in GLSL variable

  • used to store the position of the current vertex


15
New cards

Vector Data Types

  • often used for storing values that indicate positions, colors, and texture coordinates

  • may have two, three, or four components indicated by vec2, vec3, and vec4 (for vectors consisting of floats)

    • the four float values represent the vertex’s x, y, z, and w positions

    • the w parameter is used to manipulate the clipping of the vertex position in the 3D space

    • default value is 1.0


16
New cards

Vertex Buffers

  • stores every vertex shader that you write will use arrays of data

  • multiple points are needed to specify the shapes of two-dimensional or three-dimensional objects


17
New cards

Sample code to draw a 3D triangle🍀

  • each of the triangle’s vertices is specified by a call to the function glVertex3f

  • vertices must be specified between calls to glBegin and glEnd


<ul><li><p>each of the triangle’s vertices is specified by a call to the function <strong>glVertex3f</strong></p></li><li><p>vertices must be specified between calls to <strong>glBegin</strong> and <strong>glEnd</strong></p></li></ul><p></p>
18
New cards

glBegin

tells which type of primitive is being drawn

19
New cards

Uniform Variables

are global variables that can be accessed by the vertex shader or the fragment shader, and whose values are constant while each shape is being drawn (can be changed between draw function calls)

20
New cards

Uniform

  • a type qualifier that provides a mechanism for directly sending data from variables in a CPU application to variables in a GPU program


21
New cards

glGetUniformLocation(programRef, variableName)🍀

glGetUniformLocation

  • returns a value used to reference a uniform variable (indicated by the type qualifier uniform)

variableName

  • the name indicated by the parameter variableName

programRef

  • declared in the program referenced by the parameter programRef


22
New cards

Keydown

occur the moment a key is initially pressed

23
New cards

Keyup

occur the moment the key is released

24
New cards

Discrete

an event that happens once at an isolated point in time


25
New cards

Continuous

an event that continues happening during an interval of time

26
New cards

Sample code the checks if a keydown event occurs🍀

.

<p>.</p>