mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 13:48:38 -05:00
Patch for OpenGL 1280 errors
This commit is contained in:
parent
3657ce38bc
commit
e9b99be18c
@ -141,7 +141,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, float r, float
|
|||||||
glVertex3f(uxPos + ofs, hPos + labelHeight, 0.0);
|
glVertex3f(uxPos + ofs, hPos + labelHeight, 0.0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
|
||||||
glColor4f(r, g, b, 0.2);
|
glColor4f(r, g, b, 0.2);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
@ -189,11 +189,10 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
|
|||||||
|
|
||||||
float uxPos = (float) (demod->getFrequency() - (center_freq - srate / 2)) / (float) srate;
|
float uxPos = (float) (demod->getFrequency() - (center_freq - srate / 2)) / (float) srate;
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
glColor4f(r, g, b, 0.6);
|
glColor4f(r, g, b, 0.6);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
@ -210,7 +209,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
|
|||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
glColor4f(r, g, b, 0.2);
|
glColor4f(r, g, b, 0.2);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex3f((uxPos - 0.5) * 2.0 - ofs, 1.0, 0.0);
|
glVertex3f((uxPos - 0.5) * 2.0 - ofs, 1.0, 0.0);
|
||||||
@ -267,7 +266,6 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
|
|||||||
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, 16, demodAlign, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(PrimaryGLContext::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, 16, demodAlign, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,11 +284,10 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b,
|
|||||||
srate = wxGetApp().getSampleRate();
|
srate = wxGetApp().getSampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
glColor4f(r, g, b, 0.6);
|
glColor4f(r, g, b, 0.6);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
@ -313,7 +310,6 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b,
|
|||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,42 +3,56 @@
|
|||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
WaterfallContext::WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext) :
|
WaterfallContext::WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext) :
|
||||||
PrimaryGLContext(canvas, sharedContext), waterfall(0), waterfall_tex(NULL), waterfall_lines(0), fft_size(0), activeTheme(NULL) {
|
PrimaryGLContext(canvas, sharedContext), waterfall_lines(0), fft_size(0), activeTheme(NULL) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
waterfall[i] = 0;
|
||||||
|
waterfall_tex[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
||||||
if (waterfall) {
|
|
||||||
glDeleteTextures(1, &waterfall);
|
|
||||||
waterfall = 0;
|
|
||||||
}
|
|
||||||
if (waterfall_tex) {
|
|
||||||
delete waterfall_tex;
|
|
||||||
}
|
|
||||||
|
|
||||||
waterfall_lines = num_waterfall_lines_in;
|
waterfall_lines = num_waterfall_lines_in;
|
||||||
fft_size = fft_size_in;
|
fft_size = fft_size_in;
|
||||||
|
|
||||||
waterfall_tex = new unsigned char[fft_size * waterfall_lines];
|
int half_fft_size = fft_size / 2;
|
||||||
memset(waterfall_tex, 0, fft_size * waterfall_lines);
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
if (waterfall[i]) {
|
||||||
|
glDeleteTextures(1, &waterfall[i]);
|
||||||
|
waterfall[i] = 0;
|
||||||
|
}
|
||||||
|
if (waterfall_tex[i]) {
|
||||||
|
delete waterfall_tex[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
waterfall_tex[i] = new unsigned char[half_fft_size * waterfall_lines];
|
||||||
|
memset(waterfall_tex[i], 0, half_fft_size * waterfall_lines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallContext::refreshTheme() {
|
void WaterfallContext::refreshTheme() {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, waterfall);
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
|
||||||
|
|
||||||
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
|
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getRed())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getRed())[0]);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getGreen())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getGreen())[0]);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getBlue())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getBlue())[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallContext::Draw(std::vector<float> &points) {
|
void WaterfallContext::Draw(std::vector<float> &points) {
|
||||||
|
|
||||||
if (!waterfall) {
|
|
||||||
glGenTextures(1, &waterfall);
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, waterfall);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||||
|
|
||||||
|
if (!waterfall[0]) {
|
||||||
|
glGenTextures(2, waterfall);
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
@ -46,48 +60,67 @@ void WaterfallContext::Draw(std::vector<float> &points) {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (activeTheme != ThemeMgr::mgr.currentTheme) {
|
if (activeTheme != ThemeMgr::mgr.currentTheme) {
|
||||||
refreshTheme();
|
refreshTheme();
|
||||||
activeTheme = ThemeMgr::mgr.currentTheme;
|
activeTheme = ThemeMgr::mgr.currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
int half_fft_size = fft_size / 2;
|
||||||
|
|
||||||
if (points.size()) {
|
if (points.size()) {
|
||||||
memmove(waterfall_tex + fft_size, waterfall_tex, (waterfall_lines - 1) * fft_size);
|
for (int j = 0; j < 2; j++) {
|
||||||
|
memmove(waterfall_tex[j] + half_fft_size, waterfall_tex[j], (waterfall_lines - 1) * half_fft_size);
|
||||||
|
|
||||||
for (int i = 0, iMax = fft_size; i < iMax; i++) {
|
for (int i = 0, iMax = half_fft_size; i < iMax; i++) {
|
||||||
float v = points[i * 2 + 1];
|
float v = points[(j * half_fft_size + i) * 2 + 1];
|
||||||
|
|
||||||
float wv = v;
|
float wv = v;
|
||||||
if (wv < 0.0)
|
if (wv < 0.0)
|
||||||
wv = 0.0;
|
wv = 0.0;
|
||||||
if (wv > 0.99)
|
if (wv > 0.99)
|
||||||
wv = 0.99;
|
wv = 0.99;
|
||||||
waterfall_tex[i] = (unsigned char) floor(wv * 255.0);
|
waterfall_tex[j][i] = (unsigned char) floor(wv * 255.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, waterfall);
|
for (int i = 0; i < 2; i++) {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fft_size, waterfall_lines, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (GLvoid *) waterfall_tex);
|
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, half_fft_size, waterfall_lines, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (GLvoid *) waterfall_tex[i]);
|
||||||
|
}
|
||||||
|
|
||||||
glColor3f(1.0, 1.0, 1.0);
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, waterfall);
|
glBindTexture(GL_TEXTURE_2D, waterfall[0]);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0.0, 1.0);
|
glTexCoord2f(0.0, 1.0);
|
||||||
glVertex3f(-1.0, -1.0, 0.0);
|
glVertex3f(-1.0, -1.0, 0.0);
|
||||||
glTexCoord2f(1.0, 1.0);
|
glTexCoord2f(1.0, 1.0);
|
||||||
|
glVertex3f(0.0, -1.0, 0.0);
|
||||||
|
glTexCoord2f(1.0, 0.0);
|
||||||
|
glVertex3f(0.0, 1.0, 0.0);
|
||||||
|
glTexCoord2f(0.0, 0.0);
|
||||||
|
glVertex3f(-1.0, 1.0, 0.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall[1]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0, 1.0);
|
||||||
|
glVertex3f(0.0, -1.0, 0.0);
|
||||||
|
glTexCoord2f(1.0, 1.0);
|
||||||
glVertex3f(1.0, -1.0, 0.0);
|
glVertex3f(1.0, -1.0, 0.0);
|
||||||
glTexCoord2f(1.0, 0.0);
|
glTexCoord2f(1.0, 0.0);
|
||||||
glVertex3f(1.0, 1.0, 0.0);
|
glVertex3f(1.0, 1.0, 0.0);
|
||||||
glTexCoord2f(0.0, 0.0);
|
glTexCoord2f(0.0, 0.0);
|
||||||
glVertex3f(-1.0, 1.0, 0.0);
|
glVertex3f(0.0, 1.0, 0.0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ public:
|
|||||||
void refreshTheme();
|
void refreshTheme();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint waterfall;
|
GLuint waterfall[2];
|
||||||
unsigned char *waterfall_tex;
|
unsigned char *waterfall_tex[2];
|
||||||
int fft_size;
|
int fft_size;
|
||||||
int waterfall_lines;
|
int waterfall_lines;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user