-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.cpp
More file actions
95 lines (82 loc) · 2.44 KB
/
benchmark.cpp
File metadata and controls
95 lines (82 loc) · 2.44 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/** @file main.cpp o inicio de tudo. Responsavel por instanciar a interface grafica principal. */
#include <boost/timer/timer.hpp>
#include <iostream>
#include <memory>
#include <stdexcept>
#if __APPLE__
// Other kinds of Mac OS
#include <GLUT/glut.h>
#endif
#include "ent/tabuleiro.h"
#include "ent/tabuleiro.pb.h"
#include "gltab/gl.h"
#include "m3d/m3d.h"
#include "ntf/notificacao.h"
#include "log/log.h"
#include "tex/texturas.h"
#include <setjmp.h>
#include <GL/glut.h>
using namespace std;
DEFINE_string(tabuleiro, "castelo.binproto", "Tabuleiro de benchmark.");
DEFINE_int32(num_desenhos, 1000, "Numero de vezes que o tabuleiro sera renderizado.");
DEFINE_int32(tam_janela, 1000, "Altura e largura da janela quadrada");
ent::Tabuleiro* g_tabuleiro = nullptr;
int g_counter = 0;
jmp_buf g_buf;
void render() {
g_tabuleiro->Desenha();
g_tabuleiro->TrataRotacaoPorDelta(0.01f);
glutSwapBuffers();
if (++g_counter >= FLAGS_num_desenhos) {
LOG(INFO) << "saindo!!";
longjmp(g_buf, 1);
}
}
void reshape(int width, int height) {
g_tabuleiro->TrataRedimensionaJanela(width, height);
}
int main(int argc, char** argv) {
meulog::Inicializa(&argc, &argv);
// luz por pixel e mapa sombras.
glutInitWindowSize(FLAGS_tam_janela, FLAGS_tam_janela);
glutInitWindowPosition(0, 0);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_STENCIL | GLUT_DEPTH);
glutInit(&argc, argv);
glutCreateWindow("benchmark");
gl::IniciaGl(true); // inicia o glut.
ntf::CentralNotificacoes central;
tex::Texturas texturas(¢ral);
ent::OpcoesProto opcoes;
opcoes.set_iluminacao_por_pixel(true);
opcoes.set_mapeamento_sombras(true);
m3d::Modelos3d modelos(¢ral);
ent::Tabuleiro tabuleiro(opcoes, &texturas, &modelos, ¢ral);
g_tabuleiro = &tabuleiro;
tabuleiro.IniciaGL();
tabuleiro.TrataRedimensionaJanela(FLAGS_tam_janela, FLAGS_tam_janela);
// Carrega tabuleiro.
{
ntf::Notificacao n;
n.set_tipo(ntf::TN_DESERIALIZAR_TABULEIRO);
n.set_endereco("estatico://" + FLAGS_tabuleiro);
tabuleiro.TrataNotificacao(n);
}
{
ntf::Notificacao n;
n.set_tipo(ntf::TN_TEMPORIZADOR);
tabuleiro.TrataNotificacao(n);
for (int i = 0; i < 1000; ++i) {
// Carrega.
central.Notifica();
}
}
// Desenha varias vezes.
glutReshapeFunc(reshape);
glutIdleFunc(render);
glutDisplayFunc(render);
boost::timer::auto_cpu_timer timer;
if (!setjmp(g_buf)) {
glutMainLoop();
}
return 0;
}