시대도 시대이니만큼 CPU의 픽셀연산을 몽땅 버리고, 블렌딩/확대/축소/필터링/멀티텍스쳐링/컬러쉐이딩등 수많은 하드웨어 가속기의 능력을 사용해 보려고 마음을 먹었습니다. 그런데 열받는것이....D3D로 2D출력을 해보니...이넘이 색상이 뭉개지는것 같기도 하고, 한 텍셀씩 밀린다거나 끝쪽에 한라인이 삐져나오는등...벼라별 문제가 다 일어나는겁니다.
모처럼만에 큰맘먹고 3D가속기를 써보려던 마음이 마구 흔들리는 순간입니다.void DrawTexture( long x, long y, long w, long h, loat tu, float tv, float tw, float th ) { ... Vertex[0].position.x = (float)x; Vertex[0].position.y = (float)y; Vertex[1].position.x = Vertex[0].position.x + w; Vertex[1].position.y = Vertex[0].position.y; Vertex[2].position.x = Vertex[0].position.x + w; Vertex[2].position.y = Vertex[0].position.y + h; Vertex[3].position.x = Vertex[0].position.x; Vertex[3].position.y = Vertex[0].position.y + h; Vertex[0].tu = tu; Vertex[0].tv = tv; Vertex[1].tu = Vertex[0].tu + tw; Vertex[1].tv = Vertex[0].tv; Vertex[2].tu = Vertex[0].tu + tw; Vertex[2].tv = Vertex[0].tv + th; Vertex[3].tu = Vertex[0].tu; Vertex[3].tv = Vertex[0].tv + th; ... |
// filter off g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT ); DrawTexture( 1, 1, 8, 8, 0, 0, 1, 1 );// 정상출력. DrawTexture( 10, 1, 8, 8, 1, 0, -1, 1 );// 좌우뒤집기. DrawTexture( 1,10, 8, 8, 0, 1, 1, -1 );// 상하뒤집기. DrawTexture( 10,10, 8, 8, 1, 1, -1, -1 );// 상하좌우뒤집기. // filter on g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); DrawTexture( 20+ 1, 1, 8, 8, 0, 0, 1, 1 );// 정상출력. DrawTexture( 20+10, 1, 8, 8, 1, 0, -1, 1 );// 좌우뒤집기. DrawTexture( 20+ 1,10, 8, 8, 0, 1, 1, -1 );// 상하뒤집기. DrawTexture( 20+10,10, 8, 8, 1, 1, -1, -1 );// 상하좌우뒤집기. |
float textureoffset = 0.5/8; DrawTexture( ..., 0+textureoffset, 0+textureoffset, 1, 1 );// 정상출력. DrawTexture( ..., 1-textureoffset, 0+textureoffset, -1, 1 );// 좌우뒤집기. DrawTexture( ..., 0+textureoffset, 1-textureoffset, 1, -1 );// 상하뒤집기. DrawTexture( ..., 1-textureoffset, 1-textureoffset, -1, -1 );// 상하좌우뒤집기. |
... Vertex[0].position.x = (float)x - 0.5f; Vertex[0].position.y = (float)y - 0.5f; ... |
드디어 텍스쳐 밀림 현상을 해결했네요.