tomjscott
06-24-2004, 12:08 PM
I am having problems getting textures to reside in video memory. I've reduced my code down to simply creating a texture with no data that is 256x256 RGBA and it still does not query as being resident when I prioritize it. Here is my code:
GLuint mTexID;
glGenTextures(1, &mTexID);
int mWidth = 256;
int mHeight = 256;
int mDepth = 4;
unsigned char* data = (unsigned char*)malloc(mWidth * mHeight * mDepth);
memset(data, 0, mWidth * mHeight * mDepth);
glBindTexture(GL_TEXTURE_2D, mTexID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// trying to set priority here even though I re-prioritize later. seems to have
// no effect either way.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, data);
// prioritize the texture
GLclampf* priorities = new GLclampf[1];
for (int i = 0; i < 1; ++i)
{
priorities[i] = 1.0f;
}
glPrioritizeTextures(1, &mTexID, priorities);
GLboolean* flags = new GLboolean[1];
bool bAllResident = glAreTexturesResident(1, &mTexID, flags);
if (bAllResident)
{
cout << "is resident" << endl;
}
else
{
cout << "not resident" << endl;
}
delete []priorities;
delete []flags;
delete []data;I am running OpenGL on a Linux machine using the 5328 driver with a Geforce2 MX card having 64MB RAM.
GLuint mTexID;
glGenTextures(1, &mTexID);
int mWidth = 256;
int mHeight = 256;
int mDepth = 4;
unsigned char* data = (unsigned char*)malloc(mWidth * mHeight * mDepth);
memset(data, 0, mWidth * mHeight * mDepth);
glBindTexture(GL_TEXTURE_2D, mTexID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// trying to set priority here even though I re-prioritize later. seems to have
// no effect either way.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, data);
// prioritize the texture
GLclampf* priorities = new GLclampf[1];
for (int i = 0; i < 1; ++i)
{
priorities[i] = 1.0f;
}
glPrioritizeTextures(1, &mTexID, priorities);
GLboolean* flags = new GLboolean[1];
bool bAllResident = glAreTexturesResident(1, &mTexID, flags);
if (bAllResident)
{
cout << "is resident" << endl;
}
else
{
cout << "not resident" << endl;
}
delete []priorities;
delete []flags;
delete []data;I am running OpenGL on a Linux machine using the 5328 driver with a Geforce2 MX card having 64MB RAM.