OpenGL에서 현재 texture를 눈으로 확인하며 디버깅하고 싶을 때 texture를 bmp파일로 저장하여 디버깅 할때 아래와 같이 한다. 이때 중요한 함수가 glGetTexLevelParameteriv인데 이것은 현재 texture 현재 mipmap level예제에서는 level가 1개 이므로 0이다.)의 parameter를 얻는 함수이다. 저장할 때는 32비트 bmp로 저장한다. glGetTexImage는 현재 texture의 pixel을 얻어온다. 이때 32비트 bmp는 GL_BGRA이므로 format을 GL_RGBA로 하면 색깔이 뒤집힌다. #define GL_BGRA 0x80E1 // Use this for 32bit bmp GLint cx, cy, format, bpp; // 저장할 tex..
OpenGL에서 bmp파일을 로딩하여 texture를 생성하는 코드이다. bmp는 24/32비트만을 지원한다. 15,16비트와 256칼라는 지원하지 않는다. glTexImage2D로 생성하기 때문에 다음과 같이 필터가 셋팅되어 있어야 한다. #define GL_BGRA 0x80E1 // Use this for 32bit bmp #define GL_BGR_EXT 0x80E0 void LoadBmp() { glBindTexture(GL_TEXTURE_2D, tex); FILE *fp = fopen("c:\\cap2.bmp", "rb"); if (!fp) return; BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; fread(&bfh, 1, sizeof(BITMAPFILEHEA..
public class BmpLoader { public struct BMPHeader { public short type; public int size; public short reserved1; public short reserved2; public int offset; } public struct BMPInfoHeader { public int size; public int width; public int height; public short planes; public short bitsPerPixel; public uint compression; public uint imageSize; public int xPelsPerMeter; public int yPelsPerMeter; public int..
- Total
- Today
- Yesterday