0
OpenGL 4.x에서 1D 텍스처를 사용하는 데 문제가 있습니다. OpenGL 4.x에서 1D 텍스처 만들기 및 읽기
나는 나의 1D 텍스처 이러한 방법으로 생성 (BTW을 : 나는 코드가 더 명확하고 짧게 내 오류 검사를 제거 - 각각BLUE_ASSERTEx(glGetError() == GL_NO_ERROR, "glGetError failed.");
다음과 전화 GL 보통 후) :
glGenTextures(1, &textureId_);
// bind texture
glBindTexture(GL_TEXTURE_1D, textureId_);
// tells OpenGL how the data that is going to be uploaded is aligned
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
BLUE_ASSERTEx(description.data, "Invalid data provided");
glTexImage1D(
GL_TEXTURE_1D, // Specifies the target texture. Must be GL_TEXTURE_1D or GL_PROXY_TEXTURE_1D.
0, // Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
GL_RGBA32F,
description.width,
0, // border: This value must be 0.
GL_RGBA,
GL_FLOAT,
description.data);
BLUE_ASSERTEx(glGetError() == GL_NO_ERROR, "glGetError failed.");
// texture sampling/filtering operation.
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_1D, 0);
내가 시도를 생성 한 후 이 방법으로 생성 된 텍스처의 픽셀 데이터를 읽습니다 : const int width = width_; const int height = 1;
// Allocate memory for depth buffer screenshot
float* pixels = new float[width*height*sizeof(buw::vector4f)];
// bind texture
glBindTexture(GL_TEXTURE_1D, textureId_);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, pixels);
glBindTexture(GL_TEXTURE_1D, 0);
buw::Image_4f::Ptr img(new buw::Image_4f(width, height, pixels));
buw::storeImageAsFile(filename.toCString(), img.get());
delete pixels;
그러나 리턴 화소 데이터는 상기 입력 픽셀 데이터에 다른 (입력 : 색상 램프, ouptut : 흑색 화상)
어떤 아이디어 방법이 문제를 해결하기 위해? 어쩌면 잘못된 API 호출을 사용하고 있습니다.
'glReadPixels'는 텍스처가 아닌 화면 (또는 바운드 프레임 버퍼)에서 읽습니다. 당신은'glGetTexImage'를 원한다. –