Jump to content


Texture problem in VS2005 , the skin color become BLUE .


3 replies to this topic

#1 NDark

    New Member

  • Members
  • Pip
  • 8 posts

Posted 26 September 2008 - 08:10 AM

hi ,


I render a mesh using basic texture mapping , the texture coordinate is correct , however the color of some parts are too strange , like red channel is masked .

the result is like this screen shot:
Posted Image

this is original image for texture
Posted Image


I use VS2005 and OpenGL to render.

the following is image reading and texture generation process :


System::Drawing::Bitmap *TexImage ;

System::Drawing::Rectangle Rec ;

System::Drawing::Imaging::BitmapData *bmdata ;


// read image

TexImage = new System::Drawing::Bitmap( gTexfilename.c_str() ) ;// read image

Rec.X = 0 ;

Rec.Y = 0 ;

Rec.Width = TexImage->Width ;

Rec.Height = TexImage->Height ;


bmdata = new System::Drawing::Imaging::BitmapData ;

TexImage->LockBits( Rec , System::Drawing::Imaging::ImageLockMode::ReadOnly ,

	Imaging::PixelFormat::Format24bppRgb , bmdata ) ;



// generation texture

glGenTextures( 1 , &tid ) ;

glBindTexture( GL_TEXTURE_2D , tid ) ;


glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;

glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;

glTexEnvi( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_REPLACE ) ;


glTexImage2D( GL_TEXTURE_2D , 0 , GL_RGB8 , 

		TexImage->Width , TexImage->Height , 

		0 , GL_RGB , GL_UNSIGNED_BYTE , 

		(void*) bmdata->Scan0 ) ;



and render process is following :


glBindTexture( GL_TEXTURE_2D , gTexid ) ; // bind texture itri

glEnable( GL_TEXTURE_2D ) ;

glDisable( GL_LIGHTING ) ;

glDisable( GL_BLEND ) ;

glColorMask( 1.0 , 1.0 , 1.0 , 1.0 ) ;


glBegin( GL_TRIANGLES ) ;

// do vertex and texture draw

glEnd() ;

glDisable( GL_TEXTURE_2D ) ;



Does anyone know where is the key process I go wrong ? Thanks in advance .



NDark

#2 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 513 posts
  • LocationNowhere whenever

Posted 26 September 2008 - 09:42 AM

You need to swap the red and blue colors in the texture.
http://iki.fi/sol - my schtuphh

#3 Kenneth Gorking

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 26 September 2008 - 10:31 AM

Or when uploading it, using GL_BGR_EXT
"Stupid bug! You go squish now!!" - Homer Simpson

#4 NDark

    New Member

  • Members
  • Pip
  • 8 posts

Posted 01 October 2008 - 05:39 AM

Kenneth Gorking said:

Or when uploading it, using GL_BGR_EXT

thank you a lot . It works .
this is correct result.

Posted Image





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users