2012-06-08 8 views
1

Devil 1.7.8로 이미지를 읽는 데 문제가 있습니다. 은 지금까지 나는 다음 코드가 작동합니다 알고Devil으로 이미지 읽기

ilInit(); 
ILuint ImageName; 
ilGenImages(1, &ImageName); 
ilBindImage(ImageName); 
wchar_t* imgFilename = L"..\\..\\resources\\textures\\red.png"; 
ilLoadImage(imgFilename); 
ILubyte* texture = ilGetData(); 

내가 처음 픽셀

for (int i=0; i<64; i++) cout << (int)texture[i] << endl; 

을 검사 할 때 나는 꽤 임의의 출력을 얻을. 그림은 실제로 완전히 빨간색입니다.

은뿐만 아니라 내가

ilutRenderer(ILUT_OPENGL); 
GLuint t = ilutGLLoadImage(L"..\\..\\resources\\textures\\red.png"); 

ilut 사용하여 시도하지만 헤더 파일 il.h이 연결되어 내 \ (폴더에 IL 있어야하는 때문에 실제로 난 해당 헤더 파일을 포함 할 수 없습니다) 존재하지 않습니다. 이 폴더를 만들고 필요한 헤더 파일을 복사해도 컴파일 오류가 발생합니다.

누구든지 Devil을 도와 줄 수 있습니까?

답변

0

나는이 같은 텍스처 이미지를 읽고 바인딩 오전 : 정점에 텍스처의 UV의 coordites을

glBindTexture(GL_TEXTURE_2D, ind); 

을 다음 할당 : 렌더링 할 때

ilEnable(IL_ORIGIN_SET); 
ilOriginFunc(IL_ORIGIN_LOWER_LEFT); // set [0,0] of texture to bottom left corner 

ilImage image; 
GLuint ind; 
glGenTextures(1, &ind); 
glBindTexture(GL_TEXTURE_2D, ind); 
image.Load(L"<path>");// or just name.format be sure to have image in correct folder. 

가 먼저 올바른 텍스처를 결합해야합니다

glTexCoord2f(x1, y1);    
glVertex3f(x, y, z); 

GL_TEXTURE_2D 또는 사용중인 모든 유형을 사용하도록 설정해야합니다.