Original Post
I would like to know how to bind different textures for rendering my objects which all of them are stored in a single VBO without merging my textures
how to bind different textures[/quote]
First you select a texture unit
[font="Arial"]glActiveTexture(GL_TEXTURE0);[/font]
then bind a texture
glBindTexture
then select another texture unit
[font="Arial"]glActiveTexture(GL_TEXTURE1);
then bind a texture
[/font] glBindTexture
From http://opengl.org/wiki/Texture_Binding
my problem is that how does my VBO knows which texture to use when I call glDrawArray do I need to store something like a texture id on the VBO as well? I have no idea honestly
#version 110
uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform float Select; //Set to 0.0 or 1.0
varying vec2 TexCoord0;
void main()
{
vec4 texel0, texel1;
texel0 = texture2D(Texture0, TexCoord0);
texel1 = texture2D(Texture1, TexCoord0);
gl_FragColor = mix(texel0, texel1, Select);
}
uniform sampler2DArray Texture;
uniform float Select;
varying vec2 TexCoord0;
void main()
{
gl_FragColor = texture2DArray(Texture, vec3(TexCoord0, Select));
}
o wow yeah I was thinking of just doing that
is it just me or the old opengl is way better for 2d stuff?
Ill try to arrange my textures and see if I can at least merge some stuff but it really is not ideal for my and my artist to keep track of things from a single texture :S
[quote name='EvilNando' timestamp='1307166555' post='4819323']
o wow yeah I was thinking of just doing that
is it just me or the old opengl is way better for 2d stuff?
Ill try to arrange my textures and see if I can at least merge some stuff but it really is not ideal for my and my artist to keep track of things from a single texture :S
uniform sampler2DArray Texture;
uniform float Select;
varying vec2 TexCoord0;
void main()
{
gl_FragColor = texture2DArray(Texture, vec3(TexCoord0, Select));
}
Im interested in knowing more on how to use this approach
should I add the corresponding "Select" value to my buffer object then? can you give any more guidance on how should I implement this at the code level?
[quote name='EvilNando' timestamp='1307402246' post='4820293']
Im interested in knowing more on how to use this approach
should I add the corresponding "Select" value to my buffer object then? can you give any more guidance on how should I implement this at the code level?
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more