Display.cpp 891 Bytes
Newer Older
Srb František's avatar
Srb František committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Display.h"

Display::Display(unsigned int VAO,unsigned int shaderProgram)
{
    this->VAO = VAO;
    this->shaderProgram = shaderProgram;
}

Display::~Display()
{
}

void Display::DrawObject(float* line,unsigned int num_of_vertices) const
{
    //Main opengl drawing
    glBufferData(GL_ARRAY_BUFFER, num_of_vertices*sizeof(line[0])*5, line, GL_DYNAMIC_DRAW);
    glUseProgram(shaderProgram);
    glBindVertexArray(VAO);
    glDrawArrays(GL_LINES, 0, num_of_vertices);

}

23
24
25
26
27
28
29
30
31
32
void Display::DrawPoint(float* point) const
{
    glBufferData(GL_ARRAY_BUFFER, sizeof(point[0]) * 5, point, GL_DYNAMIC_DRAW);
    glUseProgram(shaderProgram);
    //point size
    glPointSize(20);
    glBindVertexArray(VAO);
    glDrawArrays(GL_POINTS, 0, 1);
}

Srb František's avatar
Srb František committed
33
34
35
36
37
38
39
void Display::CleanWindow()
{
    //clean whole screen and set every pixel to black
	glClearColor(0, 0,0, 1);
	glClear(GL_COLOR_BUFFER_BIT);
}