Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:23:28+00:00 2026-06-02T04:23:28+00:00

I have created a 3d cube in JOGL using the following code: /** *

  • 0

I have created a 3d cube in JOGL using the following code:

/**
 * Function used to draw a cube
 */
public void drawCube(GL gl) {


    gl.glBegin(gl.GL_QUADS);

    //gl.glColor3f(1, 0, 0);
        gl.glTexCoord3f(0, 0, 0);
        gl.glVertex3f(0, 0, 0);
        gl.glTexCoord3f(4, 0, 0);
        gl.glVertex3f(1, 0, 0);
        gl.glTexCoord3f(4, 4, 0);
        gl.glVertex3f(1, 1, 0);
        gl.glTexCoord3f(0, 4, 0);
        gl.glVertex3f(0, 1, 0);
    gl.glEnd();



    gl.glBegin(gl.GL_QUADS);
        gl.glTexCoord3f(0, 0, 0);
    // gl.glColor3f(0, 1, 0);
        gl.glVertex3f(0, 0, 0);
        gl.glTexCoord3f(0, 4, 0);
        gl.glVertex3f(0, 1, 0);
        gl.glTexCoord3f(0, 4, 4);
        gl.glVertex3f(0, 1, 1);
        gl.glTexCoord3f(0, 0, 4);
        gl.glVertex3f(0, 0, 1);
    gl.glEnd();



    gl.glBegin(gl.GL_QUADS);
    //  gl.glColor3f(0, 0, 1);
        gl.glTexCoord3f(0, 4, 0);
        gl.glVertex3f(0, 1, 0);
        gl.glTexCoord3f(4, 4, 0);
        gl.glVertex3f(1, 1, 0);
        gl.glTexCoord3f(4, 4, 4);
        gl.glVertex3f(1, 1, 1);
        gl.glTexCoord3f(0, 4, 4);
        gl.glVertex3f(0, 1, 1);
      gl.glEnd();


    gl.glBegin(gl.GL_QUADS);
    //  gl.glColor3f(1, 1, 0);
        gl.glTexCoord3f(4, 4, 0);
        gl.glVertex3f(1, 1, 0);
        gl.glTexCoord3f(4, 0, 0);
        gl.glVertex3f(1, 0, 0);
        gl.glTexCoord3f(4, 0, 4);
        gl.glVertex3f(1, 0, 1);
        gl.glTexCoord3f(4, 4, 4);
        gl.glVertex3f(1, 1, 1);
    gl.glEnd();

     gl.glBegin(gl.GL_QUADS);
    // gl.glColor3f(1, 0, 1);
        gl.glTexCoord3f(4, 0, 0);
        gl.glVertex3f(1, 0, 0);
        gl.glTexCoord3f(0, 0, 0);
        gl.glVertex3f(0, 0, 0);
        gl.glTexCoord3f(0, 0, 4);
        gl.glVertex3f(0, 0, 1);
        gl.glTexCoord3f(4, 0, 4);
        gl.glVertex3f(1, 0, 1);
    gl.glEnd();

     gl.glBegin(gl.GL_QUADS);
    //   gl.glColor3f(0, 1, 1);
        gl.glTexCoord3f(0, 4, 4);
        gl.glVertex3f(0, 1, 1);
        gl.glTexCoord3f(4, 4, 4);
        gl.glVertex3f(1, 1, 1);
        gl.glTexCoord3f(4, 0, 4);
        gl.glVertex3f(1, 0, 1);
        gl.glTexCoord3f(0, 0, 4);
        gl.glVertex3f(0, 0, 1);

     gl.glEnd();

The cube is on the screen, and now I’m trying to place a texture on each faces like this:

public void init(GLAutoDrawable gld) {
    //Init the gl
    GL gl = gld.getGL();

    //Init the glu
    GLU glu = new GLU();

    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluPerspective(90, 1.6, 0.6, 30.0);
    glu.gluLookAt(0, 0, 10, 0, 0, 0, 0, 2, 0);


    gl.glEnable(gl.GL_TEXTURE_2D);


    int id_textura = Gen_Textura(gl);


    gl.glBindTexture(gl.GL_TEXTURE_2D, id_textura);


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

The problem is that the texture shows up only on one face of the cube, not on all 6.

How can I make the texture to be drawn on all the faces of the cube?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:23:30+00:00Added an answer on June 2, 2026 at 4:23 am

    Answer based on my comment above.

    You should use glTexCoord2f, since you’re using 2D textures. Also, texture coordinates are usually in the range [0, 1].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 3D cube created using GL_TRIANGLE_STRIP.Is it possible to draw points(using GL_POINTS)
I have the following scenario. A cube created in SSAS 2008. I can connected
I have created a mac application using the WebView. But issue is that webView
I have created a Layout using ExtJs. It consists of a left menu and
I have created a rotating CUBE with the help of OPENGL in Android now
I have (with assistance) created a function that plots and draws a line of
I have (with assistance) created a function that plots and draws a line of
I need to draw a gridded image using opengl. I've read that images created
I've created a cube in SSAS 2008, and have it deployed to my local
I have created a custom dialog for Visual Studio Setup Project using the steps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.