Re: [PyOpenGL-Users] Textures usage
Brought to you by:
mcfletch
From: Gijs <in...@bs...> - 2010-01-08 15:49:07
|
On 1/8/10 16:04 , Frédéric wrote: > Le vendredi 8 janvier 2010 14:29, Gijs a écrit : > >> I haven't done any QT programming, so I could be wrong, but your code >> shouldn't even require a couple of %'s of your CPU. The work that your >> script does is hardly CPU-intensive and if your timer really updates >> your frame every 1/50th of a second, then the CPU hardly does anything. >> If on the other hand somehow OpenGL does updates without any sleeptime >> inbetween, then it would explain the CPU usage. So I would check the >> timer function or at least check how often your draw function is called. > > It appears that the CPU is not used by my process. I'm not sure, but it > seems to be a kernel-space usage (orange in the Gkrellm default theme)... > >> Some optimizations might be to move the glBlendFunc out of the drawing >> function to the init function. If you don't change the blending function >> somewhere else, then setting it once is enough since it is a global >> setting (not something that you need to set everytime you call >> glEnable(GL_BLEND)). You can also move glLoadIdentity to the init >> function if you don't call glRotate/glTranslate/glScale commands in >> other parts of your code. Also, though I'm not completely sure on this, >> you should be able to clear your screen without having to disable/enable >> dither and blending every time. Put the enable calls in the init section >> and see what happens. > > Thanks for the tips. > >> There are many ways to change a texture though I'm not sure your video >> card would support all of them. Shaders, PBOs, and FBOs are the usual >> way to do this but check and see if your FX5200 supports those. >> Otherwise you'd need to use the standard OpenGL calls like >> glCopyTexImage2D. > > Ok, I will first try glCopyTexImage2D. From where should I call it? Should > it be in a GL-specific context? What if the image ratio change? How do I > handle this? Can I resize the texture? > Well, depends on your implementation where you'd want to put the glCopyTex command, but probably somewhere after or before the drawing function. If you want to draw a texture that has dimensions of 512x512 on a 640x480 screen, OpenGL just resizes the texture accordingly. The final image might look a bit crushed or stretched, depending on the resolution that you draw at and the original resolution of your texture, so you might need something like mipmapping to fix this. But try it without mipmapping first. |