Files
rez_demo/sources/GL_STUFF/EFFECTS/Screen.cpp
beno bbede61723 updated makefile for supporting different target architectures
use "ARCH=arch_name make"

restructured project folder, implementations and headers together under sources/
2026-03-16 00:10:52 +01:00

49 lines
1.4 KiB
C++
Executable File

#include "Screen.h"
extern "C" {
#include "../GLES_3_1_compatibility.h"
#include <glut.h>
}
#include <string>
#include "../UTILS/ShaderMaker.h"
Screen::Screen(int left, int top, int width, int height)
: PseudoContext{ left, top, width, height }
{
glGenVertexArrays(1, &quadVAO);
glBindVertexArray(quadVAO);
glGenBuffers(1, &vertVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVerts), quadVerts, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float)/**/,(void*) 0);
glEnableVertexAttribArray(0);
string root = "C:\\Users\\BoBoBoat\\Desktop\\SCUOLA\\CGI\\GL_STUFF\\GL_STUFF\\SOURCES\\EFFECTS\\SCREEN";
string vertSh = root + "\\vertexShader_2.glsl";
string fragSh = root + "\\fragmentShader_2.glsl";
program2 = ShaderMaker::createProgram(&vertSh[0], &fragSh[0]);
shaderTexId = glGetUniformLocation(program2, "inTex");
}
void Screen::setInputTexture(GLuint inputTex) {
inputTexture = inputTex;
}
void Screen::draw() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
//glViewport(left, top, width, height);
//gluOrtho2D(0, width, height, 0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(program2);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, inputTexture);
glUniform1i(shaderTexId, 0);
glBindVertexArray(quadVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
glutSwapBuffers();
}