Jump to content

[1.7.10] [SOLVED] Having trouble with glTranslateF


ADonkeyTaboggan

Recommended Posts

So I'm drawing images to the hud using RenderGameOverlay. I want to shift around the normal gui to get better placement with my new additions, thus I am attempting to translate the vanilla gui based on what Element type the event is on.

 

Problem is I can't seem to change the position of the experience bar without changing every element even though I'm checking if the ElementType is Experience. I tried to use push and pop matrix but that didn't seem to help things.

 

Code:

public void renderGameOverlay(RenderGameOverlayEvent event) {
        if(event.type == ElementType.EXPERIENCE) {
            GL11.glTranslatef(0.0F, (float)(-7), 0.0F);
        } else {
            GL11.glTranslatef(0.0F, (float)(0), 0.0F);
        }
}

 

Result:

http://i.imgur.com/MyVDs66.png

 

I'm probably not quite understanding something simple tbh =p

 

Link to comment
Share on other sites

It seems like it is moving everything BUT the experience bar. Try this:

public void renderGameOverlay(RenderGameOverlayEvent event) {
        if(event.type == ElementType.EXPERIENCE) {
            GL11.glTranslatef(0.0F, (float)(0), 0.0F);
        } else {
            GL11.glTranslatef(0.0F, (float)(-7), 0.0F);
        }
}

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Oh wait, I might be getting this wrong. The problem is that the experience bar and the overlay when in a gui is moving? Or that everything but the experience bar is moving?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

So first off I should of clarified that my custom gui elements are not there so I don't add more confusion.

 

The Experience bar is doing exactly as expected, and so is the rest of the HUD elements (Not hot bar is directly on the bottom of my game window) but the problem is it seems ALL other gui elements are also shifted upwards. I demonstrate that in the image from the fact I am apparently hovering over a slot when the gui is being shown above it.

 

Edit: derp my mouse isnt in the screenshot... well take my word for it I guess xD

 

Link to comment
Share on other sites

Hm alright, this could be because you're not pushing and popping the matrix. Although, I am not sure considering I have only worked with OpenGl a handful of times. Try this:

public void renderGameOverlay(RenderGameOverlayEvent event) {
        if(event.type == ElementType.EXPERIENCE) {
            GL11.glPushMatrix();
                   GL11.glTranslatef(0.0F, (float)(-7), 0.0F);
            GL11.glPopMatrix();
        } else {
            //GL11.glTranslatef(0.0F, (float)(0), 0.0F); <- There is no need to reset this if you're just editing the Experience bar 
        }
}

 

Just trying to give you my knowledge to help. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Well, I know normally with OpenGL, if you don't push and pop it the matrix, it will edit other things too. I just tried doing some debugging, and it seems when I check for the HEALTH enum, it only moves the experience bar, like for some reason it's incorrect? Try messaging Erino if he doesn't reply to this post. He is very experienced in GL11, and could help you far more than I could.

 

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

The reason your code doesn't do anything, HappyKiller, is because you push the matrix, create an offset, then pop the matrix all before the event notification has finished executing, so when the actual render call is made, there are no changes.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.