for(int i=0;i);
glTexSubImage2D(GL_TEXTURE_2D,0,x,y,sizex,sizey,GL_ALPHA,GL_FLOAT,textureWeights);
//glTexImage2D(GL_TEXTURE_2D,0,GL_ALPHA,size*2,size*2,0,GL_ALPHA,GL_FLOAT,textureWeights);
} </pre> The commented out line is what I used to use. Obviously this is inefficient with larger textures. Has anyone gotten glTexSubImage2D to work correctly? </i>
glTexSubImage2D
glTexSubImage2D doesn''t seem to do exactly what it says. The following code works correctly, but only when I update the entire texture at once.
It seems that you''re passing the exact same data to both glTexSubImage2D and glTexImage2D. glTexSubImage2D does not automatically offset the data and apply a stride to it, if you''re expecting it to. You can still pass glTexSubImage2D an address of a buffer holding a "full image" if you inform it of what you''re doing (call glPixelStore with at least GL_PACK_ROW_LENGTH) and pass it a proper offset into that buffer.
I still can't get it to work .
[edited by - Raloth on October 22, 2003 10:09:55 PM]
for(int i=0;i<NUM_LAND_TEXTURES;i++) { glBindTexture(GL_TEXTURE_2D,alphamaps[i]); glPixelStorei(GL_PACK_ROW_LENGTH,size*2); glTexSubImage2D(GL_TEXTURE_2D,0,x,y,sizex,sizey,GL_ALPHA,GL_FLOAT,textureWeights[ i ]+y*size*2+x); }
[edit] The size*2 things are in there because I have two pixels per tile on my terrain. [edited by - Raloth on October 22, 2003 10:09:55 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement