- Treballant en vore perque no me va en el comp del treball
This commit is contained in:
22
basic.glsl
Normal file
22
basic.glsl
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#define COMPAT_PRECISION
|
||||||
|
|
||||||
|
varying vec2 TEX0;
|
||||||
|
|
||||||
|
#if defined(VERTEX)
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
TEX0 = gl_MultiTexCoord0.st; //vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(FRAGMENT)
|
||||||
|
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = vec4(TEX0.s, TEX0.t, 0, 1); texture2D(Texture, TEX0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
3
main.cpp
3
main.cpp
@@ -18,13 +18,14 @@ int main(int argc, char **argv)
|
|||||||
printf("VIDEO DRIVERS AVAILABLE:\n");
|
printf("VIDEO DRIVERS AVAILABLE:\n");
|
||||||
for (int i=0; i<num_drivers;++i) printf("%i: %s\n", i, SDL_GetVideoDriver(i));
|
for (int i=0; i<num_drivers;++i) printf("%i: %s\n", i, SDL_GetVideoDriver(i));
|
||||||
|
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
||||||
SDL_Renderer *renderer = SDL_CreateRenderer(win, NULL); //-1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
SDL_Renderer *renderer = SDL_CreateRenderer(win, NULL); //-1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||||
if (!renderer) { printf("ERROR al crear el renderer: %s\n", SDL_GetError()); }
|
if (!renderer) { printf("ERROR al crear el renderer: %s\n", SDL_GetError()); }
|
||||||
SDL_Texture *texTarget = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, WIDTH, HEIGHT);
|
SDL_Texture *texTarget = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, WIDTH, HEIGHT);
|
||||||
if (!win) { printf("ERROR al crear la textura target: %s\n", SDL_GetError()); }
|
if (!win) { printf("ERROR al crear la textura target: %s\n", SDL_GetError()); }
|
||||||
|
|
||||||
std::ifstream f("crtpi.glsl");
|
std::ifstream f("basic.glsl");
|
||||||
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
shader::init(win, texTarget, source.c_str());
|
shader::init(win, texTarget, source.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user