0

I have gotten my code for this mostly working using some code i found for drawing with quads but it seems to only take up the lower left-hand corner of the minecraft screen with my image when it should take up the whole thing. I think i need some way to scale it but i don't know why i should need that or if i do... the code for doing the drawing is correct it's just that it's not drawing in the right spot... and i don't know why.

private void drawImageQuad(int textureHandle, int x, int y, float w, float h) {
    // activate the specified texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D,textureHandle);
    // prepare to render in 2D
    setOrthoOn();
    // draw the image textured onto a quad
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0f, 0f);
    GL11.glVertex3f( (float)x, (float)y, (float)0);
    GL11.glTexCoord2f(1f, 0f);
    GL11.glVertex3f( (float)x+w, (float)y, (float)0);
    GL11.glTexCoord2f(1f, 1f);
    GL11.glVertex3f( (float)x+w, (float)y+h, (float)0);
    GL11.glTexCoord2f(0f, 1f);
    GL11.glVertex3f( (float)x, (float)y+h, (float)0);
    GL11.glEnd();
    // restore the previous perspective and model views
    setOrthoOff();
}


private void setOrthoOn()
{
    // prepare to render in 2D
    if(GL11.glIsEnabled(GL11.GL_DEPTH_TEST)){
        depthTest=true;
        GL11.glDisable(GL11.GL_DEPTH_TEST);
    }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();                            // preserve perspective view
    GL11.glLoadIdentity();                          // clear the perspective matrix
    GL11.glOrtho(0,width,0,height,-1,1);  // turn on 2D
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();     // Preserve the Modelview Matrix
    GL11.glLoadIdentity();   // clear the Modelview Matrix
}

private void setOrthoOff()
{
    // restore the original positions and views
    if(depthTest){
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        depthTest = false;
    }
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
}

/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int par1, int par2, float par3)
{
    //renderSkybox(par1, par2, par3);
    Tessellator tessellator = Tessellator.instance;
    double zoom = width/(double)384;
    int widthOffset = (int)((width - (384*zoom))/2);
    int widthOffset2 = widthOffset +(width*(384/256));
    this.drawImageQuad(mc.renderEngine.getTexture("/title/background0.png"),widthOffset,(height - (int)(256*zoom))/2,widthOffset+(int)(256*zoom),height+((height - (int)(256*zoom))/2));
    this.drawImageQuad(mc.renderEngine.getTexture("/title/background1.png"),widthOffset2,(height - (int)(256*zoom))/2,widthOffset2+(int)(256*zoom),height+((height - (int)(256*zoom))/2));
4

0 回答 0