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 6751755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:57:53+00:00 2026-05-26T12:57:53+00:00

The following code draws a labyrinth or maze in OpenGL, the result is a

  • 0

The following code draws a labyrinth or maze in OpenGL, the result is a 2D labyrinth, what I need to do now is to draw cubes instead these quads, how can I do it?

function drawmaze() {
    int x,y,dl;
    glNewList(dl=glGenLists(1),GL_COMPILE);
    glPushAttrib(GL_TEXTURE_BIT | GL_LIGHTING_BIT);
    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    glColor3f(1.0f,1.0f,1.0f);

    glBegin(GL_QUADS);
//  glPushMatrix();
    float i = 0;
    for(y=0;y < mazedata.size();y++) {
        for(x=0;x < mazedata[y].size();x++) {
            bool dibujar = false;
            if(wall(x,y)) {             
                glColor3ub(46,151,208);
                drawable = true;                
            }                       
            else
            if (entry(x,y)) {
                glColor3f(0.0f,0.184f,0.792f);
                drawable = true;
            }
            else
            if (mazexit(x,y)) {
                glColor3f(0.811f,0.188f,0.176f);
                drawable = true;
            }
            else 
            if (thing(x,y)) {
                glColor3ub( 151, 204, 0 );
                drawable = true;
            }
            else 
            if (visited(x,y)) {
                glColor3ub( 66, 66, 66 );
                drawable = true;
            }

            if (drawable) {
                //glPushMatrix();
                /*
                                This is a try
                                glTranslatef(1.0,0., 0.0f );

                    glutSolidCube(0.5);*/
                //glPopMatrix();
                glVertex3f(x+0.0f ,y+0.0f ,0.0f );
                glVertex3f(x+0.0f ,y+1.0f ,0.0f );
                glVertex3f(x+1.0f ,y+1.0f ,0.0f );
                glVertex3f(x+1.0f ,y+0.0f ,0.0f );
                // topside:
                glVertex3f(x+0.0f ,y+0.0f ,1.0f );
                glVertex3f(x+1.0f ,y+0.0f ,1.0f );
                glVertex3f(x+1.0f ,y+1.0f ,1.0f );
                glVertex3f(x+0.0f ,y+1.0f ,1.0f );
            }

        }
        i++;
    }
    glEnd();
//  glPopMatrix();
    glPopAttrib();
    glEndList();
    return(dl);
}
  • 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-05-26T12:57:53+00:00Added an answer on May 26, 2026 at 12:57 pm
    glBegin(GL_QUADS);
        // front
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(1.0f, 0.0f, 0.0f);
        glVertex3f(1.0f, 1.0f, 0.0f);
        glVertex3f(0.0f, 1.0f, 0.0f);
        // back
        glVertex3f(0.0f, 0.0f, -1.0f);
        glVertex3f(1.0f, 0.0f, -1.0f);
        glVertex3f(1.0f, 1.0f, -1.0f);
        glVertex3f(0.0f, 1.0f, -1.0f);
        // right
        glVertex3f(1.0f, 0.0f, 0.0f);
        glVertex3f(1.0f, 0.0f, -1.0f);
        glVertex3f(1.0f, 1.0f, -1.0f);
        glVertex3f(1.0f, 1.0f, 0.0f);
        // left
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(0.0f, 0.0f, -1.0f);
        glVertex3f(0.0f, 1.0f, -1.0f);
        glVertex3f(0.0f, 1.0f, 0.0f);
        // top
        glVertex3f(0.0f, 1.0f, 0.0f);
        glVertex3f(1.0f, 1.0f, 0.0f);
        glVertex3f(1.0f, 1.0f, -1.0f);
        glVertex3f(0.0f, 1.0f, -1.0f);
        // bottom
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(1.0f, 0.0f, 0.0f);
        glVertex3f(1.0f, 0.0f, -1.0f);
        glVertex3f(0.0f, 0.0f, -1.0f);
    glEnd();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following code to draw a filled circle in opengl. The
I have the following code which takes a touch on one button and draws
I have the following code to draw text centered vertically (and horizontally) in a
I have the following code for writing draw calls to a back buffer canvas,
I have the following code in my Rails application's routes file: MyApp::Application.routes.draw do constraints
I am trying to draw on a html5 canvas and the following code should
My machine apparently won't draw vertex lists in pyglet. The following code renders two
Following code produces a nested array as a result for keys containing three items:
i have the following code which draws nothing. If i use glBegin(GL_POINTS) it draws
I am using the following code and it draws a triangle on the screen.

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.