Jump to content

Recommended Posts

Posted (edited)

Hello.

So I have a GuiScreen that isn't displaying textures it loaded and I am at a loss of ideas.

 

This is my render function in my gui.

@Override
public void render(int mouseX, int mouseY, float partialTicks) {
	List<Spell> spells = this.isg.getSpells();
		
	if(spells.size() > 0) {
		double angle = (2 * Math.PI) / (spells.size());
		double range = 90;
			
		for(int i = 0; i < spells.size(); i++) {
			int x = (int) (range * Math.sin(angle * i));
			int y = (int) (-range * Math.cos(angle * i));
				
			GlStateManager.color3f(1.0F, 1.0F, 1.0F);
			this.mc.getTextureManager().bindTexture(spells.get(i).getSpellTexture());
			SoulMagic.LOGGER.info("hello");
			this.drawTexturedModalRect((this.width / 2) + x - 16, (this.height / 2) + y - 16, 0, 0, 32, 32);
		}
	}
	super.render(mouseX, mouseY, partialTicks);
}

 

I know for a fact that my x and y positions are correct and my textures are being loaded, as it showed a broken texture in the right positions when the texture weren't being loaded properly. With the logger.info it spams "hello" in the console, so it is being called.

I'm not good with GUIs so I don't know if "render" is the best place for it. I only know the draw foreground/background methods from GuiContainer. I grabbed that GlStateManager statement from somewhere, it was originally .color4f but that doesn't work either.

 

The textures is 32x32 and I want to render the whole thing. I am on Forge Version 1.13.2-25.0.215, the latest version of forge for 1.13.2.

Edited by RainbowLuigi281
Posted

drawTexturedModalRect assumes that the size of your texture is 256x256, so you are drawing a rect with the texture coordinates from 0, 0 to 8, 8 px.

You would need to either hve a custom implementation or use one of the overloads that allows you to specify the UVs directly.

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.