-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.cpp
151 lines (97 loc) · 2.42 KB
/
app.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include<iostream>
#include<string>
#include<stdexcept>
#include<cmath>
#include<fstream>
#include<vector>
#include<cstring>
#include<cstddef>
#include<algorithm>
#include<cstdlib>
#include<glm/glm.hpp>
#include<glm/gtc/matrix_transform.hpp>
#include<glm/gtc/type_ptr.hpp>
//#define STATIC_GLEW
#include<glad/glad.h>
#include<GLFW/glfw3.h>
#include<ktx.h>
#include"error.h"
#include"context.h"
#include"resfun.h"
#include"app.h"//declaration of app class
#include"abst.h"//declaration of abstract class
#include"conc.h"//delaration of all concrete classes
#include<stb_image.h>
namespace N_app
{
const float app::PI = 22.0f / 7;
void app::init()
{
std::cout << "A";
n_plane = 0.1;
f_plane = 1000;
fov = glm::radians(45.0f);
view_depth = 1.5;
background = glm::vec4(0.5, 0.5, 0.5, 1);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
}
void app::run()//it will act as main for opengl application
{
//vp_w = (con_w = 1280);
//vp_h = (con_h = 800);
vp_w = (con_w = 1366);
vp_h = (con_h = 786);
context obj(con_w, con_h);
glfwMakeContextCurrent(obj.get_win());
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
error("can't get proc address");
}
glViewport(0, 0, vp_w, vp_h);
chk();
init();
startup();
render();
}
void app::startup()
{
abst* ptr;
ptr = new c_prog();
ptr->pure(this);
ptr = new c_buffer;
ptr->pure(this);
ptr = new c_live;
ptr->pure(this);
ptr = new c_model;//creates random distribution of particles
ptr->pure(this);
ptr = new c_texture;
ptr->pure(this);
ptr = new c_matrix;
ptr->pure(this);
glEnable(GL_DEPTH);
glDepthFunc(GL_LEQUAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void app::render()
{
bool b = false;
while (!glfwWindowShouldClose(glfwGetCurrentContext()))
{
float one = 1.0f;
glClearBufferfv(GL_COLOR, 0, glm::value_ptr(background));
glClearBufferfv(GL_DEPTH, 0, &one);
abst* ptr = new c_live;//develops each frame of animation
ptr->pure(this);
for (int i = 1; i <= 400; ++i)//draws 1 frame of animation
{
glUseProgram(prog[0]);
glVertexAttribI1i(0, i);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
glfwSwapBuffers(glfwGetCurrentContext());
glfwPollEvents();
}
}
}