Compare commits
9 Commits
texturebuf
...
framebuffe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6adef607f2 | ||
|
|
996564ed7d | ||
|
|
08776360c2 | ||
|
|
4f347a6ef5 | ||
|
|
364ed31d8e | ||
|
|
b1c6dcfecb | ||
|
|
2147b74e86 | ||
|
|
2acbd0c10f | ||
|
|
fe718a4658 |
BIN
img/tests/flieger.jpg
Normal file
BIN
img/tests/flieger.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
BIN
img/tests/flieger2.jpg
Normal file
BIN
img/tests/flieger2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
@@ -54,22 +54,6 @@ GLuint LoadTexture(char *filename,int *textw,int *texth) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTexture(int x, int y, GLuint textureid,int textw,int texth) {
|
|
||||||
//printf("x: %d\ty: %d\tw: %d\th: %d\n", x, y, textw, texth);
|
|
||||||
//int textw,texth;
|
|
||||||
// tell opengl to use the generated texture name
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textureid);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
// make a rectangle
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2d(0.0,0.0); glVertex2f(-1, -1);
|
|
||||||
glTexCoord2d(1.0,0.0); glVertex2f(1, -1);
|
|
||||||
glTexCoord2d(1.0,1.0); glVertex2f(1, 1);
|
|
||||||
glTexCoord2d(0.0,1.0); glVertex2f(-1, 1);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){
|
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){
|
||||||
|
|
||||||
// Create the shaders
|
// Create the shaders
|
||||||
@@ -164,13 +148,55 @@ GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path
|
|||||||
return ProgramID;
|
return ProgramID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint WriteTexture(int textw, int texth){
|
||||||
|
// The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
|
||||||
|
GLuint FramebufferName = 0;
|
||||||
|
glGenFramebuffers(1, &FramebufferName);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// The depth buffer -- OPTIONAL, REMOVE WHEN NOT NEEDED
|
||||||
|
GLuint depthrenderbuffer;
|
||||||
|
glGenRenderbuffers(1, &depthrenderbuffer);
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer);
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1024, 768);
|
||||||
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthrenderbuffer);
|
||||||
|
|
||||||
|
// Set "renderedTexture" as our colour attachement #0
|
||||||
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);
|
||||||
|
|
||||||
|
// Set the list of draw buffers.
|
||||||
|
GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
|
||||||
|
glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers
|
||||||
|
|
||||||
|
// Always check that our framebuffer is ok
|
||||||
|
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Render to our framebuffer
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
||||||
|
glViewport(0, 0, textw, texth);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* args[]) {
|
int main(int argc, char* args[]) {
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
GLuint tex_jpe;
|
GLuint tex1, tex2;
|
||||||
int textw, texth;
|
int textw, texth;
|
||||||
int timer = 0;
|
int textw2, texth2;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the library */
|
/* Initialize the library */
|
||||||
@@ -181,10 +207,11 @@ int main(int argc, char* args[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Create a windowed mode window and its OpenGL context */
|
/* Create a windowed mode window and its OpenGL context */
|
||||||
|
glfwSetWindowSizeLimits(window, 640, 480, 640, 480);
|
||||||
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
|
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Make the window's context current */
|
/* Make the window's context current */
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
@@ -209,10 +236,6 @@ int main(int argc, char* args[]) {
|
|||||||
}
|
}
|
||||||
// INIT
|
// INIT
|
||||||
|
|
||||||
|
|
||||||
GLuint VertexArrayID;
|
|
||||||
glGenVertexArrays(1, &VertexArrayID);
|
|
||||||
glBindVertexArray(VertexArrayID);
|
|
||||||
// An array of 3 vectors which represents 3 vertices
|
// An array of 3 vectors which represents 3 vertices
|
||||||
static const GLfloat g_vertex_buffer_data[] = {
|
static const GLfloat g_vertex_buffer_data[] = {
|
||||||
-1.0f, -1.0f, 0.0f, // (bottom - left ) TRIANGLE 1
|
-1.0f, -1.0f, 0.0f, // (bottom - left ) TRIANGLE 1
|
||||||
@@ -247,29 +270,47 @@ int main(int argc, char* args[]) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tex1 = LoadTexture("../img/tests/flieger.jpg",&textw,&texth);
|
||||||
|
printf("Tex1: %d", tex1);
|
||||||
|
tex2 = LoadTexture("../img/tests/flieger2.jpg",&textw2,&texth2);
|
||||||
|
printf("Tex2: %d", tex2);
|
||||||
tex_jpe=LoadTexture("../img/tests/test.bmp",&textw,&texth);
|
glfwSetWindowSize(window, textw, texth);
|
||||||
|
glViewport(0, 0, textw, texth);
|
||||||
|
glfwSetWindowSizeLimits(window, textw, texth, textw, texth);
|
||||||
|
|
||||||
GLuint programID = LoadShaders("trimap.vertexshader", "trimap.fragmentshader");
|
GLuint programID = LoadShaders("trimap.vertexshader", "trimap.fragmentshader");
|
||||||
printf("%d", programID);
|
GLint textureLoc1 = glGetUniformLocation(programID, "myTextureSampler");
|
||||||
GLint textureLocation = glGetUniformLocationARB(programID, "myTextureSampler");
|
GLint textureLoc2 = glGetUniformLocation(programID, "myTextureSampler2");
|
||||||
glUniform1i(textureLocation, tex_jpe);
|
GLint widthLoc = glGetUniformLocation(programID, "pixWidth");
|
||||||
|
GLint heigthLoc = glGetUniformLocation(programID, "pixHeight");
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tex1);
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tex2);
|
||||||
|
|
||||||
|
|
||||||
|
printf("Shader program ID: %d\n", programID);
|
||||||
|
printf("textureLoc1: %d\n", textureLoc1);
|
||||||
|
printf("textureLoc2: %d\n", textureLoc2);
|
||||||
|
printf("widthLoc: %d\n", widthLoc);
|
||||||
|
printf("heigthLoc: %d\n", heigthLoc);
|
||||||
|
printf("Width: %f\n", 1.0f/textw);
|
||||||
|
printf("Height: %f\n", 1.0f/texth);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// INIT END
|
// INIT END
|
||||||
/* Loop until the user closes the window */
|
/* Loop until the user closes the window */
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
timer += 1;
|
|
||||||
if (timer==800)
|
|
||||||
timer = 0;
|
|
||||||
/* Render here */
|
/* Render here */
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glUseProgram(programID);
|
glUseProgram(programID);
|
||||||
|
glUniform1f(widthLoc, 1.0f/textw);
|
||||||
|
glUniform1f(heigthLoc, 1.0f/texth);
|
||||||
|
glUniform1i(textureLoc1, 0);
|
||||||
|
glUniform1i(textureLoc2, 1);
|
||||||
|
|
||||||
// 1rst attribute buffer : vertices
|
// 1rst attribute buffer : vertices
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
1385320478 source:d:\owncloud\documents\programmierung\cpp\opengl-test-two\main.cpp
|
1385320478 source:d:\owncloud\documents\programmierung\cpp\opengl-test-two\main.cpp
|
||||||
<iostream>
|
<iostream>
|
||||||
|
|
||||||
1473097371 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
|
1473145022 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
|
||||||
<GL/glew.h>
|
<GL/glew.h>
|
||||||
<GLFW/glfw3.h>
|
<GLFW/glfw3.h>
|
||||||
<SDL2/SDL.h>
|
<SDL2/SDL.h>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<vector>
|
<vector>
|
||||||
<stdexcept>
|
<stdexcept>
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
|
||||||
<stddef.h>
|
<stddef.h>
|
||||||
<stdint.h>
|
<stdint.h>
|
||||||
<OpenGL/gl3.h>
|
<OpenGL/gl3.h>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<GL/glext.h>
|
<GL/glext.h>
|
||||||
<GL/glu.h>
|
<GL/glu.h>
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
|
||||||
"SDL_main.h"
|
"SDL_main.h"
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_assert.h"
|
"SDL_assert.h"
|
||||||
@@ -65,12 +65,12 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
|
||||||
"SDL_config.h"
|
"SDL_config.h"
|
||||||
<sys/types.h>
|
<sys/types.h>
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
@@ -99,34 +99,34 @@
|
|||||||
<stdlib.h>
|
<stdlib.h>
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
|
||||||
"SDL_platform.h"
|
"SDL_platform.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
|
||||||
"AvailabilityMacros.h"
|
"AvailabilityMacros.h"
|
||||||
"TargetConditionals.h"
|
"TargetConditionals.h"
|
||||||
<winapifamily.h>
|
<winapifamily.h>
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\begin_code.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\begin_code.h
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\close_code.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\close_code.h
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
|
||||||
"SDL_config.h"
|
"SDL_config.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
<signal.h>
|
<signal.h>
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_platform.h"
|
"SDL_platform.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
<mbarrier.h>
|
<mbarrier.h>
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_endian.h"
|
"SDL_endian.h"
|
||||||
@@ -136,24 +136,24 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
<endian.h>
|
<endian.h>
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_atomic.h"
|
"SDL_atomic.h"
|
||||||
@@ -162,18 +162,18 @@
|
|||||||
<process.h>
|
<process.h>
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
<intrin.h>
|
<intrin.h>
|
||||||
<intrin.h>
|
<intrin.h>
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_pixels.h"
|
"SDL_pixels.h"
|
||||||
"SDL_rect.h"
|
"SDL_rect.h"
|
||||||
@@ -207,12 +207,12 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_pixels.h"
|
"SDL_pixels.h"
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_pixels.h"
|
"SDL_pixels.h"
|
||||||
"SDL_rect.h"
|
"SDL_rect.h"
|
||||||
@@ -229,11 +229,11 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_keycode.h"
|
"SDL_keycode.h"
|
||||||
@@ -241,27 +241,27 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_scancode.h"
|
"SDL_scancode.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_rwops.h"
|
"SDL_rwops.h"
|
||||||
@@ -269,11 +269,11 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
@@ -281,60 +281,60 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"SDL_joystick.h"
|
"SDL_joystick.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_rect.h"
|
"SDL_rect.h"
|
||||||
"SDL_video.h"
|
"SDL_video.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_keyboard.h"
|
"SDL_keyboard.h"
|
||||||
"SDL_render.h"
|
"SDL_render.h"
|
||||||
@@ -342,24 +342,24 @@
|
|||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"SDL_error.h"
|
"SDL_error.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
|
||||||
"SDL_stdinc.h"
|
"SDL_stdinc.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
|
||||||
"SDL.h"
|
"SDL.h"
|
||||||
"SDL_version.h"
|
"SDL_version.h"
|
||||||
"begin_code.h"
|
"begin_code.h"
|
||||||
"close_code.h"
|
"close_code.h"
|
||||||
|
|
||||||
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
|
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
|
||||||
<stddef.h>
|
<stddef.h>
|
||||||
<inttypes.h>
|
<inttypes.h>
|
||||||
<stdint.h>
|
<stdint.h>
|
||||||
|
|||||||
@@ -4,14 +4,77 @@
|
|||||||
in vec2 UV;
|
in vec2 UV;
|
||||||
|
|
||||||
// Ouput data
|
// Ouput data
|
||||||
out vec3 color;
|
//out vec3 color;
|
||||||
|
layout(location = 0) out vec3 color;
|
||||||
|
|
||||||
// Values that stay constant for the whole mesh.
|
// Values that stay constant for the whole mesh.
|
||||||
uniform sampler2D myTextureSampler;
|
uniform sampler2D myTextureSampler;
|
||||||
|
uniform sampler2D myTextureSampler2;
|
||||||
|
|
||||||
void main(){
|
// Relative width/height of a pixel
|
||||||
|
uniform float pixWidth;
|
||||||
|
uniform float pixHeight;
|
||||||
|
|
||||||
// Output color = color of the texture at the specified UV
|
|
||||||
color = texture( myTextureSampler, UV ).rgb;
|
// Pixel state
|
||||||
|
int IS_BACKGROUND = 0;
|
||||||
|
int IS_UNDEFINED = 1;
|
||||||
|
int IS_FOREGROUND = 2;
|
||||||
|
int UNSET = -1;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 getColor(vec2 uvCoord) {
|
||||||
|
return texture(myTextureSampler2, uvCoord).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBackground(vec3 c) {
|
||||||
|
/*// 49,206, 11
|
||||||
|
if (all( lessThanEqual(c, vec3(51.0f/255.0f, 208.0f/255.0f, 13.0f/255.0f))) &&
|
||||||
|
all(greaterThanEqual(c, vec3(47.0f/255.0f, 204.0f/255.0f, 9.0f/255.0f)))*/
|
||||||
|
// 0, 255, 0
|
||||||
|
if (all( lessThanEqual(c, vec3(2.0f/255.0f, 255.0f/255.0f, 2.0f/255.0f))) &&
|
||||||
|
all(greaterThanEqual(c, vec3(0.0f/255.0f, 253.0f/255.0f, 0.0f/255.0f)))
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
int status = UNSET;
|
||||||
|
|
||||||
|
for(int w=-5;w<=5;w++){
|
||||||
|
for(int h=-5;h<=5;h++){
|
||||||
|
if (w+h==-10) { // first pixel
|
||||||
|
if (isBackground(getColor(UV+vec2(pixWidth*w, pixHeight*h)))) {
|
||||||
|
status = IS_BACKGROUND;
|
||||||
|
} else {
|
||||||
|
status = IS_FOREGROUND;
|
||||||
|
}
|
||||||
|
} else { // other pixels
|
||||||
|
if (isBackground(getColor(UV+vec2(pixWidth*w, pixHeight*h)))) {
|
||||||
|
if (status != IS_BACKGROUND) {
|
||||||
|
status = IS_UNDEFINED;
|
||||||
|
w=100000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (status != IS_FOREGROUND) {
|
||||||
|
status = IS_UNDEFINED;
|
||||||
|
w=100000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == IS_BACKGROUND) {
|
||||||
|
color = vec3(1.0f, 0.0f, 0.0f);
|
||||||
|
} else if (status == IS_FOREGROUND) {
|
||||||
|
color = vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
} else {
|
||||||
|
color = vec3(0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ out vec2 UV;
|
|||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
// Output position of the vertex, in clip space : MVP * position
|
// Output position of the vertex, in clip space : MVP * position
|
||||||
gl_Position = vec4(vertexPosition_modelspace,1);
|
gl_Position = vec4(vertexPosition_modelspace, 1);
|
||||||
|
|
||||||
// UV of the vertex. No special space for this one.
|
// UV of the vertex. No special space for this one.
|
||||||
UV = vertexUV;
|
UV = vertexUV;
|
||||||
|
|||||||
Reference in New Issue
Block a user