From 15ccb946f43283bfc91d80ddf012d9ae2a0333ed Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 5 May 2019 20:38:16 +0400 Subject: i commit 2 --- Canvas.h | 62 -------------------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Canvas.h (limited to 'Canvas.h') diff --git a/Canvas.h b/Canvas.h deleted file mode 100644 index b2f943d..0000000 --- a/Canvas.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// Created by saintruler on 04.05.19. -// - -#ifndef OPENGLTEST_CANVAS_H -#define OPENGLTEST_CANVAS_H - -#include -#include - -#include - -struct Color -{ - unsigned int r = 0, g = 0, b = 0; -}; - -class Canvas -{ -public: - Canvas(int width, int height) - { - this->width = width; - this->height = height; - - canvas = (unsigned char*) malloc(width * height * 3); - glGenTextures(1, &texture); - } - - void SetPixel(int x, int y, Color color) - { - glBindTexture(GL_TEXTURE_2D, texture); // all upcoming GL_TEXTURE_2D operations now have effect on this texture object - - // set texture wrapping to GL_REPEAT (default wrapping method) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - // set texture filtering parameters - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - canvas[y * width * 3 + x * 3 + 0] = color.r; - canvas[y * width * 3 + x * 3 + 1] = color.g; - canvas[y * width * 3 + x * 3 + 2] = color.b; - - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, width, 0, GL_RGB, GL_UNSIGNED_BYTE, canvas); - glGenerateMipmap(GL_TEXTURE_2D); - } - - unsigned int* GetTexture() - { - return &(this->texture); - } - -private: - int width, height; - unsigned char* canvas; - unsigned int texture; -}; - -#endif //OPENGLTEST_CANVAS_H -- cgit v1.2.3