main
Brett 2023-12-29 19:25:41 -05:00
parent b5d707f5c7
commit d191f73a6b
6 changed files with 97 additions and 10 deletions

View File

@ -0,0 +1,27 @@
/*
* <Short Description>
* Copyright (C) 2023 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BLT_WITH_GRAPHICS_SOUND_H
#define BLT_WITH_GRAPHICS_SOUND_H
namespace blt::gfx
{
}
#endif //BLT_WITH_GRAPHICS_SOUND_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 KiB

View File

@ -0,0 +1,23 @@
/*
* <Short Description>
* Copyright (C) 2023 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <blt/gfx/sound/sound.h>
namespace blt::gfx
{
}

View File

@ -16,7 +16,8 @@ vec4 linear_iter(vec4 i, vec4 p, float factor){
void main() { void main() {
//FragColor = vec4(pos, 0.0, 1.0f); //FragColor = vec4(pos, 0.0, 1.0f);
FragColor = linear_iter(texture(tex, uv), vec4(pos, 0.0, 1.0), (uv.x + uv.y + 1.0) / 3.0); FragColor = texture(tex, uv);
//FragColor = linear_iter(texture(tex, uv), vec4(pos, 0.0, 1.0), (uv.x + uv.y + 1.0) / 3.0);
} }
")"; ")";

View File

@ -37,8 +37,11 @@ const unsigned int indices[6] = { // note that we start from 0!
blt::gfx::vertex_array* vao; blt::gfx::vertex_array* vao;
blt::gfx::shader_t* shader; blt::gfx::shader_t* shader;
blt::gfx::texture_gl2D* texture; blt::gfx::texture_gl2D* texture;
blt::gfx::texture_gl2D* parker_texture;
blt::gfx::matrix_state_manager global_matrices; blt::gfx::matrix_state_manager global_matrices;
float x = 0, y = 0, z = 0; float x = 0, y = 0, z = 0;
float bx = 500, by = 500;
float mx = 0, my = -9.8;
void handle_input() void handle_input()
{ {
@ -66,6 +69,19 @@ void handle_input()
global_matrices.setView(view); global_matrices.setView(view);
} }
void draw(float x_, float y_, float width_, float height_, float rot = 0)
{
blt::mat4x4 model;
model.translate(x_, y_, 0.0f);
model.scale(width_, height_, 1);
model.rotateZ(blt::toRadians(rot));
shader->setMatrix("model", model);
vao->bind();
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
}
void init() void init()
{ {
using namespace blt::gfx; using namespace blt::gfx;
@ -88,8 +104,9 @@ void init()
shader->bindAttribute(0, "vertex"); shader->bindAttribute(0, "vertex");
shader->bindAttribute(1, "uv_in"); shader->bindAttribute(1, "uv_in");
texture_file file("../resources/textures/cumdollar.jpg"); texture = new texture_gl2D(texture_file("../resources/textures/cumdollar.jpg").texture());
texture = new texture_gl2D(file.texture()); parker_texture = new texture_gl2D(texture_file("../resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png").texture());
global_matrices.create_internals(); global_matrices.create_internals();
} }
@ -107,16 +124,35 @@ void update(std::int32_t width, std::int32_t height)
global_matrices.update(); global_matrices.update();
shader->bind(); shader->bind();
blt::mat4x4 model;
model.translate((float) width / 2.0f, (float) height / 2.0f, 0.0f); const float w = 120, h = 120, cf = 30, rf = 15, crf = 10;
model.scale(500, 500, 1);
shader->setMatrix("model", model);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
texture->bind(); parker_texture->bind();
draw(width / 2.0, height / 2.0, width, height, 90);
vao->bind(); texture->bind();
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); draw(bx, by, w, h, 0);
bx += mx * blt::gfx::getFrameDeltaSeconds() * cf;
by += my * blt::gfx::getFrameDeltaSeconds() * cf;
if (bx < w / 2.0 || bx > width - w / 2.0)
{
mx = -mx;
my += (static_cast<float>(rand()) / static_cast<float>(RAND_MAX) * rf + crf) - (rf + crf) / 2.0f;
}
if (by < h / 2.0 || by > height - h / 2.0)
{
my = -my;
mx += (static_cast<float>(rand()) / static_cast<float>(RAND_MAX) * rf + crf) - (rf + crf) / 2.0f;
}
if (mx > 100 || mx < -100)
{
mx = mx * 0.2;
}
if (my > 100 || my < -100)
my = my * 0.2;
} }
int main() int main()