diff --git a/generic-pc/glfb.cpp b/generic-pc/glfb.cpp index 04dd899..0826b27 100644 --- a/generic-pc/glfb.cpp +++ b/generic-pc/glfb.cpp @@ -62,6 +62,7 @@ GLFramebuffer::GLFramebuffer(int x, int y): mReInit(true), mShutDown(false), mIn mState.height = y; mX = y * 16 / 9; /* hard coded 16:9 initial aspect ratio for now */ mY = y; + mVA = 1.0; mState.blit = true; last_apts = 0; @@ -345,7 +346,7 @@ void GLFramebuffer::render() #endif { glBindTexture(GL_TEXTURE_2D, mState.displaytex); - drawSquare(1.0); + drawSquare(1.0, mVA / (16.0/9)); glBindTexture(GL_TEXTURE_2D, mState.osdtex); drawSquare(1.0); } @@ -420,7 +421,7 @@ void GLFramebuffer::drawCube(float size) } #endif -void GLFramebuffer::drawSquare(float size) +void GLFramebuffer::drawSquare(float size, float x_factor) { GLfloat vertices[] = { 1.0f, 1.0f, @@ -439,7 +440,7 @@ void GLFramebuffer::drawSquare(float size) }; glPushMatrix(); - glScalef(size, size, size); + glScalef(size * x_factor, size, size); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, vertices); @@ -480,6 +481,10 @@ void GLFramebuffer::bltDisplayBuffer() if (w == 0 || h == 0) return; + AVRational a = buf->AR(); + if (a.den != 0) + mVA = static_cast(w * a.num) / h / a.den; + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mState.displaypbo); glBufferData(GL_PIXEL_UNPACK_BUFFER, buf->size(), &(*buf)[0], GL_STREAM_DRAW_ARB); diff --git a/generic-pc/glfb.h b/generic-pc/glfb.h index 0bc9f19..71c78b2 100644 --- a/generic-pc/glfb.h +++ b/generic-pc/glfb.h @@ -46,6 +46,8 @@ private: fb_var_screeninfo screeninfo; int mX; /* window size */ int mY; + float mVA; /* video aspect ratio */; + bool mReInit; /* setup things for GL */ bool mShutDown; /* if set main loop is left */ bool mInitDone; /* condition predicate */ @@ -71,7 +73,7 @@ private: void setupGLObjects(); /* PBOs, textures and stuff */ void releaseGLObjects(); // void drawCube(float size); /* cubes are the building blocks of our society */ - void drawSquare(float size); /* do not be square */ + void drawSquare(float size, float x_factor = 1); /* do not be square */ struct { int width; /* width and height, fixed for a framebuffer instance */