Jump to content

  • Log In with Google      Sign In   
  • Create Account


We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Member Since 08 Jun 2010
Offline Last Active Jul 13 2012 04:20 PM

Posts I've Made

In Topic: Billboarding woes

14 December 2011 - 09:27 AM

Got it working, finally ;D ;D ;D ;D ;D ;D ;D

public void drawBillBoardSprite(Texture texture, Vector3f sprPos, float r, float g, float b, int sprWidth, int sprHeight){
		 // store the current model matrix
			GL11.glTranslatef(sprPos.x, 0, sprPos.z);
			// bind to the appropriate texture for this sprite
			FloatBuffer modelview = BufferUtils.createFloatBuffer(16);

			// get the current modelview matrix
			GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
			// Note that a row in the C convention is a column 
			// in OpenGL convention (see the red book, pg.106 in version 1.2)
			// right vector is [1,0,0]  (1st column)
			// lookAt vector is [0,0,1] (3d column)
			// leave the up vector unchanged (2nd column)
			// notice the increment in i in the first cycle (i+=2)
			for(int i=0; i<3; i+=2 ) 
				for(int j=0; j<3; j++ ) {
					if ( i==j )
						modelview.put(i*4+j, 1.0f);
						modelview.put(i*4+j, 0.0f);

			// set the modelview matrix
			// draw a quad textured to match the sprite
				GL11.glTexCoord2f(0,0);										GL11.glVertex3f( - (sprWidth/2), (sprHeight/2), 0);	// Top left Of The Quad (Left)
				GL11.glTexCoord2f(texture.getWidth(), 0);					GL11.glVertex3f( + (sprWidth/2), (sprHeight/2), 0);  // Top right Of The Quad (Left)
				GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());	GL11.glVertex3f( + (sprWidth/2), -(sprHeight/2), 0);   // Bottom right Of The Quad (Left)
				GL11.glTexCoord2f(0, texture.getHeight());					GL11.glVertex3f( - (sprWidth/2), -(sprHeight/2), 0);   // Bottom left Of The Quad (Left)
		// restore the model view matrix to prevent contamination

In Topic: Nothing showing up on screen?

13 April 2011 - 11:09 AM

Couple thoughts:

1) You call LoadIdentity in the beginning of render on an unspecified matrix stack. Does this clear the projection matrix on the first pass, as that stack is still bound when you exit the setup function?

2) What color is your quad supposed to be? Why is texturing enabled?

3) Your quad is lying on the near plane, not sure how the clipping calculations work exactly but I'm not positive if things exactly on the near plane get clipped or not.

yup, it was 1, the LoadIdentity. Thank you very much ^_^

In Topic: 'Enemy' was not declared in this scope?

12 April 2011 - 05:07 PM

Capital E

What do you mean?

In Topic: problem blending properly in openGL

11 April 2011 - 06:18 PM

That worked. Thank you ^_^

In Topic: glOrtho - how does it work?

11 April 2011 - 01:42 PM

That worked! Thank you!