Jump to content

Recommended Posts

Posted

OK guys, once more I need help..

 

Been working on this for a couple of days and I'm a bit stuck with a couple of bugs that I cant tell the source of.

When rendering the GUI for my alter structure There are two major bugs which I've come across.

 

1) There is always one element which does not render properly, from testing this normally seems to be the one which is first in the list. If this element is then moved off the screen the closest visible element to that side of the screen then renders in the same way, and so on:

 

  Reveal hidden contents

 

 

2)If there are no elements being rendered on the GUI the whole GUI renders white

 

  Reveal hidden contents

 

 

The code for the GUI is here, it's mostly a ripoff of the achievements GUI, as I didn't want to go through the hassle of rewriting it for the same effect, so copied it, analysed it and played with it till I got to this point. Left my comments in, just to say what each part does, but if I got anything wrong please correct me, I'm still not very comfortable around lwjgl.

Posted

//1 without looking at the code I'm guessing its binding the texture after each block is drawn, causing the first block to be rendered abnormally

edit: no it seems fine the bindtexture happens once before every time you render an background

 

just for a test you change

	//element render properties
if (dest.isPrivate())
drawTexturedModalRect(i5 - 2, l4 - 2, 26, 202, 26, 26);
else
drawTexturedModalRect(i5 - 2, l4 - 2, 0, 202, 26, 26);

to this

//element render properties
if (dest.isPrivate())
drawTexturedModalRect(i5 - 2, l4 - 2, 0, 202, 26, 26);//note that its now 0 at both place. this is jsut for testing purpose
else
drawTexturedModalRect(i5 - 2, l4 - 2, 0, 202, 26, 26);

 

 

2 im guessing notch code has a bug where if there is no achievement it will not even bother rendering. Which isn't technically a bug because obviously there's always achievement, but might be a problem in your code.

 

honestly it is a pain but if you want to add stuff to make it visually impressive (animation etc) you'll have to eventually change redo some part or the other

 

btw i can see where this is going ... and I to admit that I'm jealous of this ;)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Thanks for the swift reply,

I tested this against the achievements GUI and you can reach a point where there are no achievements shown, it was one of my thoughts before I posted here.

 

  Reveal hidden contents

 

 

as for the change form 0 to 26, the 26 us just the horizontal UV coordinate of the texture which is the texture corresponding to the "pointy" achievement icon:

 

  Reveal hidden contents

 

 

Tested it like that anyway, to see if there was any java oddness going on, but no fix.

 

Any other ideas before i spend the next week trying to find a different way to make the code?

Posted

as the change for 0 to 26, my fear was that it was actually in that space on the texture where theres nothing, turn out its not.

 

I'm sorry i dont have any other idea other then hardcore debugging, but i would very much like to hear about the progress of this. Whats the name of the mod you're making and when do you think you'll be done ?

 

the last thing you could try is straight up duplicate EVERYTHING the achievement thigny use and change things ONE BY ONE, slowly but surely

 

-hydroflame, author FRev-

 

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 6/26/2013 at 6:32 PM, hydroflame said:

the last thing you could try is straight up duplicate EVERYTHING the achievement thigny use and change things ONE BY ONE, slowly but surely

 

hehe, that's mostly what I did when I made it, just not overly slowly (It was fairly obvious what wasn't needed in the code)

 

I think the problem is most likely to be with binding texture for the frame, given that it overlays the whole gui goes white, bar the button which is drawn just after this:

	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	mc.renderEngine.bindTexture("/achievement/bg.png");//gets the texture
	drawTexturedModalRect(i1, j1, 0, 0, guiPaneWidth, guiPaneHeight);//draws the relevant parts
	GL11.glPopMatrix();
	zLevel = 0.0F;
	GL11.glDepthFunc(GL11.GL_LEQUAL);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);

so the big problem is probably something in that lump of GL11, or something which should get called from the loop rendering the parts, but doesn't because there are no parts to be rendered.

Posted

heu ..... i just noticed something

 

 

you said its always the first one to be renderer that fails to have a texture

1 in the case of having "destinations" (or wtv you called your achievement-like-element) the first one to get drawn doesnt have a texture

2 in the case of no "destination" the overlay is white.

 

is it possible that the first thing to get drawn will always be white....

 

 

if thats the case ... cant you just render anything in the background, somethign that will get drawn over by the gui ... this way youll pass over the "first thing drawn is white"

 

-hydroflame-

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Hi again, i found a way to bypass the bug. heuuuuu don't ask why, just know that the texture will render correctly after you draw at least 1 item with renderItem

 

this is a code i was playing around, it seems to render fine even with 0 item to render

 

  Reveal hidden contents

 

 

i had to remove all "altars" related because i didn't have them, but it shouldn't affect the rendering code

 

Cheer,

 

-hydroflame, author FRev-

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I fixed it at about 00:30 (GMT), and didn't have any internet at that time. Managed to identify it as being badly written vanilla code (in my opinion). There was this line "GL11.glDisable(GL11.GL_TEXTURE_2D);" in the vanilla code which I had to remove. This is (as far as I can tell) has no use in the original code as it then gets re-enabled in a method directly, after which draws the lines between achievements. Just had to remove this line and it's all good. (alternatively I could have put GL11.glEnable(GL11.GL_TEXTURE_2D))

 

Thanks for the help anyway.

 

By the looks of it you took a similar method to fixing it as I did, The Item render thingi calls GL11.glEnable(GL11.GL_TEXTURE_2D), which is why it fixed it.

Posted

nice find ;)

 

yeah my method was just trying to bypass the bug, not understand why its happening

 

good job

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.