-
Notifications
You must be signed in to change notification settings - Fork 3
/
cursor.cpp
65 lines (56 loc) · 2.02 KB
/
cursor.cpp
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
#include "cursor.h"
#define PI 3.14159263
Cursor::Cursor(float length){
}
void Cursor::Initialize(float length){
len = length;
shader = new MyShader("shaders/shape.vert", "shaders/shape.frag");
shader->checkErrors();
for (int k=0;k<=360;k+= 60){
float j = k*PI/180;
float i = (k+60)*PI/180;
verts.push_back(glm::vec3(0.0f,0.0f,-1.0f));
// verts.push_back(glm::vec3(0.1* cos(k), 0.1*sin(k), 0.0f));
// verts.push_back(glm::vec3(0.1* cos(k+30), 0.1*sin(k+30), 0.0f));
verts.push_back(glm::vec3(0.1* cos(j), 0.1*sin(j), 0.0f));
verts.push_back(glm::vec3(0.1* cos(i), 0.1*sin(i), 0.0f));
}
// verts.push_back(glm::vec3(0.0f, len, 0.0f));
// verts.push_back(glm::vec3(0.3f*len, 0.0f, 0.0f));
// verts.push_back(glm::vec3(0.0f, 0.3f*len, 0.0f));
// verts.push_back(glm::vec3(-0.3f*len, 0.0f, 0.0f));
// verts.push_back(glm::vec3(0.0f, -0.3f*len, 0.0f));
// verts.push_back(glm::vec3(0.15f*len, 0.15f*len, 0.0f));
static const GLfloat vertex_data[] = {
0.0f, 0.0f,-0.01f,
0.0f, 0.01f, 0.0f,
0.0f, 0.0f, 0.01f,
};
//buffers
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, verts.size()* sizeof(glm::vec3), verts.data(), GL_STATIC_DRAW);
// glBufferData(GL_ARRAY_BUFFER, 9, vertex_data, GL_STATIC_DRAW);
// glBufferData(GL_ARRAY_BUFFER, sizeof(rocket_body_verticies), rocket_body_verticies, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void Cursor::Draw(glm::mat4 mvp){
shader->bindShader();
glm::mat4 m;
shader->setMatrix4("mvp", mvp);
glCheckError();
glEnableVertexAttribArray(0);
glCheckError();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glCheckError();
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glCheckError();
// glDrawArrays(GL_TRIANGLES, 0, 3);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDrawArrays(GL_TRIANGLES, 0, 7*3);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// glCheckError();
// glDisableVertexAttribArray(0);
glCheckError();
shader->unbindShader();
}