Issues Drawing a Cube

I’ll always give you guys a question to answer.

Generally most of my questions seem to stem from Nehe’s tutorials because, although they are nice, I think they are rather poor examples for converting into game code, simply because he never makes it easy to put them in with other stuff. Anyway.

I used tutorial number 6 to see how to draw a textured cube, then created a glCube method for accessing it. Nothing is drawn.


public static void glCube(String tex, int x, int y, int z, int w, int h, int d)
    {
    		//store the current model matrix
		GL11.glPushMatrix();
		GL11.glTranslatef(0, 0, 0);
    		try
    		{
    			Texture texture = BestGameEver.textureLoader.getTexture(tex);
    			GL11.glEnable(GL11.GL_DEPTH_TEST);  //Enable 3D depth testing
    			GL11.glTranslatef(0.0f, 0.0f, -5.0f); // Move Into The Screen 5 Units
    			texture.bind();
    		} catch (Exception e) {e.printStackTrace();}
    		ImageViewer.glColor(255,255,255,255);
    		GL11.glBegin(GL11.GL_QUADS);
    		// Front Face
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z); // Top Left Of The Texture and Quad
    		// Back Face
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
    		// Top Face
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
    		// Bottom Face
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		// Right face
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Left Of The Texture and Quad
    		// Left Face
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glEnd();
    		
    		GL11.glPopMatrix();
    }

One thing to note what I am trying to do specifically. The entirety of the game is 2D, so depth testing is most of the time disabled. When you start a dialogue or open an item window, however, the window is a 3D one that gently bobbles left and right slightly. Therefore, as you can see, I need to enable depth testing and then pop it back to the old matrix. The BestGameEver.textureLoader references the game’s TextureLoader, which is pretty much exactly Kev’s class from Space Invaders, aside from a few additions.

Nothing is drawn, and the texture is definitely found because the exact same image path is drawn correctly somewhere else.

In Nehe’s original source, he uses 0.0f or 1.0f or -1.0f in the coords, whereas I use actual points. This could be some problem. In any case, it woud be great if someone could point me in the right direction.

PS - Got text to work. :wink:

Your second command moves the modelview matrix by 0,0,0, a NO-OP. However below I see you moving the matrix by -5 z each frame, which will push your matrix right off into the distance over time (unless you are clearing the matrix somewhere else).

Perhaps this command was supposed to be GL11.glLoadIdentity()?

Other than that everything looks fine to me. You might make sure that

  1. you’ve cleared the depth buffer

  2. lighting is off

  3. your projection matrix and or viewport is not fubar

    //store the current model matrix
    GL11.glPushMatrix();
    GL11.glTranslatef(0, 0, 0);
    try
    {

Great that worked. Just needed to kill the “GL11.glTranslatef(0.0f, 0.0f, -5.0f); // Move Into The Screen 5 Units” and it worked, although I added in GL11.glLoadIdentity() for good measure. :stuck_out_tongue:

Thanks very much.

Hmm… or not. I can see something now, but there’s still a couple things that don’t work.

a) For some reason to texture on the front draws from the top left to about 50 pixels away from the bottom right, leaving black space there. Why won’t it fill the entire thing with my texture?

b) I cannot move it past -1 or 1 on the z axis without it going MIA, how do I fix that?

c) Chaning the z doesn’t seem to do anything I can notice.

d) Using GL11.glRotatef(xDir, 1.0f, 0.0f, 0.0f); to rotate the cube does nothing unless I remove GL11.glLoadIdentity(), ending up with what appears to be the texture moving up and down along the cube face, leaving gaps in between.

Hmm… that’s a lot of issues. Any ideas what may be up, or what GL11 things I need to set before drawing this correctly? I’m pretty sure I’ve got them all…

Hmm… Don’t have much time now, but…

b), c) this sounds to me that you are in ortho mode, constrained in z from -1 to 1, so, that could be the problem…

Oh yeah, that’s probably it. How do I jump out of ortho mode?

you need to do this:


GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
GLU.gluPerspective(45.0f, (float)width/(float)height, 0.1f, 1000.0f);

or something similar. You put it in ortho mode by doing


GL11.glOrtho()

instead of


GLU.gluPerspective()

Okay, now after I do that I get this:

After commenting some stuff out I isolated it as the glMatrixMode that breaks it. If I have only gluPerspective then instead of seeing a weird messed up line skewing like I had I see nothing.

Weird! Here is what I use to init everything:


private void initDisplay()
{
    try
    {
        //find displaymode
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (int i = 0; i < modes.length; i++)
        {
            if (modes[i].getWidth() == 640 &&
                    modes[i].getHeight() == 480 &&
                    modes[i].getBitsPerPixel() >= 32 &&
                    modes[i].getFrequency() == 60)
            {
                mode = modes[i];
                break;
            }
        }
        Display.setDisplayMode(mode);
        Display.setTitle("DXF Reader");
        Display.create();
        return;
    }
    catch (LWJGLException e)
    {
        e.printStackTrace();
    }
}

private void initGL()
{
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1.0);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    
    // Go into orthographic projection mode.
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    
    GLU.gluPerspective(45.0f, mode.getWidth()/mode.getHeight(), 0.1f, 1000.0f);
    GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
    
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
}

… and in my constructor I call them in that order! Then I have the main loop of the program.

Hope this helps!

Well obviously something is going hunky-dory between me trying to have everything be 2D except this single cube. I must be forgetting to switch some stuff back to 2D.

After adding in


GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

before glPopMatrix() I don’t get the exception anymore, which after reading through my Java book stems from this line, which makes sense because it says there is a stack problem. Anyway, after doing this, it continues to run, however, the entire screen turns white. I think I’m probably forgetting to set something back to the 2D settings, although I believe am setting ortho mode manually before every drawing… or not. I’ll try re-enabling ortho mode after the cube is drawn…

Well, well. Setting it back to ortho mode, along with changing the matrix mode to modelview, “fixes” everything. No freezes, no crashes, everything is drawn. BUT. There is absolutely no cube drawn at all. ::slight_smile:

Here’s what I have at this stage:


public static void glCube(String tex, int x, int y, int z, int w, int h, int d)
    {
    		//store the current model matrix
		GL11.glPushMatrix();
		//GL11.glTranslatef(0, 0, 0);
		//GL11.glLoadIdentity();
    		try
    		{
    			Texture texture = BestGameEver.textureLoader.getTexture(tex);
    			GL11.glEnable(GL11.GL_DEPTH_TEST);  //Enable 3D depth testing
    			GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
    			GL11.glLoadIdentity();
    			GLU.gluPerspective(45.0f, (float)800/(float)600, 0.1f, 1000.0f);
    			texture.bind();
    		} catch (Exception e) {e.printStackTrace();}
    		ImageViewer.glColor(255,255,255,255);
    		GL11.glBegin(GL11.GL_QUADS);
    		// Front Face
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z); // Top Left Of The Texture and Quad
    		// Back Face
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
    		// Top Face
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
    		// Bottom Face
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		// Right face
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x+w,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Left Of The Texture and Quad
    		// Left Face
    		GL11.glTexCoord2f(0.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 0.0f);
    		GL11.glVertex3f(x,y+h,z); // Bottom Right Of The Texture and Quad
    		GL11.glTexCoord2f(1.0f, 1.0f);
    		GL11.glVertex3f(x,y,z); // Top Right Of The Texture and Quad
    		GL11.glTexCoord2f(0.0f, 1.0f);
    		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
    		GL11.glEnd();
    		
    		GL11.glDisable(GL11.GL_DEPTH_TEST);  //Enable 3D depth testing
		GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
		GL11.glLoadIdentity();
		GL11.glOrtho(0, 800, 600, 0, -1, 1);
    		GL11.glMatrixMode(GL11.GL_MODELVIEW);
    		GL11.glLoadIdentity();
    		GL11.glPopMatrix();
    }

Ok, I am new to all of this too so I may be wrong, but try putting the glPopMatrix() right after the glEnd(). And this stuff:


GL11.glDisable(GL11.GL_DEPTH_TEST);  //Enable 3D depth testing
GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
GL11.glLoadIdentity();
GL11.glOrtho(0, 800, 600, 0, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

… only needs to be done once when you initialize everything. Also is the cube the only thing that you’re drawing? If it is then you shouldn’t need the push pop matrix stuff at all. Is there a place in your code where you do a glTranslate() into the screen? If not then the box is being drawn around the camera and you would be looking at the “other” side of the quads that you’re drawing and therefore see through them.

Here, this works. The placement of the cube in your method is a little off so it doesn’t rotate exacly around the center, but you can tweek that no problem! ;D


import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.glu.GLU;

public class Cube
{
	private DisplayMode mode;
	private boolean done = false;
	private float z = -10f, rotX = 0, rotY = 0;
	
	public static void main(String[] args)
	{
		new Cube();
	}
	public Cube()
	{
		initDisplay();
        initGL();
        run();
	}
	
	private void initDisplay()
    {
        try
        {
            //find displaymode
            DisplayMode[] modes = Display.getAvailableDisplayModes();
            for (int i = 0; i < modes.length; i++)
            {
                if (modes[i].getWidth() == 640 &&
                        modes[i].getHeight() == 480 &&
                        modes[i].getBitsPerPixel() >= 32 &&
                        modes[i].getFrequency() == 60)
                {
                    mode = modes[i];
                    break;
                }
            }
            Display.setDisplayMode(mode);
            Display.setTitle("DXF Reader");
            Display.create();
            return;
        }
        catch (LWJGLException e)
        {
            e.printStackTrace();
        }
    }
    
    private void initGL()
    {
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        GL11.glClearDepth(1.0);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        
        // Go into orthographic projection mode.
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        
        GLU.gluPerspective(45.0f, mode.getWidth()/mode.getHeight(), 0.1f, 1000.0f);
        GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
        
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    }
    
    private void run()
    {
        while(!done)
        {
            mainLoop();
            render();
            Display.update();
            
            Thread.yield();
        }
        cleanup();
    }
    
    private void mainLoop()
    {
    	if(Keyboard.isKeyDown(Keyboard.KEY_UP))
        {
            rotX -= 1.0f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_DOWN))
        {
        	rotX += 1.0f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_LEFT))
        {
        	rotY -= 5.0f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
        {
        	rotY += 5.0f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_ADD))
        {
            z += 0.1f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT))
        {
            z -= 0.1f;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
        {
            done = true;
        }
        if(Display.isCloseRequested())
        {
            done = true;
        }
    }
    
    private void render()
    {
        // clear background
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glLoadIdentity();
        GL11.glTranslatef(0.0f, 0.0f, z);
        GL11.glRotatef(rotX, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(rotY, 0.0f, 1.0f, 0.0f);

        glCube("", -1, -1, -1, 2, 2, 2);
    }
    
	public static void glCube(String tex, int x, int y, int z, int w, int h, int d)
    {
		GL11.glBegin(GL11.GL_QUADS);
		// Front Face
		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
		GL11.glVertex3f(x,y,z); // Top Left Of The Texture and Quad
		// Back Face
		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Right Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
		// Top Face
		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
		GL11.glVertex3f(x,y,z); // Bottom Left Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z); // Bottom Right Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z-d); // Top Right Of The Texture and Quad
		// Bottom Face
		GL11.glVertex3f(x+w,y+h,z-d); // Top Right Of The Texture and Quad
		GL11.glVertex3f(x,y+h,z-d); // Top Left Of The Texture and Quad
		GL11.glVertex3f(x,y+h,z); // Bottom Left Of The Texture and Quad
		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
		// Right face
		GL11.glVertex3f(x+w,y+h,z); // Bottom Right Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z); // Top Right Of The Texture and Quad
		GL11.glVertex3f(x+w,y,z-d); // Top Left Of The Texture and Quad
		GL11.glVertex3f(x+w,y+h,z-d); // Bottom Left Of The Texture and Quad
		// Left Face
		GL11.glVertex3f(x,y+h,z-d); // Bottom Left Of The Texture and Quad
		GL11.glVertex3f(x,y+h,z); // Bottom Right Of The Texture and Quad
		GL11.glVertex3f(x,y,z); // Top Right Of The Texture and Quad
		GL11.glVertex3f(x,y,z-d); // Top Left Of The Texture and Quad
		GL11.glEnd();
    }
	
	private void cleanup()
    {
        System.exit(0);
    }
}

Yeah, I run that on its own and it works, thanks for the code.

My big problem, however, is that I am not only drawing a cube. What I have right now is an entire 2D game drawn out. I simply trying to change the dialogue window that pops when you talk to a character from a 2D rectangle to a 3D cube that gently rotates back and forth. I am having some issues actively converting it between these drawing methods.

The 2D stuff is drawn in ortho mode with depth testing off, no z axis, etc. The cube obviously needs some perspective to be drawn correctly.

I’ll try to use your code to change my initializers in here somewhere.

It should also be known that I am not plugging in dumb values like -1, 1, etc. into the coords for drawing my cube, which could very well be the problem. I am trying to put in flat out x, y coordinates. Say the window is like this:


+---------------------+
|    *-----------*    |
|    | dialogue  |    |
|    *-----------*    |
|                     |
+---------------------+

The coordinates of the actual display are 0,0 as the top left corner and 800,600 as the bottom right. The window itself is drawn at about 100,10 as top left to 500,210 as the bottom right. These are the coordinates I am plugging into the cube method, whereas yours are very small values, and if I put in small values I can actually see something drawn even within my game. I like glOrtho because it turns it all to this display-like format, which is useful for drawing sprites and the like. How can I have cube drawing work the same way?

I felt like I should edit this and post that I do in fact have a spinning cube in there now, the only problem is trying to translate it into that sort of coordinate use. It may not be possible, it occurs to me, but that’s fine. I’ll figure it out.

Also, for some off reason whenever I map textures in this way they only fill up a part of the quad, leaving black space on the edges for no reason. Any ideas why? I can “stretch” textures to fit, but then I need to tailor it for every texture that crosses my path, something I don’t want to do.

Any idea how I can draw text onto the cube so that it rotates with the cube? Should I just draw text along with it?

elias4444 has some code in his ScreenManager class that calculates the proper z-value to make each unit a pixel on the screen. I have not looked too far into it, but you may appeal to him for help on that front. I am a little at a loss for what you are trying to do in the big picture though. You have a cube with text on it that oscillates back and forth? Is the player seeing the edge of the cube or the side? (i.e. could it be a single quad?) elias4444 also has a very handy text class that you may be able to get some good stuff from!

I’ll check him out, thanks for the help.

I do need a cube because of the perspective angle. You can see the sides of it, even though the front face is the really important part. On the left side of the cube a texture for the current talker’s portrait is drawn, then on the right side the text will (theoretically) be drawn. I already have text working on a 2D level, I’m just going to extend points into 3D, that should work.

All in all, thanks for everyone’s help, now I finally can figure (most of) this stuff out by myself. :slight_smile: