PDA

View Full Version : applying texture to the application surface



Heavybrush
09-26-2016, 08:09 AM
how to change the color of the application surface, using the texture??

https://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes

https://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes#/media/File:CGA_palette_color_test_chart.png

https://upload.wikimedia.org/wikipedia/commons/c/c5/CGA_palette_color_test_chart.png

my fragment shader start in this way:



varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
{
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
}


thanks

john_connor
09-26-2016, 10:46 AM
i think you are missing the texture sampler:


uniform sampler2D gm_BaseTexture;


if you want to use multiple textures, you have to explicitly assign a value to "gm_BaseTexture":
c-code:


unsigned int textureunit = ..anynumber..;

// get sampler location:
int location = getUniformLocation(shader, "gm_BaseTexture");
// send texture location to the sampler:
glProgramUniform1i(shader, location, textureunit);
// bind texture to texture unit
glActiveTexture(GL_TEXTURE0 + textureunit);
glBindTexture(GL_TEXTURE_2D, texture);

Silence
09-27-2016, 12:14 AM
If I understood you well, you should better search in this direction (https://en.wikipedia.org/wiki/HSL_and_HSV).

Cabeceira
09-28-2016, 04:09 AM
If I understood you well, you should better search in this direction (https://en.wikipedia.org/wiki/HSL_and_HSV).

nice link.. it is detailed.. got it ifirmative