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

Android OpenGL specifics #1

This commit is contained in:
f4exb 2016-02-29 03:04:14 +01:00
parent 8d43ead373
commit b2dc3026bc
3 changed files with 288 additions and 29 deletions

View File

@ -19,15 +19,13 @@
#ifndef INCLUDE_UTIL_GLESHELP_H_ #ifndef INCLUDE_UTIL_GLESHELP_H_
#define INCLUDE_UTIL_GLESHELP_H_ #define INCLUDE_UTIL_GLESHELP_H_
#define GLdouble GLfloat #define GL_VERTEX_ARRAY 0 // We like submitting vertices on stream 0 for no special reason (GL: 0x8074)
#define GL_CLAMP GL_CLAMP_TO_EDGE #define GL_NORMAL_ARRAY 1 // We like submitting normals on stream 1 for no special reason (GL: 0x8075)
#define glClearDepth glClearDepthf #define GL_TEXTURE_COORD_ARRAY 2 // We like submitting texcoords on stream 2 for no special reason (GL: 0x8078)
#define glOrtho glOrthof
#define glFrustum glFrustumf
#define glColor4fv(a) glColor4f(a[0], a[1], a[2], a[3]) #define glColor4fv(a) glColor4f(a[0], a[1], a[2], a[3])
#define glColor3fv(a) glColor4f(a[0], a[1], a[2], 1.0f) #define glColor3fv(a) glColor4f(a[0], a[1], a[2], 1.0f)
#define glColor3f(a,b,c) glColor4f(a, b, c, 1.0f #define glColor3f(a,b,c) glColor4f(a, b, c, 1.0f)
#endif /* INCLUDE_UTIL_GLESHELP_H_ */ #endif /* INCLUDE_UTIL_GLESHELP_H_ */

View File

@ -6,6 +6,10 @@
#include <algorithm> #include <algorithm>
#include <QDebug> #include <QDebug>
#ifdef GL_ANDROID
#include "util/gleshelp.h"
#endif
/* /*
#ifdef _WIN32 #ifdef _WIN32
static double log2f(double n) static double log2f(double n)
@ -270,11 +274,17 @@ void GLScope::paintGL()
0, 0, 0, 0,
1, 0 1, 0
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4); glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -322,11 +332,17 @@ void GLScope::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
// Vertical X1 // Vertical X1
@ -362,11 +378,17 @@ void GLScope::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -406,6 +428,15 @@ void GLScope::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -413,6 +444,7 @@ void GLScope::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -453,6 +485,15 @@ void GLScope::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -460,6 +501,7 @@ void GLScope::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -508,11 +550,17 @@ void GLScope::paintGL()
0, m_triggerLevelDis1, 0, m_triggerLevelDis1,
1, m_triggerLevelDis1 1, m_triggerLevelDis1
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
} }
#endif #endif
@ -605,12 +653,17 @@ void GLScope::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start); glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
m_nbPow = end - start; m_nbPow = end - start;
} }
#endif #endif
@ -675,11 +728,17 @@ void GLScope::paintGL()
q3[2*i] = i - start; q3[2*i] = i - start;
q3[2*i + 1] = v; q3[2*i + 1] = v;
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start); glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -772,6 +831,15 @@ void GLScope::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -779,6 +847,7 @@ void GLScope::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -813,11 +882,17 @@ void GLScope::paintGL()
0, 0, 0, 0,
1, 0 1, 0
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4); glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -861,11 +936,17 @@ void GLScope::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
// Vertical X2 // Vertical X2
@ -900,11 +981,17 @@ void GLScope::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -944,6 +1031,15 @@ void GLScope::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -951,6 +1047,7 @@ void GLScope::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -991,6 +1088,15 @@ void GLScope::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -998,6 +1104,7 @@ void GLScope::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -1042,11 +1149,17 @@ void GLScope::paintGL()
0, m_triggerLevelDis2, 0, m_triggerLevelDis2,
1, m_triggerLevelDis2 1, m_triggerLevelDis2
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
} }
#endif #endif
@ -1110,11 +1223,17 @@ void GLScope::paintGL()
q3[2*i] = x; q3[2*i] = x;
q3[2*i+1] = y; q3[2*i+1] = y;
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start); glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -1160,11 +1279,17 @@ void GLScope::paintGL()
q3[2*i] = i - start; q3[2*i] = i - start;
q3[2*i+1] = v; q3[2*i+1] = v;
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, end - start); glDrawArrays(GL_LINE_STRIP, 0, end - start);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
//glDisable(GL_LINE_SMOOTH); //glDisable(GL_LINE_SMOOTH);
@ -1457,6 +1582,15 @@ void GLScope::drawPowerOverlay()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -1464,6 +1598,7 @@ void GLScope::drawPowerOverlay()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);

View File

@ -24,6 +24,10 @@
#include <QDebug> #include <QDebug>
#ifdef GL_ANDROID
#include "util/gleshelp.h"
#endif
GLSpectrum::GLSpectrum(QWidget* parent) : GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent), QGLWidget(parent),
m_cursorState(CSNormal), m_cursorState(CSNormal),
@ -566,6 +570,16 @@ void GLSpectrum::paintGL()
1, prop_y, 1, prop_y,
0, prop_y 0, prop_y
}; };
#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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -573,6 +587,7 @@ void GLSpectrum::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -603,10 +618,17 @@ void GLSpectrum::paintGL()
0, 1 0, 1
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -636,10 +658,17 @@ void GLSpectrum::paintGL()
1, 0 1, 0
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4); glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -700,6 +729,15 @@ void GLSpectrum::paintGL()
1, 1, 1, 1,
0, 1 0, 1
}; };
#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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -707,6 +745,7 @@ void GLSpectrum::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -740,10 +779,17 @@ void GLSpectrum::paintGL()
0, 1 0, 1
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -770,11 +816,17 @@ void GLSpectrum::paintGL()
0.5, 0, 0.5, 0,
0.5, 1 0.5, 1
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -802,11 +854,17 @@ void GLSpectrum::paintGL()
0, 0, 0, 0,
1, 0 1, 0
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_LOOP, 0, 4); glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -850,6 +908,15 @@ void GLSpectrum::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -857,6 +924,7 @@ void GLSpectrum::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -903,6 +971,15 @@ void GLSpectrum::paintGL()
1, 0, 1, 0,
0, 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_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vtx1); glVertexPointer(2, GL_FLOAT, 0, vtx1);
@ -910,6 +987,7 @@ void GLSpectrum::paintGL()
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -946,11 +1024,17 @@ void GLSpectrum::paintGL()
1, 0.5, 1, 0.5,
0, 0.5 0, 0.5
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -978,11 +1062,17 @@ void GLSpectrum::paintGL()
0.5, 0, 0.5, 0,
0.5, 1 0.5, 1
}; };
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();
@ -1044,11 +1134,17 @@ void GLSpectrum::paintGL()
q3[2*i] = (Real) i; q3[2*i] = (Real) i;
q3[2*i+1] = v; q3[2*i+1] = v;
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, m_fftSize);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, m_fftSize); glDrawArrays(GL_LINE_STRIP, 0, m_fftSize);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
//glDisable(GL_LINE_SMOOTH); //glDisable(GL_LINE_SMOOTH);
@ -1092,11 +1188,17 @@ void GLSpectrum::paintGL()
q3[2*i] = (Real) i; q3[2*i] = (Real) i;
q3[2*i+1] = v; q3[2*i+1] = v;
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, m_fftSize);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINE_STRIP, 0, m_fftSize); glDrawArrays(GL_LINE_STRIP, 0, m_fftSize);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
//glDisable(GL_LINE_SMOOTH); //glDisable(GL_LINE_SMOOTH);
@ -1149,11 +1251,17 @@ void GLSpectrum::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
tickList = &m_frequencyScale.getTickList(); tickList = &m_frequencyScale.getTickList();
@ -1187,11 +1295,17 @@ void GLSpectrum::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
@ -1243,11 +1357,17 @@ void GLSpectrum::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
tickList = &m_frequencyScale.getTickList(); tickList = &m_frequencyScale.getTickList();
@ -1281,11 +1401,17 @@ void GLSpectrum::paintGL()
} }
} }
} }
#ifdef GL_ANDROID
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
#else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, q3); glVertexPointer(2, GL_FLOAT, 0, q3);
glDrawArrays(GL_LINES, 0, 2*effectiveTicks); glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
#endif
} }
#endif #endif
glPopMatrix(); glPopMatrix();