[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

4.2

texture map

Asked by jhshukla in OpenGL Graphics & Game Programming

Tags: texture

For some reason the texture is not being applied to the polygon. it draws the polygon with the last color set. what is wrong with the code? as it is obivous from the looking at the code, it is using MFC/C++. no glut* solutions please. and ignore potential memory leaks, etc. i take care of it in a different routine.

void COpenGL3View::LoadTexture(const char * path)
{
      struct bmp_header
      {
            char sig[2];
            unsigned int fileSize, res1, dataOffset;
            unsigned int bmpHeaderSize, width, height;
            unsigned short planes, bpp;
            unsigned int compression, dataSize;
            unsigned int hres, vres;
            unsigned int numColors, impColors;
      } header;
      ifstream infile (path);
      infile.read(&header.sig[0], 2);
      infile.read((char*)&header.fileSize, 4*6);
      infile.read((char*)&header.planes, 2*2);
      infile.read((char*)&header.compression, 4*5);
      char str[512] = "";
      sprintf(str, "filesize = %d\ndata = %d\nheadersize = %d\nwidth = %d, height = %d\n"
                         "planes = %d, bpp = %d\ncompression = %d\ndatasize = %d\n"
                         "hres = %d, vres = %d\nnumcolors = %d, impcolors = %x",
                         header.fileSize, header.dataOffset, header.bmpHeaderSize, header.width, header.height,
                         header.planes, header.bpp, header.compression, header.dataSize,
                         header.hres, header.vres, header.numColors, header.impColors);
      //MessageBox(str);
      texture = malloc(header.dataSize);
      if ( texture != NULL )
      {
            infile.seekg(header.dataOffset);
            infile.read((char*)texture, header.dataSize);
            sprintf(str, "file read success\nfirst pixel is (%02x,%02x,%02x)",
                  ((unsigned char*)texture)[0],
                  ((unsigned char*)texture)[1],
                  ((unsigned char*)texture)[2]);
            //MessageBox(str);
      }
      ::glBindTexture(GL_TEXTURE_2D, 1);
      ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);      // not really relevant
      ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);      // -"-
      ::glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);      // -"-
      ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, header.width, header.height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);

      ::glEnable(GL_TEXTURE_2D);
}

BOOL COpenGL3View::RenderScene()
{
      ::glBindTexture(GL_TEXTURE_2D, 1);
      ::glEnable(GL_TEXTURE_2D);
      glBegin(GL_POLYGON);
      {
            ::glTexCoord2i(  0,  0); ::glVertex3f(0,  0,  0);
            ::glTexCoord2i(171,  0); ::glVertex3f(0,  0,100);
            ::glTexCoord2i(171,171); ::glVertex3f(0,100,100);
            ::glTexCoord2i(  0,171); ::glVertex3f(0,100,  0);
      }
      glEnd();
      ::glDisable(GL_TEXTURE_2D);

      /* the code below is fine */
      /*
      glEnable(GL_LIGHTING);
      auxSolidSphere( 0.7*50 );
      glDisable(GL_LIGHTING);
      */

      glBegin(GL_LINES); // x y z axes
      {
            ::glColor3f(1,0,0); ::glVertex3f( 0, 0, 0); ::glVertex3f( 200, 0, 0);
            ::glColor3f(0,1,0); ::glVertex3f( 0, 0, 0); ::glVertex3f( 0, 200, 0);
            ::glColor3f(0,0,1); ::glVertex3f( 0, 0, 0); ::glVertex3f( 0, 0, 200);
      }
      glEnd();
      return true;
}
[+][-]07/22/05 11:23 PM, ID: 14508699Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/23/05 03:47 AM, ID: 14509269Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/23/05 03:56 AM, ID: 14509285Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/23/05 04:04 AM, ID: 14509298Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/23/05 10:34 AM, ID: 14510803Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 07:50 AM, ID: 14518208Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 09:19 AM, ID: 14519100Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 09:30 AM, ID: 14519248Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 09:43 AM, ID: 14519384Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 11:50 AM, ID: 14520688Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 12:03 PM, ID: 14520817Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 12:24 PM, ID: 14521036Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 12:28 PM, ID: 14521072Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 01:20 PM, ID: 14521500Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 01:24 PM, ID: 14521534Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 01:26 PM, ID: 14521546Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 01:31 PM, ID: 14521581Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 02:10 PM, ID: 14521924Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 02:12 PM, ID: 14521938Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 02:25 PM, ID: 14522026Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/05 03:16 PM, ID: 14522417Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/25/05 04:25 PM, ID: 14522713Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/26/05 07:29 AM, ID: 14527456Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/26/05 07:30 AM, ID: 14527466Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/26/05 07:31 AM, ID: 14527479Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/26/05 07:33 AM, ID: 14527490Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/26/05 07:34 AM, ID: 14527507Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/26/05 07:35 AM, ID: 14527517Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/27/05 03:40 PM, ID: 14541703Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/27/05 07:58 PM, ID: 14542822Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: OpenGL Graphics & Game Programming
Tags: texture
Sign Up Now!
Solution Provided By: _corey_
Participating Experts: 2
Solution Grade: A
 
[+][-]07/28/05 10:04 AM, ID: 14547697Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/28/05 10:08 AM, ID: 14547744Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/28/05 10:26 AM, ID: 14547940Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/31/05 10:10 AM, ID: 14795689Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08/31/05 10:11 AM, ID: 14795705Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89