I'm using LWJGL, however I'm a bit confused on what to do.

I'm trying to write an AI simulation, however I'm stuck at this problem. I have one camera, and I plan to move the camera to the mob position and then save it to the screen, then I will then use that to input into the neural network, then it does its action, then I move onto the next mob and repeat. Then, finally I move the camera to the player position so I can see what is happening.

The problem is that I just want to see out of the player eyes and not the mob eyes. However, I'm confused on how to do it. http://www.lwjgl.org/wiki/index.php?title=Taking_Screen_Shots the only way I can think of getting the information for what the mobs see is to take a screen shot if I render it to the screen. But, then if I do this all I will see is everything jump around a lot.

The code will look something like this

public class Game() {
  public Game() {
      camera = new Camera();
      player = new Player();
      ArrayList<Mobs> mobs = new ArrayList<Mobs>();

  public void update() {
    for(int i=0; i<mobs.length; i++) {

   public void render() {

There must be a better way. For example, maybe it possible to not render to the screen to input the data into the mob. Or maybe, I don't need to save it to say .png to then put into the neural network.

  • \$\begingroup\$ I have no experience with lwjgl, but I would try to add an own camera object to each AI entity and have it render off-screen, while the actual camera which renders to the users screen stays independent of the AI. \$\endgroup\$
    – Philipp
    Jul 9, 2013 at 10:56

1 Answer 1


Just render to an offscreen buffer for each mob. This is an FBO in OpenGL or a RenderTarget in D3D. In OpenGL, if no FBO is bound, everything is rendered to the screen. Just create and bind an FBO and then the mob's "view" will be rendered into a texture of your choosing for processing (and you aren't required to draw it to the screen, ever).

Note that you probably don't actually want to render the mob's vision. I'm not sure what AI you're trying to do, but odds are you're trying to do things a little too "realistic" and not faking things enough. Remember, in AI, the goal of computer vision is to take an image and then break it down into some semantic representation; with a game, you're starting with the semantic representation and then drawing it, just to try to convert it back (which is hard). Even if you think you need to really "see" you can usually fake this with ray casts and other scene metadata in a significantly faster and easier way than trying to do any sort of image processing on a rendered scene.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .