我用下面的代码测试,请问为什么不行啊?
- void testTexture()
- {
- unsigned short embTex[128*128];
- GLfixed rect[] = { Float2Fixed(-25.0f), Float2Fixed(-25.0),0,
- Float2Fixed(25.0f), Float2Fixed(-25.0), 0,
- Float2Fixed(25.0f), Float2Fixed(25.0), 0,
- Float2Fixed(-25.0f), Float2Fixed(-25.0),0,
- Float2Fixed(25.0f), Float2Fixed(25.0), 0,
- Float2Fixed(-25.0f), Float2Fixed(25.0f) , 0
- };
- GLfixed rnormal[] = {
- 0, Float2Fixed(1.0f), 0,
- 0, Float2Fixed(1.0f), 0,
- 0, Float2Fixed(1.0f), 0,
- 0, Float2Fixed(1.0f), 0,
- 0, Float2Fixed(1.0f), 0,
- 0, Float2Fixed(1.0f), 0
- };
- GLfixed rectuv[] = {
- Float2Fixed(0.0f), Float2Fixed(0.0),
- Float2Fixed(1.0f), Float2Fixed(0.0),
- Float2Fixed(1.0f), Float2Fixed(1.0),
- Float2Fixed(0.0f), Float2Fixed(0.0),
- Float2Fixed(1.0f), Float2Fixed(1.0),
- Float2Fixed(0.0f), Float2Fixed(1.0f)
- };
- unsigned short color[4]={ 0xF800, 0x7E0, 0x1F, 0xffff };
- for ( int i = 0; i < 128; ++i )
- {
- for ( int j = 0; j < 128; ++j )
- {
- embTex[i*128+j] = color[(i/32 + j/32)%4];
- }
- }
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128 , 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, embTex);
- glEnableClientState( GL_VERTEX_ARRAY );
- glEnableClientState( GL_NORMAL_ARRAY );
- glEnableClientState( GL_TEXTURE_COORD_ARRAY );
- glVertexPointer( 3, GL_FIXED, 0, rect );
- glNormalPointer( GL_FIXED, 0, rnormal);
- glTexCoordPointer( 2, GL_FIXED, 0, rectuv );
- glDrawArrays( GL_TRIANGLES, 0, 6);
- }
复制代码
在桌面下我也可以!谢谢!
|