PDA

View Full Version : About text and texture -- URGENT !!!



sonnik
04-17-2009, 09:45 PM
I am able to print text on the cube using texture and successfully rotate the cube so that text rotates with it.

But my problem is this works only in init(). wht modifications shld i be doing to include this in the display functions so that i can make it dynamic.

plz reply as i need this urgently....

public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
glut = new GLUT();

gl.glClearColor(0.8f, 0.7f, 0.5f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glShadeModel(GL.GL_SMOOTH);
gl.glEnable(GL.GL_TEXTURE_2D);


gl.glEnable(GL.GL_PIXEL_UNPACK_BUFFER);
gl.glEnable(GL.GL_PIXEL_PACK_BUFFER);


gl.glBindTexture(GL.GL_TEXTURE_2D, texture);

gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0 , GL.GL_RGB, -1, 0, 128, 128, 0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);



gl.glClearColor(0.8f, 0.7f, 0.5f, 0.0f);
glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_10, "FINALLY!!!!!");
gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, -20, -100, 128,115);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);


gl.glClearColor(0.8f, 0.7f, 0.5f, 0.0f);
glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_10, "THIS TEXT");
gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 40, -60, 128,70);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

gl.glClearColor(0.8f, 0.7f, 0.5f, 0.0f);
glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_10, "IS WRITING");
gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 80, -20, 128,30);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);


}

remdul
04-18-2009, 07:31 AM
http://www.catb.org/~esr/faqs/smart-questions.html