Playing around with values to actually get something not fully opaque

This commit is contained in:
2025-01-09 23:42:33 +01:00
parent 09220ced25
commit 7c046a099a
5 changed files with 153 additions and 68 deletions

View File

@@ -6,6 +6,17 @@
#include "Shader.h"
// TODO: Delete
void saveImage2(const char* filename, unsigned char* framebuffer, int width, int height) { // TODO: Figure out a better way to do this
std::ofstream imageFile(filename, std::ios::out | std::ios::binary);
imageFile << "P6\n" << width << " " << height << "\n255\n";
for (int i = 0; i < width * height * 3; i++) {
imageFile << framebuffer[i];
}
imageFile.close();
}
Window::Window(unsigned int w, unsigned int h) {
this->w = w;
this->h = h;
@@ -53,9 +64,17 @@ int Window::init(float* data) {
if (init_quad(data)) return -1;
this->last_frame = std::chrono::steady_clock::now();
while (!glfwWindowShouldClose(window)) {
Window::tick();
}
// TODO: These changes are temporary
// while (!glfwWindowShouldClose(window)) {
// Window::tick();
// }
Window::tick();
Window::tick();
// Save the image
unsigned char* pixels = new unsigned char[this->w * this->h * 3];
glReadPixels(0, 0, this->w, this->h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
saveImage2("output.ppm", pixels, this->w, this->h);
delete[] pixels;
Window::free(data);
return 0;