이미지 파일을로드하여 큐브의 질감으로 사용하려고합니다. SDL_image를 사용하고 있습니다. 나는 다양한 파일 형식 (TGA, TIF, JPG, PNG, BMP)SDL_image/C++ OpenGL 프로그램 : IMG_Load()가 흐릿한 이미지를 생성합니다.
에서 그것을 발견했기 때문에
original image http://i33.tinypic.com/2i1f3bp.jpg
나는이 이미지를 사용하는 코드 :
SDL_Surface * texture;
//load an image to an SDL surface (i.e. a buffer)
texture = IMG_Load("/Users/Foo/Code/xcode/test/lena.bmp");
if(texture == NULL){
printf("bad image\n");
exit(1);
}
//create an OpenGL texture object
glGenTextures(1, &textureObjOpenGLlogo);
//select the texture object you need
glBindTexture(GL_TEXTURE_2D, textureObjOpenGLlogo);
//define the parameters of that texture object
//how the texture should wrap in s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//how the texture should wrap in t direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//how the texture lookup should be interpolated when the face is smaller than the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//how the texture lookup should be interpolated when the face is bigger than the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//send the texture image to the graphic card
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, texture-> pixels);
//clean the SDL surface
SDL_FreeSurface(texture);
코드 오류나 경고없이 컴파일!
나는 모든 파일 형식 피곤했습니다 그러나 이것은 항상 추한 결과를 생성합니다
result http://i34.tinypic.com/ipbpxe.jpg
내가 사용하고 있습니다 : 10.6.2에서 엑스 코드 3.2 SDL_image 1.2.9 & SDL 1.2.14을
이 문제를 해결하는 방법을 아는 사람이 있습니까?
메모 : 너무 많은 형식의 이미지를 찾는 이유는 그것이 이미지 압축 테스트의 표준 이미지이기 때문입니다. "Lenna"는 이미지의 이름이고 모델의 이름은 Lena Soderberg입니다. 이미지의 역사는 꽤 흥미 롭습니다. – greyfade