diff --git a/include/blt/gfx/sound/sound.h b/include/blt/gfx/sound/sound.h new file mode 100644 index 0000000..b9f7f44 --- /dev/null +++ b/include/blt/gfx/sound/sound.h @@ -0,0 +1,27 @@ +/* + * + * 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 . + */ + +#ifndef BLT_WITH_GRAPHICS_SOUND_H +#define BLT_WITH_GRAPHICS_SOUND_H + +namespace blt::gfx +{ + +} + +#endif //BLT_WITH_GRAPHICS_SOUND_H diff --git a/resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png b/resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png new file mode 100644 index 0000000..eadd6e0 Binary files /dev/null and b/resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png differ diff --git a/resources/textures/parkerfemBOY.png b/resources/textures/parkerfemBOY.png new file mode 100644 index 0000000..14bdba0 Binary files /dev/null and b/resources/textures/parkerfemBOY.png differ diff --git a/src/blt/gfx/sound/sound.cpp b/src/blt/gfx/sound/sound.cpp new file mode 100644 index 0000000..76a3932 --- /dev/null +++ b/src/blt/gfx/sound/sound.cpp @@ -0,0 +1,23 @@ +/* + * + * 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 . + */ +#include + +namespace blt::gfx +{ + +} \ No newline at end of file diff --git a/tests/include/shaders/test.frag b/tests/include/shaders/test.frag index 069fa53..6104832 100644 --- a/tests/include/shaders/test.frag +++ b/tests/include/shaders/test.frag @@ -16,7 +16,8 @@ vec4 linear_iter(vec4 i, vec4 p, float factor){ void main() { //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); } ")"; diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 541573b..c380021 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -37,8 +37,11 @@ const unsigned int indices[6] = { // note that we start from 0! blt::gfx::vertex_array* vao; blt::gfx::shader_t* shader; blt::gfx::texture_gl2D* texture; +blt::gfx::texture_gl2D* parker_texture; blt::gfx::matrix_state_manager global_matrices; float x = 0, y = 0, z = 0; +float bx = 500, by = 500; +float mx = 0, my = -9.8; void handle_input() { @@ -66,6 +69,19 @@ void handle_input() 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() { using namespace blt::gfx; @@ -88,8 +104,9 @@ void init() shader->bindAttribute(0, "vertex"); shader->bindAttribute(1, "uv_in"); - texture_file file("../resources/textures/cumdollar.jpg"); - texture = new texture_gl2D(file.texture()); + texture = new texture_gl2D(texture_file("../resources/textures/cumdollar.jpg").texture()); + parker_texture = new texture_gl2D(texture_file("../resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png").texture()); + global_matrices.create_internals(); } @@ -107,16 +124,35 @@ void update(std::int32_t width, std::int32_t height) global_matrices.update(); shader->bind(); - blt::mat4x4 model; - model.translate((float) width / 2.0f, (float) height / 2.0f, 0.0f); - model.scale(500, 500, 1); - shader->setMatrix("model", model); + + const float w = 120, h = 120, cf = 30, rf = 15, crf = 10; glActiveTexture(GL_TEXTURE0); - texture->bind(); + parker_texture->bind(); + draw(width / 2.0, height / 2.0, width, height, 90); - vao->bind(); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); + texture->bind(); + 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(rand()) / static_cast(RAND_MAX) * rf + crf) - (rf + crf) / 2.0f; + } + if (by < h / 2.0 || by > height - h / 2.0) + { + my = -my; + mx += (static_cast(rand()) / static_cast(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()