13 OpenGLGraphics::OpenGLGraphics() :
15 ApplicationBGColor(0, 0, 0)
18 OpenGLGraphics::~OpenGLGraphics() {
22 void OpenGLGraphics::SetOpenGLBackGroundColor() {
23 unsigned long bgColor;
24 XtVaGetValues(
RNA3D->
glw, XmNbackground, &bgColor,
NULp);
29 xcolor.pixel = bgColor;
30 Colormap colormap = DefaultColormapOfScreen(XtScreen(w));
31 XQueryColor(XtDisplay(w), colormap, &xcolor);
33 float r = xcolor.red / 65535.0;
34 float g = xcolor.green / 65535.0;
35 float b = xcolor.blue / 65535.0;
38 glClearColor(r, g, b, 1);
44 ColorRGBf OpenGLGraphics::ConvertGCtoRGB(
int gc) {
50 XGetGCValues(XtDisplay(w), xgc, GCForeground, &xGCValues);
51 unsigned long color = xGCValues.foreground;
56 Colormap colormap = DefaultColormapOfScreen(XtScreen(w));
57 XQueryColor(XtDisplay(w), colormap, &xcolor);
59 float r = xcolor.red / 65535.0;
60 float g = xcolor.green / 65535.0;
61 float b = xcolor.blue / 65535.0;
68 void OpenGLGraphics::SetColor(
int gc) {
74 ColorRGBf OpenGLGraphics::GetColor(
int gc) {
82 GLdouble modelMatrix[16];
83 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
84 GLdouble projMatrix[16];
85 glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
87 glGetIntegerv(GL_VIEWPORT, viewport);
93 &screenPos[0], &screenPos[1], &screenPos[2]
101 void OpenGLGraphics::init_font(GLuint base,
char* f) {
103 XFontStruct* font_info;
108 display = glXGetCurrentDisplay();
110 fprintf(stderr,
"XOpenDisplay() failed. Exiting.\n");
115 font_info = XLoadQueryFont(display, f);
117 fprintf(stderr,
"XLoadQueryFont() failed - Exiting.\n");
122 first = font_info->min_char_or_byte2;
123 last = font_info->max_char_or_byte2;
124 glXUseXFont(font_info->fid, first, last-first+1, base+first);
130 void OpenGLGraphics::print_string(GLuint base,
char*
s) {
131 if (!glIsList(font_base)) {
132 fprintf(stderr,
"print_string(): Bad display list. - Exiting.\n");
135 else if (s && strlen(s)) {
136 glPushAttrib(GL_LIST_BIT);
138 glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *)s);
143 void OpenGLGraphics::InitMainFont(
char* f) {
144 font_base = glGenLists(256);
145 if (!glIsList(font_base)) {
146 fprintf(stderr,
"InitMainFont(): Out of display lists. - Exiting.\n");
150 init_font(font_base, f);
154 void OpenGLGraphics::PrintString(
float x,
float y,
float z,
char *s,
void * ) {
155 glRasterPos3f(x, y, z);
156 print_string(font_base, s);
159 void OpenGLGraphics::DrawBox(
float x,
float y,
float w,
float h) {
161 glVertex2f(x-w/2, y-h/2);
162 glVertex2f(x+w/2, y-h/2);
163 glVertex2f(x+w/2, y+h/2);
164 glVertex2f(x-w/2, y+h/2);
Widget AW_get_AreaWidget(AW_window *aww, AW_area area)
GC AW_map_AreaGC(AW_window *aww, AW_area area, int gc)
void WinToScreenCoordinates(int x, int y, GLdouble *screenPos)
struct _WidgetRec * Widget
GB_write_int const char s