simple texturing problems

Hi everyone,

I am advanced in programming DirectX, so I know the basics of 3D programming.

I just began (today) programming OpenGL and started to rebuild the classic windows GUI.
But now I have some serious problems with texturing.
Look at this screenshot. ( I know, it doesn’t look the windows titlebar. This is just for testing purposes, which makes the problem more clear)

You see the titlebar. It should be a gradient from darkblue to lightblue (systemcolors).

The texture looks like this (32x32).

But where does the grey shade on the right and left of the gradient come from? What am I doing wrong? I have clamp-mode on. Here is the relevant code.

	// Setup a pixel format descriptor
	PIXELFORMATDESCRIPTOR pfDesc =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
		PFD_TYPE_RGBA,
		32,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		32,
		0, 0,
		PFD_MAIN_PLANE,
		0, 0, 0, 0
	};
//...
	// matrix stuff
	glViewport(0, 0, 640, 480);
	glMatrixMode(GL_PROJECTION); 
	glLoadIdentity(); 
	glOrtho(0, 640, 0, 480, -1, 1);
	glMatrixMode(GL_MODELVIEW); 
	glLoadIdentity(); 
//..
//loading texture

	AUX_RGBImageRec *pTextureImage = auxDIBImageLoad( L".\\pattern7.bmp" );

//...
	glGenTextures( 1, &g_textureID );

	glBindTexture( GL_TEXTURE_2D, g_textureID );

	glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR );
	glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP );
	glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP );
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);


	glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, pTextureImage->sizeX, pTextureImage->sizeY, 0,
		GL_RGB, GL_UNSIGNED_BYTE, pTextureImage->data );

//...
//DrawLoop
//...
// type of m_bgColor is COLORREF
	glClearColor(GetRValue(m_bgColor) / 255.f, GetGValue(m_bgColor) / 255.f, GetBValue(m_bgColor) / 255.f, 0.0f); 
	glClear(GL_COLOR_BUFFER_BIT);
	
	glEnable( GL_TEXTURE_2D );
	glBegin(GL_TRIANGLE_STRIP);
	glTexCoord2f(0.0, 1.0);
	glVertex2f(24,480-4);
	glTexCoord2f(0.0, 0.0);
	glVertex2f(24,480-4-18);
	glTexCoord2f(1.0, 1.0);
	glVertex2f(640-4-52,480-4);
	glTexCoord2f(1.0, 0.0);
	glVertex2f(640-4-52,480-4-18);
	glEnd();
	glDisable( GL_TEXTURE_2D );
	
	SwapBuffers(m_dc);

Hope you can help me. :slight_smile:
Thanks
Martin

I started using a 2x2 texture (here magnified by 1600% for you to see)

And the relult looks like this.

strange dark shade at the the border…

That’s what GL_CLAMP does.
Try GL_CLAMP_TO_EDGE.

Thanks. That does the trick! :slight_smile: