mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 15:33:00 +02:00
GLFB: add video aspect ratio handling
This commit is contained in:
@@ -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<float>(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);
|
||||
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user