2014-11-15 23:41:41 -05:00
|
|
|
#include "SpectrumContext.h"
|
|
|
|
|
|
|
|
|
|
#include "SpectrumCanvas.h"
|
|
|
|
|
|
|
|
|
|
SpectrumContext::SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedContext) :
|
|
|
|
|
PrimaryGLContext(canvas, sharedContext) {
|
2014-12-05 18:20:28 -05:00
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
2014-11-15 23:41:41 -05:00
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpectrumContext::Draw(std::vector<float> &points) {
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
|
|
|
|
|
if (points.size()) {
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glTranslatef(-1.0f, -0.9f, 0.0f);
|
|
|
|
|
glScalef(2.0f, 1.8f, 1.0f);
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
|
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
2014-12-08 02:16:06 -05:00
|
|
|
|
2014-12-08 19:38:38 -05:00
|
|
|
GLint vp[4];
|
|
|
|
|
|
|
|
|
|
glGetIntegerv( GL_VIEWPORT, vp);
|
|
|
|
|
|
|
|
|
|
std::string msgStr("Welcome to CubicSDR -- This is a test string. 01234567890!@#$%^&*()_[]");
|
|
|
|
|
float charHeight = 62.0;
|
|
|
|
|
float viewAspect = (float)vp[2]/(float)vp[3];
|
|
|
|
|
float msgWidth = getFont()->getStringWidth(msgStr,charHeight/(float)vp[3],viewAspect);
|
|
|
|
|
|
|
|
|
|
getFont()->drawString(msgStr,0.0-(msgWidth/2.0),0.0,charHeight/(float)vp[3],viewAspect);
|
2014-12-08 02:16:06 -05:00
|
|
|
|
2014-11-15 23:41:41 -05:00
|
|
|
CheckGLError();
|
|
|
|
|
}
|