source: opengl-game/opengl-notes.txt@ 27c40ce

feature/imgui-sdl points-test
Last change on this file since 27c40ce was 9dd2eb7, checked in by Dmitry Portnoy <dmp1488@…>, 7 years ago

Implement Phong shading in the color and texture shaders

  • Property mode set to 100644
File size: 1.6 KB
Line 
1Default bounds
2
3 1 -1
4 | /
5 | /
6 | /
7 |/
8-1 --------------- 1
9 /|
10 / |
11 / |
12 / |
13 1 -1
14
15Matrices
16
17model: transforms each object separately
18view: transforms the whole world
19
20for instance, a positive x translation moves either one object or all objects on the screen to the right a certain distance.
21
22If you want to transform the camera position or rotation, it should be the inverse of the transformations the view matrix is applying.
23
24projection: Here's where the fun stuff begins
25Viewing Frustum diagram is on page 99
26
27I need to first implement the click detection function without applying the projection matrix
28
29The click detection function uses ray tracing to figure out which object we hit
30
31First, we need to generate the equation for the ray that starts at the camera position and through the point the user clicked. To do that, we need to turn the 2d point of the click into a 3d point on the near clipping plane.
32
33Ray Equation:
34R(t) = O+Dt
35
36where R(t) defines all the points on the ray, O is the camera origin,
37and D is the direction of the ray.
38
39In this case, D = P-O, where P is the point the user clicked on in 3D space
40
41Camera position = (0, 0, 0)
42
43
44BUFFER FUNCTIONS
45-----------------
46
47glGenBuffers creates a buffer
48glBindBuffer sets the currently active buffer
49glBufferData populates the buffer with data
50
51glGenVertexArrays creates a vao
52glBindVertexArray sets the currently active vao
53glEnableVertexAttribArray sets the active index in the vao
54glVertexAttribPointer determines the layout of a buffer in a VAO
55 -The last params (often NULL), specifies the offset in the buffer
Note: See TracBrowser for help on using the repository browser.