Jump to content

Recommended Posts

Posted

I put this into my Gui class method, but I honestly have no idea how GL11 works. however I get an error:

 

########## GL ERROR ##########

@ Post render

1284: Stack underflow

 


private static AC_ModelIceWolf huskyModel = new AC_ModelIceWolf();

public int field_40227_h;
    public float field_40229_i;
    public float field_40225_j;
    public float field_40226_k;
    public float field_40223_l;
    public float field_40224_m;
    public float field_40221_n;

public void drawScreen(int i, int j, float f)
{
this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture("/ArcticCraft/mobs/icewolf.png"));
        GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
        float var10 = this.field_40221_n + (this.field_40224_m - this.field_40221_n) * i;
        GL11.glTranslatef((1.0F - var10) * 0.2F, (1.0F - var10) * 0.1F, (1.0F - var10) * 0.25F);
        GL11.glRotatef(-(1.0F - var10) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
        float var11 = this.field_40225_j + (this.field_40229_i - this.field_40225_j) * i + 0.25F;
        float var12 = this.field_40225_j + (this.field_40229_i - this.field_40225_j) * i + 0.75F;
        var11 = (var11 - (float)MathHelper.func_40346_b((double)var11)) * 1.6F - 0.3F;
        var12 = (var12 - (float)MathHelper.func_40346_b((double)var12)) * 1.6F - 0.3F;

        if (var11 < 0.0F)
        {
            var11 = 0.0F;
        }

        if (var12 < 0.0F)
        {
            var12 = 0.0F;
        }

        if (var11 > 1.0F)
        {
            var11 = 1.0F;
        }

        if (var12 > 1.0F)
        {
            var12 = 1.0F;
        }

        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        huskyModel.render((Entity)null, 0.0F, var11, var12, var10, 0.0F, 0.0625F);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.disableStandardItemLighting();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

Posted

Seems pretty obvious:

You call 2 times GL11.glPopMatrix() without calling any GL11.glPushMatrix() before. Google your error and you'll find help.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Fixed it, but now ive come to notice its not rendering the model correctly at all, i see two pixel wide boxes, and thats all:

 

GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        ScaledResolution var7 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glViewport((var7.getScaledWidth() - 320) / 2 * var7.scaleFactor, (var7.getScaledHeight() - 240) / 2 * var7.scaleFactor, 320 * var7.scaleFactor, 240 * var7.scaleFactor);
        GL11.glTranslatef(-0.34F, 0.23F, 0.0F);
        GLU.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
        float var8 = 1.0F;
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        RenderHelper.enableStandardItemLighting();
        GL11.glTranslatef(0.0F, 3.3F, -16.0F);
        GL11.glScalef(var8, var8, var8);
        float var9 = 5.0F;
        GL11.glScalef(var9, var9, var9);
	this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture("/ArcticCraft/mobs/icewolf.png"));
        GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
        float var10 = this.field_40221_n + (this.field_40224_m - this.field_40221_n) * i;
        GL11.glTranslatef((1.0F - var10) * 0.2F, (1.0F - var10) * 0.1F, (1.0F - var10) * 0.25F);
        float var11 = this.field_40225_j + (this.field_40229_i - this.field_40225_j) * i + 0.15F;
        float var12 = this.field_40225_j + (this.field_40229_i - this.field_40225_j) * i + 0.50F;
        var11 = (var11 - (float)MathHelper.func_40346_b((double)var11)) * 1.6F - 0.3F;
        var12 = (var12 - (float)MathHelper.func_40346_b((double)var12)) * 1.6F - 0.3F;
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        huskyModel.render(this.husky, 0.0F, var11, var12, var10, 0.0F, 0.1000F);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.disableStandardItemLighting();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

Posted

This is a code snippet from the Turret Book GUI from my Turret Mod, which renders a turret entity and let it rotate automatically:

private int rotateTurret = 0;

private void drawTurret(EntityLiving turret) {
	int xPos = (this.width - this.menuW) / 2;
	int yPos = (this.height - this.menuH) / 2;

	if (turret == null) {
		return;
	}

/* some special code for the turrets, not neccessary
	turret.health = turret.getMaxHealth() / 2;

	if (turret instanceof TurretMod_EntityTurretG) {
		((TurretMod_EntityTurretG) turret).ammo = ((TurretMod_EntityTurretG) turret).maxammo / 2;
	} else if (turret instanceof TurretMod_EntityDefenseBot) {
		((TurretMod_EntityDefenseBot) turret).ammo = ((TurretMod_EntityDefenseBot) turret).maxammo / 2;
		((TurretMod_EntityDefenseBot) turret).isTamed = true;
	}*/

	GL11.glPushMatrix();
	GL11.glColor3f(1F, 1F, 1F);
	GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
	GL11.glEnable(2903 /* GL_COLOR_MATERIAL */);
	GL11.glPushMatrix();
	GL11.glTranslatef(xPos + 40, yPos + 98, 50F);
	float f1 = 30F;
	GL11.glScalef(-f1, f1, f1);
	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
	GL11.glRotatef(0.0F, 1.0F, 0.0F, 0.0F);
	turret.renderYawOffset = turret.rotationYaw = turret.prevRotationYaw = turret.prevRotationYawHead = turret.rotationYawHead = this.rotateTurret;
	turret.rotationPitch = 0.0F;
	GL11.glTranslatef(0.0F, turret.yOffset, 0.0F);
	RenderManager.instance.playerViewY = 180F;
	RenderManager.instance.renderEntityWithPosYaw(turret, 0.0D, 0.0D, 0.0D,
			0.0F, 1.0F);
	GL11.glPopMatrix();
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
	GL11.glTranslatef(0F, 0F, 0.0F);
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
	int i1 = 240;
	int k1 = 240;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,
			i1 / 1.0F, k1 / 1.0F);
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(2896 /* GL_LIGHTING */);
	GL11.glDisable(2929 /* GL_DEPTH_TEST */);
	GL11.glPopMatrix();
}

 

This method gets called in the drawScreen method of your GUI. Just change the things to your wishes.

 

The rotateTurret integer field gets incremented in the updateScreen method like this.rotateTurret++;

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

And now it also rotates around the head of my actual mob and not only the rendered one in the gui, and the rendered model is kinda dark

 

You should use a new instance of your entity, or else you get these effects. Also menuW and menuH are the width and height of my gui (223 px and 222 px).

private int menuW = 223, menuH = 222;

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

This is what it looks like:

 

P5HIu.png

 

If its a bit hard to see where it is its at the right of the heal and increase health buttons, the reason its hard to see is because its dark

 

I dunno if there was something changed in the rendering stuff for guis in 1.3. The code is still from the 1.2.5 version of the mod, so I cannot say if it still works correctly for 1.3.

I have to figure this out myself now with an other mod I want to update (which gets a new GUI with features like this). So either you wait until I / an other person respond or you can play with stuff around for yourself.

I think the problem is a colorizing problem. Try to put this code:

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

before this line:

RenderManager.instance.renderEntityWithPosYaw(turret, 0.0D, 0.0D, 0.0D,
			0.0F, 1.0F);

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Im coding for 1.2.5 just now so it should work then, does it have anything to do with my instance?(the GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); didnt change anything)

 

public AC_EntityIceWolf huskythingy = new AC_EntityIceWolf(mc.theWorld);

 

Main code:

/**
 * Called from the main game loop to update the screen.
 */
public void updateScreen()
{
	this.rotateWolf++;
	this.rotateWolf++;
}

private void drawWolf(EntityLiving wolf)
{
	if (wolf == null) 
	{
		return;
	}

	int xPos = (this.width) / 2;
	int yPos = (this.height) / 2;

	GL11.glPushMatrix();
	GL11.glColor3f(1F, 1F, 1F);
	GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
	GL11.glEnable(2903 /* GL_COLOR_MATERIAL */);
	GL11.glPushMatrix();
	GL11.glTranslatef(xPos + 40, yPos + 98, 50F);
	float f1 = 75F;
	GL11.glScalef(-f1, f1, f1);
	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
	GL11.glRotatef(0.0F, 1.0F, 0.0F, 0.0F);
	wolf.renderYawOffset = wolf.rotationYaw = wolf.prevRotationYaw = wolf.prevRotationYawHead = wolf.rotationYawHead = this.rotateWolf;
	wolf.rotationPitch = 0.0F;
	GL11.glTranslatef(0.0F, wolf.yOffset, 0.0F);
	RenderManager.instance.playerViewY = 180F;
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	RenderManager.instance.renderEntityWithPosYaw(wolf, 0.0D, 0.0D, 0.0D,
			0.0F, 1.0F);
	GL11.glPopMatrix();
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
	GL11.glTranslatef(0F, 0F, 0.0F);
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
	int i1 = 240;
	int k1 = 240;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,
			i1 / 1.0F, k1 / 1.0F);
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(2896 /* GL_LIGHTING */);
	GL11.glDisable(2929 /* GL_DEPTH_TEST */);
	GL11.glPopMatrix();
}

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.