-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.cpp
55 lines (47 loc) · 974 Bytes
/
snake.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
#include <iostream>
#include <fstream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "common.h"
#include "snake.h"
Snake::Snake(unsigned int size,GLuint shader):size(size),shader(shader){
dir = None;
snake = new snakeUnit[size];
glGenBuffers(1, &VBO);
glGenVertexArrays(1, &VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindVertexArray(VAO);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,0,0);
glEnableVertexAttribArray(0);
}
Snake::~Snake(){
delete[] this->snake;
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
}
Direction Snake::getDirection(){
return this->dir;
}
void Snake::setDirection(Direction a){
this->dir = a;
}
unsigned int Snake::getLen()
{
return this->len;
}
void Snake::setLen(unsigned int len)
{
this->len = len;
}
GLuint Snake::getVBO()
{
return this->VBO;
}
GLuint Snake::getVAO()
{
return this->VAO;
}
GLuint Snake::getShader()
{
return this->shader;
}