glUseProgram(shaderProgramForRaindrops);
glm::mat4 transformic;
transformic = glm::translate(transformic, glm::vec3(0.0f, (GLfloat)raindropY, 0.0f));
if (raindropY <= 7 * floor[4] + 0.05) {
raindropY = -(float)0.1f;
}
GLint transformLocRainDrops = glGetUniformLocation(shaderProgramForRaindrops, "raindropsdown");
glUniformMatrix4fv(transformLocRainDrops, 1, GL_FALSE, glm::value_ptr(transformic));
glBindVertexArray(VAOs[2]);
glDrawArraysInstanced(GL_LINES, 0, 2, 200);
glBindVertexArray(0);
raindropY = raindropY - 0.003;
glBindVertexArray(VAOs[2]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[2]);
glBufferData(GL_ARRAY_BUFFER, sizeof(raindrops), raindrops, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[3]);
glBufferData(GL_ARRAY_BUFFER, sizeof(translations), translations, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), (GLvoid*)0);
glVertexAttribDivisor(1, 6);
glEnableVertexAttribArray(1);
glBindVertexArray(0);
gl_Position = vec4(aPos + aOffset, 0.0, 1.0);
glUseProgram(shaderProgramForRaindrops);
glBindVertexArray(VAOs[2]);
glDrawArraysInstanced(GL_TRIANGLES, 0, 6, 100);
glBindVertexArray(0);
//В коде обозначен как const GLchar* vertexRainDrops
#version 460 core\n
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aOffset;
void main()
{
gl_Position = vec4(aPos + aOffset, 0.0, 1.0);
}
#version 460 core
out vec4 color;
void main()
{
color = vec4(0.0f, 0.0f, 0.65f, 1.0f);
};
GLuint vertexraindrops = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentshaderBlue = glCreateShader(GL_FRAGMENT_SHADER);
GLuint shaderProgramForRaindrops = glCreateProgram();
glShaderSource(vertexraindrops, 1, &vertexRainDrops, NULL);
glCompileShader(vertexraindrops);
glShaderSource(fragmentshaderBlue, 1, &fragmentShaderBlue, NULL);
glCompileShader(fragmentshaderBlue);
glAttachShader(shaderProgramForRaindrops, vertexraindrops);
glAttachShader(shaderProgramForRaindrops, fragmentshaderBlue);
glLinkProgram(shaderProgramForRaindrops);
glm::vec2 translations[100];
int index = 0;
float offset = 0.1f;
for (int y = -10; y < 10; y += 2)
{
for (int x = -10; x < 10; x += 2)
{
glm::vec2 translation;
translation.x = (float)x / 10.0f + offset;
translation.y = (float)y / 10.0f + offset;
translations[index++] = translation;
}
}
GLfloat raindrops[] = {
-0.05f, 1.0f, 0.0f,
-0.05f, 0.95f, 0.0f,
0.05f, 1.0f, 0.0f,
0.05f, 1.0f, 0.0f,
0.05f, 0.95f, 0.0f,
-0.05f, 1.0f, 0.0f,
};
GLuint VBOs[4],
VAOs[3],
EBOs[2];
glGenBuffers(4, VBOs);
glGenVertexArrays(3, VAOs);
glGenBuffers(2, EBOs);
/* Здесь объявления VAOs[0] и Vaos[1] */
glBindVertexArray(VAOs[2]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[2]);
glBufferData(GL_ARRAY_BUFFER, sizeof(raindrops), raindrops, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[3]);
glBufferData(GL_ARRAY_BUFFER, sizeof(translations), translations, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), (GLvoid*)0);
glVertexAttribDivisor(1, 6);
glEnableVertexAttribArray(1);
glBindVertexArray(0);
/* Вызов в игровом цикле*/
/* Третья программа */
glUseProgram(shaderProgramForRaindrops);
glBindVertexArray(VAOs[2]);
glDrawArraysInstanced(GL_TRIANGLES, 0, 6, 100);
glBindVertexArray(0);
#version 460 core
layout (location = 0) in vec3 aPos;
uniform vec2 offsets[100];
void main()
{
vec3 offset = offsets[gl_InstanceID];
gl_Position = vec4(aPos + offset, 0.0, 1.0);
}
#version 460 core
out vec4 color;
void main()
{
color = vec4(1.0f, 1.0f, 0.0f, 1.0f);
}
^ array:3 [
0 => array:3 [
"query" => "select count(*) as aggregate from `games`"
"bindings" => []
"time" => 1.51
]
1 => array:3 [
"query" => "select * from `games` limit 10 offset 0"
"bindings" => []
"time" => 0.21
]
2 => array:3 [
"query" => "select `game_genres`.*, `games_games_genres`.`game_name` as `pivot_game_name`, `games_games_genres`.`genre_name` as `pivot_genre_name` from `game_genres` inner join `games_games_genres` on `game_genres`.`id` = `games_games_genres`.`genre_name` where `games_games_genres`.`game_name` in (42, 43, 44, 45, 46, 47)"
"bindings" => []
"time" => 0.31
]
]