Login  Register

Re: Modern JOGL, simple texture example

Posted by Xerxes Rånby on Sep 03, 2013; 10:28am
URL: https://forum.jogamp.org/Modern-JOGL-simple-texture-example-tp4029964p4029965.html

elect wrote
Hi,

I didnt managed to find a simple and clear example regarding using texture with modern JOGL

This it what I think it should be the right way, but it's not working and I dont know why
...
Fragment Shader
#version 330

in vec2 fragmentUV;

out vec4 outputColor;

uniform sampler2D myTexture;

void main()
{
    //outputColor = new vec4(1.0f, 0.0f, 0.0f, 1.0f);

    outputColor = texture(myTexture, fragmentUV).rgb;
}
You have a faulty assignment of different type in the fragment shader.
outputColor is a vec4 while you tried to pass it a "vec3" (.rgb)

Use:
    outputColor = texture(myTexture, fragmentUV).rgba;

It worked for me: