Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Heyho Guys!

I searched for a method to draw NURBS Curves with GL. The problem is: I googled a bit and it told me that I can use the method GLU.newNurbsRenderer(). The problem is that this method doesnt exist. How can I draw one of these curves? Or is there another way of drawing Curves which are formed with controlpoints like the nurbs curve?

  • Author

This looks quite useful, but I still cannot find out where the needed method gluNewNurbsRenderer is implemented. Either I'm totally blind or it doesn't exist in GLU.class or anywhere else.

 

Edit:

Looks like NURBS are not supported by this version of lwjgl. Take a look over here. Damn.. seems like I have to implement my own methods for this.

I have no Idea how this works but I'll try.

This looks quite useful, but I still cannot find out where the needed method gluNewNurbsRenderer is implemented. Either I'm totally blind or it doesn't exist in GLU.class or anywhere else.

Being a NURBS noob I'm for sure no expert but it looks to me like you can either use the glu methods, or the OpenGL 1.1 glMap2f methods.

i.e. you don't need the glu methods.

(Or - do the matrix maths yourself to generate the patches manually, if you don't go crazy on the number of patches it should be plenty fast enough)

 

-TGG

  • Author
@SideOnly(Side.CLIENT)
public void renderToCodex(GuiCodexMagicum gui, Minecraft mc, int x, int y) {
	if (Codex.getStatusFor(mc.thePlayer, this) > 0) {
		mc.getTextureManager().bindTexture(this.icons);
		GLUtil.resetColour();
		GL11.glDisable(GL11.GL_LIGHTING);
		gui.drawTexturedModalRect(x, y, (Codex.getStatusFor(mc.thePlayer, this) - 1) * 26, this.hasSpecialLayout ? 26 : 0, 26, 26);
		if (this.isIconItem) {
			gui.drawItemStack(this.iconItem, x + 5, y + 5, "");
		} else {
			mc.getTextureManager().bindTexture(this.labels);
			gui.drawTexturedModalRect(x + 5, y + 5, this.iconX * 16, this.iconY * 16, 16, 16);
		}

		GL11.glDisable(GL11.GL_LIGHTING);
		if (Codex.getStatusFor(mc.thePlayer, this) == 1) {
			GLUtil.setColour(0, 0, 0);
		} else {
			GLUtil.setColour((this.lineColour >> 16) % 256, (this.lineColour >>  % 256, this.lineColour % 256);
		}
		GL11.glColor3f(0, 1, 0);
		for (Vertex2D[] line : this.lines) {
			if (line.length > 2) {
				this.renderBezier(gui, line, x - this.getX(), y - this.getY());
			} else {
				GL11.glBegin(GL11.GL_LINE);
				GL11.glVertex3d(line[0].x + x - this.getX(), line[0].y + y - this.getY(), gui.getZLevel() - 2);
				GL11.glVertex3d(line[1].x + x - this.getX(), line[1].y + y - this.getY(), gui.getZLevel() - 2);
				GL11.glEnd();
			}
		}
	}
}

private void renderBezier(GuiCodexMagicum gui, Vertex2D[] controlpoints, int x, int y) {
	FloatBuffer buf = BufferUtils.createFloatBuffer(controlpoints.length * 6);
	for (int i = 0; i < controlpoints.length; i ++) {
		buf.put(i*3, (float) controlpoints[i].x + x);
		buf.put(i*3+1, (float) controlpoints[i].y + y);
		buf.put(i*3+2, gui.getZLevel() - 2);
		buf.put(i*3+3, (float) controlpoints[i].x + x);
		buf.put(i*3+4, (float) controlpoints[i].y + y);
		buf.put(i*3+5, gui.getZLevel() - 2);
	}
	GL11.glMap1f(GL11.GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4, buf);
	GL11.glEnable(GL11.GL_MAP1_VERTEX_3);
	GL11.glBegin(GL11.GL_LINE_STRIP);
	for (int i = 0; i < 24; i ++) {
		GL11.glEvalCoord1f(i / 24.0f);
	}
	GL11.glEnd();
}

I am no expert, but maybe, try using GL11.glColor4f(1, 1, 1, 1); this will enable red, green, blue, and alpha (transparency) I saw you had GL11.glColor3f(0, 1, 0); I have never used this one, but I'm logically assuming that is red, green and blue. so this is only enabling green. But weirdly, you said green is the only one not working. Maybe it is somehow inverted? try setting that 1 to a 0, or all of them to 1.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

When you say "with this code" do you mean when I suggested GL11.glColor4f(1, 1, 1, 1); or when I said to set the 1 to a 0, or when I said to set the zeros to a 1?

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Off topic: Can you post a screenshot of the curve? I'm just curious about how it looks.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

That looks really cool!

 

In my opinion, I think it would look better if you left it black, instead of making it bright green. But, your mod, so your decision.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

  • Author

If I write this piece of code at the beginning of the method, the line is in a very dark green. Maybe this helps you..

		GL11.glDisable(GL11.GL_LIGHTING);
		if (Codex.getStatusFor(mc.thePlayer, this) == 1) {
			GLUtil.setColour(0, 0, 0);
		} else {
			GLUtil.setColour((this.lineColour >> 16) % 256, (this.lineColour >>  % 256, this.lineColour % 256);
		}
		GL11.glColor3f(0, 1, 0);
		for (Vertex2D[] line : this.lines) {
			if (line.length > 2) {
				this.renderBezier(gui, line, x - this.getX(), y - this.getY());
			} else {
				GL11.glBegin(GL11.GL_LINE);
				GL11.glVertex3d(line[0].x + x - this.getX(), line[0].y + y - this.getY(), gui.getZLevel() - 2);
				GL11.glVertex3d(line[1].x + x - this.getX(), line[1].y + y - this.getY(), gui.getZLevel() - 2);
				GL11.glEnd();
			}
		}
	}
}

 

If I use only this piece of code, without the rest, nothing is rendered. Is it possible that the Lines are rendered with the actual texture? Its the Purple/Black Missing Texture, this would explain the green colour problem.

How can I disable the texture, if this is the problem?

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.