-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedundantCode.txt
More file actions
54 lines (48 loc) · 2.18 KB
/
RedundantCode.txt
File metadata and controls
54 lines (48 loc) · 2.18 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
/* Shaders are OpenGL objects which run in the background in the memory
* Defining Vertex and Fragment Shaders because they do not have
* OpenGL defaults:
*/
//// Vertex Shader:
//const char* vertexShaderSource = "#version 330 core\n"
//"layout (location = 0) in vec3 aPos;\n"
//"void main()\n"
//"{\n"
//" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
//"}\0"; // \0 indicates termination of character string in C.
//// Fragment Shader:
//const char* fragmentShaderSource = "#version 330 core\n"
//"out vec4 FragColor;\n"
//"void main()\n"
//"{\n"
//" FragColor = vec4(0.8f, 0.3f, 0.02f, 1.0f);\n"
//"}\n\0";
GLfloat vertices[] = {
-0.5f, -0.5f * float(sqrt(3)) / 3, 0.0f, // Lower-left
0.5f, -0.5f * float(sqrt(3)) / 3, 0.0f, // Lower-right
0.0f, 0.5f * float(sqrt(3)) * 2 / 3, 0.0f, // Upper corner
-0.5f / 2, 0.5f * float(sqrt(3)) / 6, 0.0f, // Inner-left
0.5f / 2, 0.5f * float(sqrt(3)) / 6, 0.0f, // Inner-right
0.0f, -0.5f * float(sqrt(3)) / 3, 0.0f // Inner-down
};
/* Arbitrary coordinates for generating a 2D triangle:
* Every 3 floats will represent one coordinate
* Centre of the coordinates for X and Y is the middle of the screen
* Z coordinate would not be considered for 2D
* Coordinates are normalized, so they gotta be in [-1, 1]:
*/
GLfloat vertices[] = {
// COORDINATES / COLORS //
-0.5f, -0.5f * float(sqrt(3)) * 1 / 3, 0.0f, 0.8f, 0.3f, 0.02f, // Lower-left
0.5f, -0.5f * float(sqrt(3)) * 1 / 3, 0.0f, 0.8f, 0.3f, 0.02f, // Lower-right
0.0f, 0.5f * float(sqrt(3)) * 2 / 3, 0.0f, 1.0f, 0.6f, 0.32f, // Upper corner
-0.5f / 2, 0.5f * float(sqrt(3)) * 1 / 6, 0.0f, 0.9f, 0.45f, 0.17f, // Inner-left
0.5f / 2, 0.5f * float(sqrt(3)) * 1 / 6, 0.0f, 0.9f, 0.45f, 0.17f, // Inner-right
0.0f, -0.5f * float(sqrt(3)) * 1 / 3, 0.0f, 0.8f, 0.3f, 0.02f // Inner-down
};
// If a primitive (in this case vertex) has a color defined, then OpenGL will automatically
// create a gradient from one color to another. This is called interpolation.
GLuint indices[] = {
0, 3, 5, // Lower-left triangle
3, 2, 4, // Lower-right triangle
5, 4, 1 // Upper-triangle
};