Can anyone tell me quickly the functions to render into a texture ? Too busy to seach
Thanks !
There are two ways I know of.
- Render what you want and use glReadPixels() to get it into system memory. Then use glTexImage2D() to define it as a texture.
- Render what you want and use glCopyTexImage() to transfer your rendering directly into texture memory.
I know Option (1) works, but it is a bit clunky. Option (2) should be much faster, but I can never get it to work!
Why is this? Any ideas?
-Jules
hmmm Option (2) does work for me…
glGenTextures(1, &tex_name);
glBindTexture(GL_TEXTURE_2D,tex_name);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
glEnable(GL_TEXTURE_2D);
glCopyTexImage2D(GL_TEXTURE_2D,0,mTextureFormat,0, 0,Width(),Height(),border);
hmm this works for me
Chris
This does bode well !
Thanks guys !