ChinaShrimp
05-25-2004, 05:00 PM
Hi, now I want to generate a float texture and the code likes the following:
glGenTextures(1, &_iTexture);
glBindTexture(GL_TEXTURE_2D, _iTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
//read data from a file through the function
//: read_img
float* pData = read_img(cPath, _iWidth, _iHeight);
//especiall this one
glTexImage2D(GL_TEXTURE_2D, 0, 1, _iWidth, _iHeight, 0, GL_RED, GL_FLOAT, pData); But I cann't get a correct result. Someone pointed out that there is something wrong with this statement "glTexImage2D(GL_TEXTURE_2D, 0, 1, _iWidth, _iHeight, 0, GL_RED, GL_FLOAT, pData);
". He said that "The third parameter is "internal format", which can't be set to "1". That means you have a GL error. Because you didn't specify a float internal format, this won't be a float texture, and therefore you have 8-bit fixed-point values in the texture. "
But I don't understand why the third parameter cann't be set to 1.
Any suggestions are appreciated, thank you in advance!
glGenTextures(1, &_iTexture);
glBindTexture(GL_TEXTURE_2D, _iTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
//read data from a file through the function
//: read_img
float* pData = read_img(cPath, _iWidth, _iHeight);
//especiall this one
glTexImage2D(GL_TEXTURE_2D, 0, 1, _iWidth, _iHeight, 0, GL_RED, GL_FLOAT, pData); But I cann't get a correct result. Someone pointed out that there is something wrong with this statement "glTexImage2D(GL_TEXTURE_2D, 0, 1, _iWidth, _iHeight, 0, GL_RED, GL_FLOAT, pData);
". He said that "The third parameter is "internal format", which can't be set to "1". That means you have a GL error. Because you didn't specify a float internal format, this won't be a float texture, and therefore you have 8-bit fixed-point values in the texture. "
But I don't understand why the third parameter cann't be set to 1.
Any suggestions are appreciated, thank you in advance!