Skip to content

Commit

Permalink
OpenGL modernization: GLScope modernization #2
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Mar 5, 2016
1 parent 1dbd387 commit e55da66
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
1 change: 1 addition & 0 deletions include/gui/glscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class SDRANGEL_API GLScope: public QGLWidget {

GLShaderSimple m_glShaderSimple;
GLShaderTextured m_glShaderLeft1Scale;
GLShaderTextured m_glShaderBottom1Scale;

void initializeGL();
void resizeGL(int width, int height);
Expand Down
73 changes: 33 additions & 40 deletions sdrbase/gui/glscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ void GLScope::initializeGL()
{
glDisable(GL_DEPTH_TEST);
m_glShaderSimple.initializeGL();
m_glShaderLeft1Scale.initializeGL();
m_glShaderBottom1Scale.initializeGL();
}

void GLScope::resizeGL(int width, int height)
Expand Down Expand Up @@ -408,6 +410,7 @@ void GLScope::paintGL()
#endif

// paint left #1 scale
#ifdef GL_DEPRECATED
glPushMatrix();
glTranslatef(m_glLeft1ScaleRect.x(), m_glLeft1ScaleRect.y(), 0);
glScalef(m_glLeft1ScaleRect.width(), m_glLeft1ScaleRect.height(), 1);
Expand All @@ -417,7 +420,7 @@ void GLScope::paintGL()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
#ifdef GL_DEPRECATED

glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
Expand All @@ -428,6 +431,8 @@ void GLScope::paintGL()
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
#else
{
GLfloat vtx1[] = {
Expand All @@ -442,29 +447,13 @@ void GLScope::paintGL()
1, 0,
0, 0
};
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glEnableVertexAttribArray(GL_TEXTURE_COORD_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, vtx1);
glVertexAttribPointer(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, tex1);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
glDisableVertexAttribArray(GL_TEXTURE_COORD_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1);
glTexCoordPointer(2, GL_FLOAT, 0, tex1);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif

m_glShaderLeft1Scale.drawSurface(m_glLeft1ScaleMatrix, tex1, vtx1, 4);
}
#endif
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// paint bottom #1 scale
#ifdef GL_DEPRECATED
glPushMatrix();
glTranslatef(m_glBot1ScaleRect.x(), m_glBot1ScaleRect.y(), 0);
glScalef(m_glBot1ScaleRect.width(), m_glBot1ScaleRect.height(), 1);
Expand All @@ -474,7 +463,7 @@ void GLScope::paintGL()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
#ifdef GL_DEPRECATED

glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
Expand All @@ -485,6 +474,9 @@ void GLScope::paintGL()
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();

glDisable(GL_TEXTURE_2D);
glPopMatrix();
#else
{
GLfloat vtx1[] = {
Expand All @@ -499,27 +491,10 @@ void GLScope::paintGL()
1, 0,
0, 0
};
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glEnableVertexAttribArray(GL_TEXTURE_COORD_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, vtx1);
glVertexAttribPointer(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, tex1);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
glDisableVertexAttribArray(GL_TEXTURE_COORD_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1);
glTexCoordPointer(2, GL_FLOAT, 0, tex1);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif

m_glShaderBottom1Scale.drawSurface(m_glBot1ScaleMatrix, tex1, vtx1, 4);
}
#endif
glDisable(GL_TEXTURE_2D);
glPopMatrix();

// paint trigger level #1
if ((m_triggerChannel == ScopeVis::TriggerChannelI)
Expand Down Expand Up @@ -1865,6 +1840,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_left1ScaleTextureAllocated = true;

m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage());

} // Y1 scale
{ // X1 scale
m_x1Scale.setSize(scopeWidth);
Expand Down Expand Up @@ -1900,6 +1878,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_bot1ScaleTextureAllocated = true;

m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage());

} // X1 scale

if (m_mode == ModeIQPolar)
Expand Down Expand Up @@ -2228,6 +2209,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_left1ScaleTextureAllocated = true;

m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage());

} // Y1 scale
{ // X1 scale
m_x1Scale.setSize(scopeWidth);
Expand Down Expand Up @@ -2263,6 +2247,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_bot1ScaleTextureAllocated = true;

m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage());

} // X1 scale

if (m_mode == ModeIQPolar)
Expand Down Expand Up @@ -2596,6 +2583,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_left1ScaleTextureAllocated = true;

m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage());

} // Y1 scale
if (m_mode == ModeIQPolar) { // Y2 scale
m_y2Scale.setSize(scopeHeight);
Expand Down Expand Up @@ -2666,6 +2656,9 @@ void GLScope::applyConfig()
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_bot1ScaleTextureAllocated = true;

m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage());

} // X1 scale
} // Primary display only
else if (m_displays == DisplaySecondOnly)
Expand Down

0 comments on commit e55da66

Please sign in to comment.