Added background to refinement shader
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
int main(int argc, char* args[]) {
|
||||
GLFWwindow* window;
|
||||
GLuint tex1, tex2;
|
||||
GLuint texFG, texBG;
|
||||
int textw, texth;
|
||||
int textw2, texth2;
|
||||
|
||||
@@ -92,20 +92,19 @@ int main(int argc, char* args[]) {
|
||||
|
||||
|
||||
|
||||
tex1 = LoadTexture("../img/tests/flieger.jpg",&textw,&texth);
|
||||
printf("Tex1: %d\n", tex1);
|
||||
texBG = LoadTexture("../img/backgrounds/sky.jpg",&textw2,&texth2);
|
||||
texFG = LoadTexture("../img/tests/flieger.jpg",&textw,&texth);
|
||||
printf("Tex1: %d\n", texFG);
|
||||
glfwSetWindowSize(window, textw, texth);
|
||||
glViewport(0, 0, textw, texth);
|
||||
glfwSetWindowSizeLimits(window, textw, texth, textw, texth);
|
||||
|
||||
// The texture we'<re going to render to
|
||||
// The texture we're going to render to
|
||||
GLuint renderedTexture;
|
||||
glGenTextures(1, &renderedTexture);
|
||||
// "Bind" the newly created texture : all future texture functions will modify this texture
|
||||
glBindTexture(GL_TEXTURE_2D, renderedTexture);
|
||||
// Give an empty image to OpenGL ( the last "0" )
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, textw, texth, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||
// Poor filtering. Needed !
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
@@ -129,9 +128,12 @@ int main(int argc, char* args[]) {
|
||||
|
||||
GLint textureLocTri = glGetUniformLocation(programRefineID, "trimap");
|
||||
GLint textureLocFore = glGetUniformLocation(programRefineID, "foreground");
|
||||
GLint textureLocBack = glGetUniformLocation(programRefineID, "background");
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex1);
|
||||
glBindTexture(GL_TEXTURE_2D, texFG);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, texBG);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, renderedTexture);
|
||||
|
||||
@@ -199,6 +201,7 @@ int main(int argc, char* args[]) {
|
||||
|
||||
glUseProgram(programRefineID);
|
||||
glUniform1i(textureLocTri, 2);
|
||||
glUniform1i(textureLocBack, 1);
|
||||
glUniform1i(textureLocFore, 0);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user