Jump to content

Recommended Posts

Posted

Ok, so I got this method within an extender to GuiScreen.

public void drawString(FontRenderer fontRendererIn, String text, int x, int y, float size, int color) {
        GL11.glScalef(size,size,size);
        float mSize = (float)Math.pow(size,-1);
        this.drawString(fontRendererIn,text,x,y,color);
        GL11.glScalef(mSize,mSize,mSize);
    }

which draws a string with a different scale(multiplier) and then resets GL scale to normal..

The problem is, the point of which it scales from is at x,y which means the scale will move the string bottom-right a bit..

Now, since the scalef is not linked to the width of height of anything, it will leave the text in a wierd place once I resize the minecraft screen or move computers to different resolutions..

 

I need to find a way to translate the text back to a point based on scale, x and y. and I just dont know how...

Any help is appreciated..

Doing stuff n' things

Posted
1 hour ago, diesieben07 said:

You need to scale the coordinates as well.

:-\

That I know, but how..

I dont know how much I have to multiply it and to what..

Doing stuff n' things

Posted
2 minutes ago, diesieben07 said:

If you scale everything by 2 and then draw something at 10, 10 it will be drawn at 20,20. For it to actually end up at 10, 10 you need to divide by 2 (the scale).

Thank you so much! I suck at math..

If anyone needs the method:

public void drawString(FontRenderer fontRendererIn, String text, int x, int y, float size, int color) {
        GL11.glScalef(size,size,size);
        float mSize = (float)Math.pow(size,-1);
        this.drawString(fontRendererIn,text,Math.round(x / size),Math.round(y / size),color);
        GL11.glScalef(mSize,mSize,mSize);
    }

 

Doing stuff n' things

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.