开发者

FPS Game and OpenGL

开发者 https://www.devze.com 2023-04-12 06:02 出处:网络
I am trying to capture images coming from my game using LD_PRELOAD method, by supplying my own library so file that will intercept OpenGL calls. This method works great for simple demo OpenGL code (se

I am trying to capture images coming from my game using LD_PRELOAD method, by supplying my own library so file that will intercept OpenGL calls. This method works great for simple demo OpenGL code (see this project's file demo.cpp, make.sh, load.sh), however does not work for FPS game UrbanTerror which I thought was using OpenGL. My own supplied function gettimeofday is called properly, however my glXSwapBuffers is not, for some reason. Do these games use OpenGL differently? If so, how? Any tips on how to hook into UrT, and/or another FPS game would be welcome. I am on U开发者_开发百科buntu 11.

Related Question 1

Related Question 2


AFAIK the Quake3 engine (which is used for Urban Terror) implements a custom dynamic OpenGL loader system, i.e. the binary doesn't link against libGL.so directly, but uses dlopen to load libGL.so, then dlsym to retrieve all the OpenGL symbols. To avoid clashes with any directly linked code, all internal symbols are prefixed to "namespace" them.

The LD_PRELOAD environment variable however will have no effect then. To hook into dynamically loaded libraries you'll have to do some major trickery. There are several possibilities. I recommend also intercepting the dlopen and dlsym calls, and for functions you intend to hook into, return your trampoline (which will ultimately call the requested function) instead returning the function pointer directly.

BTW: It's good you asked this question now, as I'm about to write a similar preloading libGL.so as support for a window compositor I'm working on; and I'd probably fallen into the same pitfall.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号