Jump to content

Recommended Posts

Posted (edited)

Hello. So I've been working on this mod for just around 2 years, and currently I'm adding a feature where items with a specific rarity glow just like with spectre arrow in the rarity of the item. Just a disclaimer, the project I work for is closed source so I wont be able to link to the git repo, but I do have in fact narrowed it down to a single OpenGL feature which shouldn't require my original source.

 

So back to the topic, I do have this feature 100% working and so I'm not here with help for that. Currently, my problem is maintaining compatibility with my previous features. Basically I have a lock item system where you can lock the items and not drop them. These items are indicated by a lock texture in the top right corner of the item slot, overlaying some of the item. Now getting the glow requires using shaders, which in turn requires a separate framebuffer, atleast to my knowledge. The system took just over a day to get working flawlessly, until I wanted to render the locks again, and noticed they are at the wrong location of the screen, which is the top left corner.

 

Having had this type of problem before I knew it was the scaling (from Gui Scale in video settings) reset, and I assumed it would be in the glow render code so I commented that out, built the code (Gotta love IntelliJ HotSwap <3), and noticed that the lock did indeed pop back to where they belong. After this it was just a matter of closing down the code step by step until I had only one part. I found last call made by me affecting the problem was Framebuffer#framebufferRenderExt. Now from reading help threads I knew this wasn't enough so I looked in the method and saw 2 key components. Resetting the view mode (in this case Orthographic), and resetting the viewport. I went into my main code for the gui rendering again and commented out the glow code call, and as a test, added a reset for orthographic just to test my theory and indeed that was the source of the problem. Just for reference this is a small illustration of my method at that point

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  // irrelevant code
  
  GL11.glPushMatrix();
  GL11.glMatrixMode(GL11.GL_PROJECTION);
  GL11.glLoadIdentity();
  GL11.glOrtho(0, mc.displayWidth, mc.displayHeight, 0, 1000f, 3000f);
  GL11.glMatrixMode(GL11.GL_MODELVIEW);
  GL11.glLoadIdentity();
  //RarityGlow.renderGlow(this);
  GL11.glPopMatrix();
  
  renderLocks();
}

Now my first thought was to somehow push the matrix mode or view, and thought of glPushAttrib. I looked up the problem on google, both for forge and in general, and found that pushing GL_TRANSFORM_BIT and GL_VIEWPORT_BIT should do the trick. I did try this, but that didn't work. So my current concern is, how would I go ahead and push/pop (or similar) the state in order to solve this said problem?

 

Edit: Also noting this is 1.12 which means Java 1.8. Forgot to mention that.

Edited by Kirdow

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.