Preparing to add texture to quad

This commit is contained in:
Caesar2011
2016-09-05 17:49:15 +02:00
parent 0279e9c3a0
commit 866fabdf45
5 changed files with 77 additions and 60 deletions

View File

@@ -67,7 +67,7 @@ void DrawTexture(int x, int y, GLuint textureid,int textw,int texth) {
glTexCoord2d(1.0,1.0); glVertex2f(1, 1);
glTexCoord2d(0.0,1.0); glVertex2f(-1, 1);
glEnd();
glDisable(GL_TEXTURE_2D );
glDisable(GL_TEXTURE_2D);
}
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){
@@ -214,12 +214,14 @@ int main(int argc, char* args[]) {
// INIT
tex_jpe=LoadTexture("../img/tests/test.jpeg",&textw,&texth);
tex_jpg=LoadTexture("../img/tests/test.jpg",&textw,&texth);
tex_png=LoadTexture("../img/tests/test.png",&textw,&texth);
tex_bmp=LoadTexture("../img/tests/test.bmp",&textw,&texth);
//tex_jpg=LoadTexture("../img/tests/test.jpg",&textw,&texth);
//tex_png=LoadTexture("../img/tests/test.png",&textw,&texth);
//tex_bmp=LoadTexture("../img/tests/test.bmp",&textw,&texth);
GLuint programID = LoadShaders("trimap.vertexshader", "trimap.fragmentshader");
printf("%d", programID);
GLint textureLocation = glGetUniformLocationARB(programID, "texture");
glUniform1iARB(textureLocation, tex_jpe);
// INIT END
/* Loop until the user closes the window */
@@ -229,17 +231,24 @@ int main(int argc, char* args[]) {
timer = 0;
/* Render here */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(programID);
// RENDER
if (timer<200)
/*if (timer<200)
DrawTexture(50,50,tex_jpe,textw,texth);
else if (timer<400)
DrawTexture(50,50,tex_jpg,textw,texth);
else if (timer<600)
DrawTexture(50,50,tex_png,textw,texth);
else
DrawTexture(50,50,tex_bmp,textw,texth);
DrawTexture(50,50,tex_bmp,textw,texth);*/
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, 0);
glTexCoord2d(0.0,1.0); glVertex2f(-1, 0);
glEnd();
// RENDER END
/* Swap front and back buffers */

View File

@@ -2,7 +2,7 @@
1385320478 source:d:\owncloud\documents\programmierung\cpp\opengl-test-two\main.cpp
<iostream>
1473007864 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
1473070070 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
<GL/glew.h>
<GLFW/glfw3.h>
<SDL2/SDL.h>
@@ -13,7 +13,7 @@
<vector>
<stdexcept>
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
<stddef.h>
<stdint.h>
<OpenGL/gl3.h>
@@ -34,7 +34,7 @@
<GL/glext.h>
<GL/glu.h>
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
"SDL_main.h"
"SDL_stdinc.h"
"SDL_assert.h"
@@ -65,12 +65,12 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
"SDL_config.h"
<sys/types.h>
<stdio.h>
@@ -99,34 +99,34 @@
<stdlib.h>
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
"SDL_platform.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
"AvailabilityMacros.h"
"TargetConditionals.h"
<winapifamily.h>
"begin_code.h"
"close_code.h"
1472737758 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\begin_code.h
1472737758 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\close_code.h
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
"SDL_config.h"
"begin_code.h"
<signal.h>
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
"SDL_stdinc.h"
"SDL_platform.h"
"begin_code.h"
<mbarrier.h>
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_endian.h"
@@ -136,24 +136,24 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
"SDL_stdinc.h"
<endian.h>
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_atomic.h"
@@ -162,18 +162,18 @@
<process.h>
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
"SDL_stdinc.h"
<intrin.h>
<intrin.h>
@@ -185,7 +185,7 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
@@ -199,7 +199,7 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
"SDL_stdinc.h"
"SDL_pixels.h"
"SDL_rect.h"
@@ -207,12 +207,12 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_pixels.h"
@@ -220,7 +220,7 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
"SDL_stdinc.h"
"SDL_pixels.h"
"SDL_rect.h"
@@ -229,11 +229,11 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_keycode.h"
@@ -241,27 +241,27 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
"SDL_stdinc.h"
"SDL_scancode.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
"SDL_stdinc.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_rwops.h"
@@ -269,11 +269,11 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
"SDL_stdinc.h"
"SDL_error.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
@@ -281,60 +281,60 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_joystick.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
"SDL_stdinc.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
"SDL_stdinc.h"
"SDL_rect.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
"SDL_stdinc.h"
"SDL_keyboard.h"
"SDL_render.h"
@@ -342,24 +342,24 @@
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1472737758 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
"SDL.h"
"SDL_version.h"
"begin_code.h"
"close_code.h"
1472927170 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
<stddef.h>
<inttypes.h>
<stdint.h>

View File

@@ -1,8 +1,11 @@
#version 330 core
uniform sampler2D texture;
in vec2 vTexCoord;
out vec4 color;
void main(){
color = vec3(0.5,0,0);
//color = vec4(1f,0f,0f,1.0f);
vec2 tcoord=vec2(0.5f,0.5f);
color = vec4(texelFetch(texture, ivec2(vTexCoord), 0).rgb, 1);
}

View File

@@ -1,8 +1,13 @@
#version 330 core
#version 400
layout(location = 0) in vec3 vertexPosition_modelspace;
in vec2 aVertex;
in vec2 aTexCoord;
void main(){
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
out vec2 vTexCoord;
out vec3 vNormal;
void main()
{
vTexCoord = aTexCoord;
gl_Position = vec3(aVertex, 1);
}