tags:

views:

16

answers:

0

Hi everyone,

I am trying to set up a 3d openGL scene just like in the image below. I have a few different 2d squares (x,y) in that scene. The camera has the position (0,0,-5). Now I want to be able to rotate the camera to see the squares on the upper left side. How can i manage to do this? I tried rotating my camera. Problem is, that the object at the center are being turned and not the camera itself.... can somebody help me?

alt text

Here is my code:

First is set up the view:

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glViewport(0, 0, self.bounds.size.width, self.bounds.size.height);
glMatrixMode(GL_PROJECTION);

glLoadIdentity();
float ratio = self.bounds.size.width / self.bounds.size.height;
glFrustumf(-ratio, ratio, -ratio, ratio, 1, 1000);
glEnable(GL_DEPTH_TEST);

glMatrixMode(GL_MODELVIEW);

Then I render the scene -> updates every frame:

[EAGLContext setCurrentContext:context];

glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

static const GLfloat squareVertices[] = {
    -0.5f,  -0.33f,
    0.5f,  -0.33f,
    -0.5f,   0.33f,
    0.5f,   0.33f,
};



static const GLubyte squareColors[] = {
    255, 255,   0, 255,
    0,   255, 255, 255,
    0,     0,   0,   0,
    255,   0, 255, 255,
};


glVertexPointer(2, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);


glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];

Is there a possible way to make this happen?