gui shader

Here is my GUI shader. It works, but I’m wondering about how to switch to integer coordinates instead of floats:

say I do this:

struct VA
{
GLint pos[2];
GLfloat texc[2];
};

(and pack the struct)

or this:

char* v(buffer);

((GLint)(v))++ = a;
((GLint)(v))++ = b;
((GLfloat)(v))++ = c;
((GLfloat)(v))++ = d;

[] means there’s a new file
() means #include


[compatibility_vs.h]

#ifdef GL_ES
# define IN attribute
# define OUT varying
#else
#if (__VERSION__ > 120)
# define IN in
# define OUT out
#else
# define IN attribute
# define OUT varying
#endif // __VERSION __
#endif // GL_ES

[compatibility_fs.h]

#ifdef GL_ES
# define IN varying
#else
#if (__VERSION__ > 120)
# define IN in
# define OUT out
#else
# define IN varying
#endif // __VERSION __
#endif // GL_ES

[gui_shader.vs]
(compatibility_vs.h)

// attributes
IN vec2 wc_position;
IN vec2 tc_texcoords0;
OUT vec2 tc_texcoords0fs;

uniform float invwh[2];

void main()
{
  tc_texcoords0fs = tc_texcoords0;
  gl_Position = vec4(invwh[0] * (2 * wc_position.x) - 1,
    invwh[1] * (2 * wc_position.y) - 1, 1, 1);
}

[gui_shader.fs]
(compatibility_fs.h)

uniform sampler2D tex0; 

IN vec2 tc_texcoords0fs;

#if !defined(GL_ES) && (__VERSION__ > 120)
OUT vec4 gl_FragColor;
#endif

void main()
{
  gl_FragColor = texture2D(tex0, tc_texcoords0fs);
}

[gui_shader.sp]
gui_shader.vs
gui_shader.fs

Oh, well, the answer is glVertexAttribIPointer(), I used to know that, but have since forgotten it :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.