Dorun
02-16-2011, 09:11 AM
first of all hi to OpenGL community : )
my problem is a bit strange im creating texture using this code
glGenTextures(1,&m_iID);
glBindTexture(GL_TEXTURE_2D,m_iID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
m_iWidth=1;
m_iHeight=1;
m_iSurfaceWidth=pSurface->w;
m_iSurfaceHeight=pSurface->h;
while (m_iWidth < iWidth) m_iWidth <<= 1;
while (m_iHeight < iHeight) m_iHeight <<= 1;
glTexImage2D( GL_TEXTURE_2D, 0, _nOfColors, m_iWidth, m_iHeight, 0, _texture_format, GL_UNSIGNED_BYTE, NULL );
creating it with dimensions like 64x64 128x64 256x32 gives this result:
http://img594.imageshack.us/img594/8463/colorm.th.jpg (http://img594.imageshack.us/i/colorm.jpg/)
the color is constant and doesnt change.
but using same code but dimensions like 128x128 256x64 etc gives clear texture:
http://img220.imageshack.us/img220/4803/nocolors.th.jpg (http://img220.imageshack.us/i/nocolors.jpg/)
im using SDL as API i know i can just create new Surface and blit it onto texture but i was just wondering whats the cause of it? or is there any alternate method to do it?
my problem is a bit strange im creating texture using this code
glGenTextures(1,&m_iID);
glBindTexture(GL_TEXTURE_2D,m_iID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
m_iWidth=1;
m_iHeight=1;
m_iSurfaceWidth=pSurface->w;
m_iSurfaceHeight=pSurface->h;
while (m_iWidth < iWidth) m_iWidth <<= 1;
while (m_iHeight < iHeight) m_iHeight <<= 1;
glTexImage2D( GL_TEXTURE_2D, 0, _nOfColors, m_iWidth, m_iHeight, 0, _texture_format, GL_UNSIGNED_BYTE, NULL );
creating it with dimensions like 64x64 128x64 256x32 gives this result:
http://img594.imageshack.us/img594/8463/colorm.th.jpg (http://img594.imageshack.us/i/colorm.jpg/)
the color is constant and doesnt change.
but using same code but dimensions like 128x128 256x64 etc gives clear texture:
http://img220.imageshack.us/img220/4803/nocolors.th.jpg (http://img220.imageshack.us/i/nocolors.jpg/)
im using SDL as API i know i can just create new Surface and blit it onto texture but i was just wondering whats the cause of it? or is there any alternate method to do it?