so im setting up a vbo , I tested it with color initially and I attempted to implement color using the loader class that SHC had but im unable to get it to render.
shader.bind();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texid);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordid);
GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0);
// Draw the textured rectangle
GL20.glUniform2f(locationtransform,transformation.x,transformation.y);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertcount);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
shader.unbind();
setup code
vertex = BufferUtils.createFloatBuffer(6 * 2);
texture = BufferUtils.createFloatBuffer(6*2);
vertex.put(new float[]{0,0,1,0,1,1,0,0,0,1,1,1});
texture.put(new float[]{0,0,1,0,1,1,0,0,0,1,1,1});
vertex.rewind();
texture.rewind();
vertid = GL15.glGenBuffers();
texcoordid = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertex, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordid);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texture, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
shaders
#version 330
in vec2 position;
in vec2 texin;
uniform vec2 transform;
out vec2 texpos;
void main(){
texpos = texin;
gl_Position = vec4(position.x + transform.x,position.y + transform.y,0f,0f);
}
#version 330
uniform sampler2D tex;
in vec2 texpos;
void main(){
gl_FragColor = texture(tex,texpos);
}
One thing to note was that when I was performing gl_FragColor = vec4(texpos.x,texpos.y,1,1); it would turn solid blue throughout , meaning the value was always 0. so I think either the data isnt getting sent to the shader correctly or its not getting sent from the vertex shader to the fragment shader.