Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Jun 2011
Offline Last Active Jun 13 2013 03:43 PM

Posts I've Made

In Topic: glCopyBufferSubData?

19 May 2013 - 02:35 PM

Hi, mhagain, thanks for the reply.
Yeah, my hardware can't deal with that you mentioned.
For the moment I'm wondering how good or bad is my current approach of copying a texture binded by some FBO into another binded by another FBO.
The method consists in clearing the destination texture and drawing the first one to the second, so I can make the copy even if dealing with different sized textures.

In Topic: glCopyBufferSubData?

18 May 2013 - 07:41 AM

Yeah, it seems that I can't. FBO is not a buffer object.

In Topic: glCopyBufferSubData?

18 May 2013 - 07:40 AM

The manual says those are specified in basic machine units, which is most likely bytes, just like in other opengl functions. Have you tried passing zeros for offsets, and the size of your buffer in bytes for the size? It should copy the whole buffer.

I tried every reasonable combination.
Maybe it's important to say that I'm trying to copy an FBO to another (because I don't know if this function can deal with FBO's).


In Topic: How can I change [-1,1] range from gluPerspective?

17 May 2013 - 03:26 PM

Thanks for the replies.

I assumed this is what he wants, for example to be able to do a 2D UI with nice 3D transitions.

That's exactly what I want: be able to see my layers from different perspectives and choose one among them with a nice interface.

However, I couldn't make it work yet. Tried both approaches, from Bob and Olof, but stills nothing.

I don't know if I'm doing the calculations ok. Let me try to explain exactly how it's being done so far:

The layer l1 is drawn over the layer l2. Every layer have it's own attributes, i.e, xPosition, yPosition, width, height, and angle, so I must (I guess) apply the properly transformations in the modelview matrix before each draw.

As posted before, that's my perspective function, called before anything:


void setPerspective(int w, int h)
    glViewport(0, 0, w, h);
    // gluOrtho2D(0, w, h, 0); (the old guy)
    gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 0.001, 5000.0);
    ... (transformations suggested by you)



And that's the mess with which my layer is drawn, working perfectly with ortho2D:


            setPerspective(dst->width, dst->height);

               // Dest transformations
            glTranslatef(dst->cx, dst->cy, 0);  // cx = width/2   cy = height/2
            glRotatef(-dst->angle, 0, 0, 1);
            glTranslatef(-dst->cx, -dst->cy, 0);
            glTranslatef(-dst->x, -dst->y, 0.0f);

               // Source transformations
            glTranslatef(src->x, src->y, 0.0f);
            glTranslatef(src->cx, src->cy, 0);
            glRotatef(src->angle, 0, 0, 1);
            glTranslatef(-src->cx, -src->cy, 0);

            glBindTexture(GL_TEXTURE_2D, src->texID;

            glTexCoord2f(0.0f, 1.0f);  glVertex2i(0,0);    
            glTexCoord2f(1.0f, 1.0f);  glVertex2i(src->width,0);  
            glTexCoord2f(1.0f, 0.0f);  glVertex2i(src->width,src->height);  
            glTexCoord2f(0.0f, 0.0f);  glVertex2i(0,src->height);

            glBindTexture(GL_TEXTURE_2D, 0);



In Topic: How can I change [-1,1] range from gluPerspective?

17 May 2013 - 03:46 AM

That is the job of the view matrix.


A scaling and a translation will make sure that the coordinates in x/y-plane from 0,0 to w,h is mapped to the screen.

Sorry, but this is a little vague to me.
All I'm doing is making a perspective change before every texture draw — since they can have different sizes — with:

void setPerspective(int w, int h)
    glViewport(0, 0, w, h);
    gluOrtho2D(0, w, h, 0);


By replacing my gluOrtho2D with gluPerspective, what changes shoud I make and where?