ported the University CGI demo from WINDOWS + GLUT + GLEW + GLU + OpenGL 4 to LINUX WAYLAND + EGL + GLES 2 with minimal cuts
This commit is contained in:
48
GL_STUFF/SOURCES/EFFECTS/Screen.cpp
Executable file
48
GL_STUFF/SOURCES/EFFECTS/Screen.cpp
Executable file
@@ -0,0 +1,48 @@
|
||||
#include "../../HEADERS/EFFECTS/Screen.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../../GLES_3_1_compatibility.h"
|
||||
#include <glut.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include "../../HEADERS/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();
|
||||
}
|
||||
Reference in New Issue
Block a user