Skip to main content
gamedev.net
🔒 Locked

JOGL map texturing

Started by TeSsL 0 replies 850+ views
Original Post
TeSsL
TeSsL
Hihi~ i am trying to have a larger textured ground which look 3D. Problem 1: this is what i did:
 gl.glBindTexture(GL.GL_TEXTURE_2D, Map);
		gl.glEnable(GL.GL_TEXTURE_2D);
		
		gl.glColor4f(1,1,1,0);
		gl.glBegin(GL.GL_QUADS);
		gl.glTexCoord2f(0.0f, 0.0f);
		gl.glVertex3f(-10f,-10f,-1.0f);
		gl.glTexCoord2f(0.0f, 4.0f);
		gl.glVertex3f(10f,-10f,-1.0f);
		gl.glTexCoord2f(4.0f, 4.0f);
		gl.glVertex3f(10f,10f,-1.0f);
		gl.glTexCoord2f(4.0f, 0.0f);
		gl.glVertex3f(-10f,10f,-1.0f);	    	  	
		
		gl.glEnd();    	
		gl.glDisable(GL.GL_TEXTURE_2D);    
i tried changing the vertex and also texcoord, but the size seems unchanged. Problem 2: my viewport seems abit wierd cause when i tried rotating my floor, some angle make some of the part a bit chipped off.. also when i draw lines, those with different z-value requires me to zoom in or out before i can see them.
  final GL gl = glDrawable.getGL();
		if (height <= 0) // avoid a divide by zero error!
			height = 1;   
		h = (float)width / (float)height;
		gl.glViewport(0, 0, width, height);
		gl.glMatrixMode(GL.GL_PROJECTION);
		gl.glLoadIdentity();
		
		glu.gluPerspective(55.0f, h, 1.0, 20.0);
		gl.glMatrixMode(GL.GL_MODELVIEW);	    	
		gl.glLoadIdentity();  
feel that it might be because of my lookat:glu.gluLookAt(0,15,3,0,0,0,0,0,1); Sorry for my lengthy problem.. Help on any of the qns would be appreciated=D thanks
TeSsL
TeSsL
hmm. i realise it did enlarge, its just that i varies the texcoord too little previously. but now my line i drew earlier became not visible. how am i suppose to make lines bigger? or maybe i can draw tubes but how am i suppose to draw tubes that are slightly transparent so that i can add my model into it?

Also is there any codes to limit movement(zooming,translating,rotating,panning) to my ground. this is what i do now for tranlating, but all this is done via trying out the values so am wondering if there is a proper way of doing this.

public void keyPressed(KeyEvent e) {

if (e.getKeyCode() == KeyEvent.VK_LEFT)
{
rot+=0.5;
}
else if(e.getKeyCode()==KeyEvent.VK_RIGHT)
{
rot-=0.5;
}
else if(e.getKeyCode()==KeyEvent.VK_UP)
{
if(fwd <13)
fwd += 5;
else
fwd=13;
}
else if (e.getKeyCode()==KeyEvent.VK_DOWN) {
if(fwd>-7)
fwd-=5;
else
fwd=-7;
}

}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.