1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

Reorder glPushMatrix and glBindTexture to ease future migration to Open GL ES 2.0

This commit is contained in:
f4exb 2016-02-28 11:01:58 +01:00
parent 5ecf7ea00c
commit 718dcf3d8f
2 changed files with 30 additions and 31 deletions

View File

@ -306,14 +306,14 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// paint left #1 scale // paint left #1 scale
glPushMatrix();
glTranslatef(m_glLeft1ScaleRect.x(), m_glLeft1ScaleRect.y(), 0);
glScalef(m_glLeft1ScaleRect.width(), m_glLeft1ScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_left1ScaleTexture); glBindTexture(GL_TEXTURE_2D, m_left1ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glLeft1ScaleRect.x(), m_glLeft1ScaleRect.y(), 0);
glScalef(m_glLeft1ScaleRect.width(), m_glLeft1ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -329,14 +329,14 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// paint bottom #1 scale // paint bottom #1 scale
glPushMatrix();
glTranslatef(m_glBot1ScaleRect.x(), m_glBot1ScaleRect.y(), 0);
glScalef(m_glBot1ScaleRect.width(), m_glBot1ScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_bot1ScaleTexture); glBindTexture(GL_TEXTURE_2D, m_bot1ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glBot1ScaleRect.x(), m_glBot1ScaleRect.y(), 0);
glScalef(m_glBot1ScaleRect.width(), m_glBot1ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -515,14 +515,14 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// Paint secondary scale // Paint secondary scale
glPushMatrix();
glTranslatef(m_glRight1ScaleRect.x(), m_glRight1ScaleRect.y(), 0);
glScalef(m_glRight1ScaleRect.width(), m_glRight1ScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture); glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glRight1ScaleRect.x(), m_glRight1ScaleRect.y(), 0);
glScalef(m_glRight1ScaleRect.width(), m_glRight1ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -597,14 +597,14 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// paint left #2 scale // paint left #2 scale
glPushMatrix();
glTranslatef(m_glLeft2ScaleRect.x(), m_glLeft2ScaleRect.y(), 0);
glScalef(m_glLeft2ScaleRect.width(), m_glLeft2ScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture); glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glLeft2ScaleRect.x(), m_glLeft2ScaleRect.y(), 0);
glScalef(m_glLeft2ScaleRect.width(), m_glLeft2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -620,14 +620,14 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// paint bottom #2 scale // paint bottom #2 scale
glPushMatrix();
glTranslatef(m_glBot2ScaleRect.x(), m_glBot2ScaleRect.y(), 0);
glScalef(m_glBot2ScaleRect.width(), m_glBot2ScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_bot2ScaleTexture); glBindTexture(GL_TEXTURE_2D, m_bot2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glBot2ScaleRect.x(), m_glBot2ScaleRect.y(), 0);
glScalef(m_glBot2ScaleRect.width(), m_glBot2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -989,12 +989,6 @@ void GLScope::drawPowerOverlay()
QGLContext::MipmapBindOption); QGLContext::MipmapBindOption);
m_powerOverlayTextureAllocated1 = true; m_powerOverlayTextureAllocated1 = true;
glBindTexture(GL_TEXTURE_2D, m_powerOverlayTexture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
float shiftX = m_glScopeRect1.width() - ((rect.width() + 4.0f) / width()); float shiftX = m_glScopeRect1.width() - ((rect.width() + 4.0f) / width());
float shiftY = 6.0f / height(); float shiftY = 6.0f / height();
@ -1003,6 +997,11 @@ void GLScope::drawPowerOverlay()
glTranslatef(m_glScopeRect1.x() + shiftX, m_glScopeRect1.y(), 0); glTranslatef(m_glScopeRect1.x() + shiftX, m_glScopeRect1.y(), 0);
glScalef(rect.width() / (float) width(), rect.height() / (float) height(), 1); glScalef(rect.width() / (float) width(), rect.height() / (float) height(), 1);
glBindTexture(GL_TEXTURE_2D, m_powerOverlayTexture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);

View File

@ -689,16 +689,15 @@ void GLSpectrum::paintGL()
// paint left scales (time and power) // paint left scales (time and power)
if(m_displayWaterfall || m_displayMaxHold || m_displayCurrent || m_displayHistogram ) { if(m_displayWaterfall || m_displayMaxHold || m_displayCurrent || m_displayHistogram ) {
glPushMatrix();
glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0);
glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture); glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0);
glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -711,11 +710,16 @@ void GLSpectrum::paintGL()
glVertex2f(0, 0); glVertex2f(0, 0);
glEnd(); glEnd();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glPopMatrix(); glPopMatrix();
} }
// paint frequency scale // paint frequency scale
if(m_displayWaterfall || m_displayMaxHold || m_displayCurrent || m_displayHistogram ) { if(m_displayWaterfall || m_displayMaxHold || m_displayCurrent || m_displayHistogram ) {
glPushMatrix();
glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0);
glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1);
glBindTexture(GL_TEXTURE_2D, m_frequencyTexture); glBindTexture(GL_TEXTURE_2D, m_frequencyTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -723,11 +727,6 @@ void GLSpectrum::paintGL()
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPushMatrix();
glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0);
glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
@ -740,6 +739,7 @@ void GLSpectrum::paintGL()
glVertex2f(0, 0); glVertex2f(0, 0);
glEnd(); glEnd();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glPopMatrix(); glPopMatrix();
// paint channels // paint channels