Im trying to create weapon screen. i have the base of it. But how do i add the picture of the gun on it? Im using VBO to render the base of it.
THis code draws a rectangle and puts a texture on it. But how do i but additional textures/pictures on this rectangle.
In addition it should display currentammo and the totalammo of the weapon.
public class WeaponDisplay extends HudComponent{
String texPath = "res/models/hud/HudWep.png";
public WeaponDisplay(){
position = new Vector2f(10,10);
width = 200;
height = 100;
//Create Vertex Buffer
vertices = BufferUtils.createFloatBuffer(2 * 4); //(x,y)*(4 vertices on a rectangle)
vertices.put(new float[]{0,height, width,height, width,0, 0,0});
vertices.rewind();
//testing texture
isTextured = true;
if(isTextured){
texVertices = BufferUtils.createFloatBuffer(2 * 4);
texVertices.put(new float[]{0,1, 1,1, 1,0, 0,0});
texVertices.rewind();
}
}
@Override
public void renderInitStart() {
if(isTextured){
Texture tex = Texture.loadTexture(texPath);
texture = tex.id;
vboTexVertexID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboTexVertexID);
glBufferData(GL_ARRAY_BUFFER, texVertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
@Override
public void renderDraw() {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_QUADS, 0, 4);
glDisable(GL_BLEND);
}
@Override
public void update() {
// TODO Auto-generated method stub
}
}