Repository navigation
Expand file tree
/
Copy pathnotes.txt
More file actions
109 lines (59 loc) · 4.32 KB
/
Copy pathnotes.txt
File metadata and controls
109 lines (59 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
OPEN GL - API Specification for communicating with the GPU
it defines if a function exists, there names , what parameter they take , not the implimentations , implimentations are done by GPU manufacturers
Hence the term "Specification" means a formal rulebook (eg These functions and datatypes must exist but not the source code)
State Machine - OpenGL works by maintaining a big internal state.
State = a collection of settings . example - which shader is active , which texture is bound etc.
Its like control panel where you change settings and make things happen ;
GLFW (graphics library framwork) - “Give me a window, an OpenGL context, and input events — I’ll talk to Windows/Linux/macOS for you.”
creates window , handle keyboard and mouse event , create opengl context .
GLAD - function loader , Modern OpenGL does NOT give you function pointers automatically.
means - glGenBuffers(...) does not exist in your program unless you load it.
GLAD:
Asks the OS/driver for addresses of OpenGL functions
Stores them in global function pointers
Lets you call them normally
Why do we need to “find function locations”?
Because OpenGL is a driver-based API. Your graphics driver (NVIDIA/AMD/Intel) provides the actual machine code for:
glGenBuffers
glBindBuffer
glDrawArrays
Not the OpenGL headers.The header only contains : void glGenBuffers(GLsizei, GLuint*);
But where is the function body?➡️ Inside the GPU driver.
At runtime, your program must ask:
“Hey driver, where in memory is glGenBuffers?”
That’s exactly what this line does: wglGetProcAddress("glGenBuffers")
Shader's - small, specialized programs written in GLSL (OpenGL Shading Language) that run directly on the GPU to handle rendering tasks, allowing for parallel processing of graphics
Vertex Shader - Place Vertexes
Fragment Shader - Colors it
Objects - An OpenGL Object is an OpenGL construct that contains some state. When they are bound to the context, the state that they contain is mapped into the context's state. Thus, changes to context state will be stored in this object, and functions that act on this context state will use the state stored in the object.
Vertex Buffer Objects (VBO) =
- Stores a large number of verticies in the GPU's memory , the advantage of using those buffer objects is that we can send large batches of data in all at once to the graphics card .
- basically store's the vertex of any shape / shader .
- Vertex data starts in RAM - it gets transferted to GPU via these funcs
glGenBuffers -> create GPU memory
glBindBuffer -> select's it
glBufferData -> copy numbers to GPU memory
VBO = GPU-side array of floats.
Vertex Array Objects (VAO) =
- VAO stores interpretation rules. GPU has the numbers now via VBO but it dose'nt know how to interpret those , which number are position's , how many per vertex , how far apart etc.
- It's a metadata about how to read VBO .
example for both objects :-
- here we can see how a vertex atrib pointer work's for vertices send to the gpu by VBO , and here VAO helping gpu interpret it :
//
float verticies[] = {
-0.5f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f };
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)0);
//
Vertices (VBO)
↓
Vertex Shader
↓
Triangle Assembly
↓
Rasterization (3D to 2D conversion)
↓
Fragment Shader
↓
Pixel's