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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:32:23+00:00 2026-06-16T18:32:23+00:00

I want to make a room in OpenGl with Visual Studio 2010 and add

  • 0

I want to make a room in OpenGl with Visual Studio 2010 and add some objects like a chair, carpet etc. I designed the walls only by using textures. I have some problems when I try to import objects from 3DS Max. I see the object, but it’s all white. I should be able to see its colour.What did I do wrong? Thanks.
enter image description here
<-My object on 3ds MAx
enter image description here
<-OpenGL

#include "stdafx.h"
#include "tga.h"
#include "glut.h"
#include <gl/gl.h>
#include "glm.h"

int screen_width=1040;
int screen_height=580;


GLuint skyboxTexture[6];//skybox 
GLfloat fSkyboxSizeX, fSkyboxSizeY, fSkyboxSizeZ; //box size on X, Y and Z axes
GLMmodel *3dsobj;

GLfloat fGlobalAngleX, fGlobalAngleY, fGlobalAngleZ; //global rotation angles

void initOpenGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glViewport(0, 0, screen_width, screen_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)screen_width/(GLfloat)screen_height, 1.0f, 1000.0f);
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glMatrixMode(GL_MODELVIEW); 

glGenTextures(6,skyboxTexture);

loadTGA("Textures\\greywall.tga",skyboxTexture[0]); 
loadTGA("Textures\\carpet2.tga",skyboxTexture[1]);  
loadTGA("Textures\\wallpaper.tga",skyboxTexture[2]);    
loadTGA("Textures\\wallpaper.tga",skyboxTexture[3]);    
loadTGA("Textures\\green.tga",skyboxTexture[4]);    
loadTGA("Textures\\wallpaper.tga",skyboxTexture[5]);    
//set skybox size
fSkyboxSizeX =60.0;
fSkyboxSizeY =9.0;
fSkyboxSizeZ =60.0;


 }



////////////////////////////////////////
// function used to create the skybox //
////////////////////////////////////////

void DrawSkybox (GLfloat sizeX, GLfloat sizeY, GLfloat sizeZ)
{
glEnable(GL_TEXTURE_2D); //enable 2D texturing


//////////////////////////////////////////////////////////////////
// please consult the orientation convention for this skybox    //
// ("orientation_convention.png" file in the "Textures" folder) //
//////////////////////////////////////////////////////////////////


//negative x plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[0]); //select the current texture
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(-sizeX, sizeY, -sizeZ); //assign each corner     of the texture to a 3D vertex in the OpenGL scene
    glTexCoord2f(0, 6);glVertex3f(-sizeX, sizeY, sizeZ); //(0,0) is the left lower corner, while (1,1) is the right upper corner of the texture
    glTexCoord2f(0, 0);glVertex3f(-sizeX, -sizeY, sizeZ);
    glTexCoord2f(6, 0);glVertex3f(-sizeX, -sizeY, -sizeZ);
glEnd();

//negative y plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[1]);
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(sizeX, -sizeY, -sizeZ);
    glTexCoord2f(0, 6);glVertex3f(-sizeX, -sizeY, -sizeZ);
    glTexCoord2f(0, 0);glVertex3f(-sizeX, -sizeY, sizeZ);
    glTexCoord2f(6, 0);glVertex3f(sizeX, -sizeY, sizeZ);
glEnd();

//negative z plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[2]);
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(-sizeX, sizeY, sizeZ);
    glTexCoord2f(0, 6);glVertex3f(sizeX, sizeY, sizeZ);
    glTexCoord2f(0, 0);glVertex3f(sizeX, -sizeY, sizeZ);
    glTexCoord2f(6, 0);glVertex3f(-sizeX, -sizeY, sizeZ);
glEnd();

//positive x plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[3]);
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(sizeX, sizeY, sizeZ);
    glTexCoord2f(0, 6);glVertex3f(sizeX, sizeY, -sizeZ);
    glTexCoord2f(0, 0);glVertex3f(sizeX, -sizeY, -sizeZ);
    glTexCoord2f(6, 0);glVertex3f(sizeX, -sizeY, sizeZ);
glEnd();

//positive y plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[4]);
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(sizeX, sizeY, sizeZ);
    glTexCoord2f(0, 6);glVertex3f(-sizeX, sizeY, sizeZ);
    glTexCoord2f(0, 0);glVertex3f(-sizeX, sizeY, -sizeZ);
    glTexCoord2f(6, 0);glVertex3f(sizeX, sizeY, -sizeZ);
glEnd();

//positive z plane
glBindTexture(GL_TEXTURE_2D, skyboxTexture[5]);
glBegin(GL_QUADS);
    glTexCoord2f(6, 6);glVertex3f(sizeX, sizeY, -sizeZ);
    glTexCoord2f(0, 6);glVertex3f(-sizeX, sizeY, -sizeZ);
    glTexCoord2f(0, 0);glVertex3f(-sizeX, -sizeY, -sizeZ);
    glTexCoord2f(6, 0);glVertex3f(sizeX, -sizeY, -sizeZ);
glEnd();

glDisable(GL_TEXTURE_2D); //disable 2D texuring
}

//////////////////////////////////////////////
///DrawModel                              ///
//////////////////////////////////////////////
void drawModel(GLMmodel *pmodel,char*filename,GLuint mode)
{ 
if(!pmodel)
{ 
    pmodel=glmReadOBJ(filename);
    //printf("read the model\n");
    if(!pmodel)
    { 
        exit(0); 
    }  
} 

//generate facet normal vectors for model 
glmFacetNormals(pmodel); 
//generate vertex normal vectors (called after generating facet normals) 
glmVertexNormals(pmodel,90.0);

glmDraw(pmodel,mode); 

}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//place the camera 1.2 units above the negative Y plane of the skybox
gluLookAt(0.0, -fSkyboxSizeY + 1.2 , 3.0, 0.0, -fSkyboxSizeY + 1.2, -10.0, 0.0, 1.0, 0.0);

//set global rotation on the X,Y and Z axes
glRotatef(fGlobalAngleX, 1.0, 0.0, 0.0);
glRotatef(fGlobalAngleY, 0.0, 1.0, 0.0);
glRotatef(fGlobalAngleZ, 0.0, 0.0, 1.0);

//draw skybox
glPushMatrix();     
    DrawSkybox(fSkyboxSizeX, fSkyboxSizeY, fSkyboxSizeZ);
glPopMatrix();

     glTranslatef(0.0, -fSkyboxSizeY + fTreeSize, 0.0);

//draw the tree slice
/*glPushMatrix();
    DrawSingleTreeTexture(fTreeSize);
glPopMatrix();*/


glPushMatrix(); 
  // glTranslatef(-30,0 ,0);
   glRotatef(30, 0, 1, 0);
 // glTranslatef(3, -20,-200);
   //place the tree on the negative Y plane of the skybox
    glTranslatef(19, -fSkyboxSizeY + fTreeSize+10, -6);
   glScalef(0.1,0.1,0.1);
   drawModel(3dsobj,"myObj.obj",GLM_NONE|GLM_FLAT); 
glPopMatrix();

glutSwapBuffers(); //swap the buffers used in the double-buffering technique
}

void changeSize(int w, int h)
{
screen_width=w;
screen_height=h;

if(h == 0)
    h = 1;

float ratio = 1.0*w/h;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45.0f, ratio, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 50.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
}

void processNormalKeys(unsigned char key, int x, int y)
{

switch(key)
{
    case 't':
        //process
        glutPostRedisplay();
        break;
    case 27: //esc
        exit(1);
        break;
    //control the global Y rotation angle using 'a' and 'd'
    case 'a': 
        fGlobalAngleY += 1;
        if (fGlobalAngleY >= 360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleY = (GLint)fGlobalAngleY % 360;
        break;
    case 'd':
        fGlobalAngleY -= 1;
        if (fGlobalAngleY <= -360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleY = (GLint)fGlobalAngleY % 360;         
        break;
    //control the global X rotation angle using 'w' and 's'
    case 'w':
        fGlobalAngleX += 1;
        if (fGlobalAngleX >= 360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleX = (GLint)fGlobalAngleX % 360;         
        break;
    case 's':
        fGlobalAngleX -= 1;
        if (fGlobalAngleX <= -360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleX = (GLint)fGlobalAngleX % 360; 
        break;
    //control the global Z rotation angle using 'q' and 'e'
    case 'q':
        fGlobalAngleZ += 1;
        if (fGlobalAngleZ >= 360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleZ = (GLint)fGlobalAngleZ % 360; 
        break;
    case 'e':
        fGlobalAngleZ -= 1;
        if (fGlobalAngleZ <= -360) //clamp the rotation angle in the [0,360) interval
            fGlobalAngleZ = (GLint)fGlobalAngleZ % 360; 
        break;      
}


}

int main(int argc, char* argv[])
{
//Initialize the GLUT library
glutInit(&argc, argv);
//Set the display mode
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
//Set the initial position and dimensions of the window
glutInitWindowPosition(100, 100);
glutInitWindowSize(screen_width, screen_height);
//creates the window
glutCreateWindow("First OpenGL Application");
//Specifies the function to call when the window needs to be redisplayed
glutDisplayFunc(renderScene);
//Sets the idle callback function
glutIdleFunc(renderScene);
//Sets the reshape callback function
glutReshapeFunc(changeSize);
//Keyboard callback function
glutKeyboardFunc(processNormalKeys);
//Initialize some OpenGL parameters
initOpenGL();
//Starts the GLUT infinite loop
glutMainLoop();
return 0;
}
  • 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-16T18:32:24+00:00Added an answer on June 16, 2026 at 6:32 pm

    You’re calling glmDraw() with GLM_NONE|GLM_FLAT as your mode. You want GLM_SMOOTH and GLM_TEXTURE in there instead.

    In the header for GLM, glmDraw()‘s different mode arguments are listed:

    GLvoid
    glmDraw(GLMmodel* model, GLuint mode);
    /* glmList: Generates and returns a display list for the model using
     * the mode specified.
     *
     * model    - initialized GLMmodel structure
     * mode     - a bitwise OR of values describing what is to be rendered.
     *            GLM_NONE    -  render with only vertices
     *            GLM_FLAT    -  render with facet normals
     *            GLM_SMOOTH  -  render with vertex normals
     *            GLM_TEXTURE -  render with texture coords
     *            GLM_FLAT and GLM_SMOOTH should not both be specified.  
     */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I want make some of my sources publicly available via my blog
I'm making a website for a restaurant, where they want to make room in
i want to make a chat room on gae ,(audio chat) has any framework
I want to make a Firefox like Option Dialog in Java with Swing. I
i am working on asp.net i want to make a chat room which should
I am creating a room reservation system. So i want to make selectable only
I want to make a highchart like this http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-labels/ I have a stored procedure
I want make datetimepicker in my project. Using jquery how it is possible? I
I want make a bash script which returns the position of an element from
I want make interactive application where user launches it and can do various task

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.