Jump to content
  • Advertisement
Sign in to follow this  
fazekaim

I can't use otho mode. Please help!

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I would like to draw a backgroud image, then draw a quad plan. My code doesn't work. Can You help? Here is the code::
private static void orthoMode(float left, float top, float right, float bottom, float up, float down) {
        gl.glMatrixMode( GL.GL_PROJECTION);

        gl.glPushMatrix();

        gl.glLoadIdentity();

        gl.glOrtho( left, right, bottom, top, up, down );

        gl.glMatrixMode( GL.GL_MODELVIEW);

        gl.glLoadIdentity();
    }
    private static void perspectiveMode(){
        gl.glMatrixMode( GL.GL_PROJECTION );

        gl.glPopMatrix();

        gl.glMatrixMode( GL.GL_MODELVIEW );
    }

    private static void drawSpace(){
        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glBindTexture(GL.GL_TEXTURE_2D, space );
        gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

        gl.glBegin(GL.GL_QUADS);
            gl.glTexCoord2f( coords[0], coords[2] );
            gl.glVertex2f( -1.0f, -1.0f );

            gl.glTexCoord2f( coords[0], coords[3] );
            gl.glVertex2f( -1.0f, 1.0f );

            gl.glTexCoord2f( coords[1], coords[3] );
            gl.glVertex2f( 1.0f, 1.0f );

            gl.glTexCoord2f( coords[1], coords[2]);
            gl.glVertex2f( 1.0f, -1.0f );
        gl.glEnd();

        gl.glDisable(GL.GL_TEXTURE_2D);
    }

    private static void drawPlate(){
        gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
        gl.glBegin(GL.GL_QUADS);
            gl.glColor3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( -5.0f, 0, -5.0f );

            gl.glColor3f( 0.0f, 1.0f, 0.0f );
            gl.glVertex3f( -5.0f, 0, 5.0f );

            gl.glColor3f( 0.0f, 0.0f, 1.0f );
            gl.glVertex3f( 5.0f, 0, 5.0f );

            gl.glColor3f( 1.0f, 1.0f, 1.0f );
            gl.glVertex3f( 5.0f, 0, -5.0f );
        gl.glEnd();
    }

    public static void draw() {
        orthoMode( -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f );

        drawSpace();

        perspectiveMode();

        drawPlate();
    }

Thanks

Share this post


Link to post
Share on other sites
Advertisement
Possibly a poly winding problem..?
Try inverting the z values in drawPlate.

And are you moving the camera away from the 'scene' so it's viewable?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!