#ifndef _INCLUDED_L3_OPGL_H #define _INCLUDED_L3_OPGL_H // *OpenGL and Mesa/GLUT Interface* Copyright (C) Krzysztof Bosak 1999-10-13...2000-01-08 // All rights reserved. // kbosak@box43.pl // http://www.kbosak.prv.pl #ifdef WIN32 #include #include #include #include #else #include #include #include #define CALLBACK #endif #include #include #include #include "l3_array.h" #include "l3_tool.h" #include "l3_str.h" static int _xmax; static int _ymax; static unsigned char rasters[256][13]={ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36}, {0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xff, 0x66, 0x66, 0x00, 0x00}, {0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f, 0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18}, {0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30, 0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70}, {0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70, 0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e}, {0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c}, {0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30}, {0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c, 0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00}, {0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03}, {0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c}, {0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x38, 0x18}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e}, {0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e}, {0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c}, {0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x03, 0x03, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e}, {0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03, 0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e}, {0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06}, {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60}, {0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e}, {0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3, 0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, {0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e}, {0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, {0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3}, {0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e}, {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, {0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff}, {0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c}, {0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x30, 0x30, 0x60, 0x60}, {0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18}, {0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x70}, {0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, {0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x03, 0x03, 0x03, 0x03, 0x03}, {0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e}, {0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0}, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00}, {0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00}, {0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0}, {0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78}, {0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00}, {0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00}, {0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x00}, {0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00}, {0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38, 0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f}, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}, {0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c, 0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00} }; void GFastestHints() { ::glHint(GL_FOG_HINT, GL_FASTEST); ::glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); ::glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); ::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST); ::glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); ::glShadeModel(GL_FLAT); } void GNicestHints() { ::glHint(GL_FOG_HINT, GL_NICEST); ::glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); ::glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); ::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); ::glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); ::glShadeModel(GL_SMOOTH); } void GSmoothOn() { ::glEnable(GL_LINE_SMOOTH); ::glEnable(GL_BLEND); ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ::glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); } void GSmoothOff() { ::glDisable(GL_LINE_SMOOTH); ::glDisable(GL_BLEND); } void GMessageBox(const TextString& text, const TextString& title) {//xxx not ported #ifdef WIN32 ::MessageBox(0, text.c_str(), title.c_str(), MB_ICONINFORMATION|MB_OK|MB_APPLMODAL); #endif } int GMaxx() {// xxx not ported #ifdef WIN32 return ::GetSystemMetrics(SM_CXSCREEN); #else return 1024; #endif } int GMaxy() {// xxx not ported #ifdef WIN32 return ::GetSystemMetrics(SM_CYSCREEN); #else return 768; #endif } void CALLBACK GCopyToClipboard(void (*func)()) {//xxx not ported #ifdef WIN32 WINDOWPLACEMENT place; place.length=sizeof(WINDOWPLACEMENT); ::GetWindowPlacement(::auxGetHWND(), &place); const RECT oldrect=place.rcNormalPosition; bool move=false; if(func!=NULL) { RECT rect=oldrect; if(rect.left<0) { rect.right-=rect.left; rect.left=0; move=true; } if(rect.top<0) { rect.bottom-=rect.top; rect.top=0; move=true; } if(rect.right>GMaxx()) { const int diff=rect.right-GMaxx(); rect.right-=diff; rect.left-=diff; move=true; } if(rect.bottom>GMaxy()) { const int diff=rect.bottom-GMaxy(); rect.bottom-=diff; rect.top-=diff; move=true; } if(move==true) { place.rcNormalPosition=rect; ::SetWindowPlacement(::auxGetHWND(), &place); func(); } } const HDC hdcdest=::CreateCompatibleDC(::auxGetHDC()); if(hdcdest==NULL) return;// false; const HBITMAP hbitmap=::CreateCompatibleBitmap(::auxGetHDC(), _xmax, _ymax); if(hbitmap==NULL) return;// false; const HBITMAP old_hbitmap=static_cast(::SelectObject(hdcdest, hbitmap)); if(old_hbitmap==NULL) return;// false; if(::BitBlt(hdcdest, 0, 0, _xmax, _ymax, ::auxGetHDC(), 0, 0, SRCCOPY)==FALSE) return;// false; ::SelectObject(hdcdest, old_hbitmap); ::DeleteObject(hbitmap); ::DeleteDC(hdcdest); if(move==true) { place.rcNormalPosition=oldrect; ::SetWindowPlacement(::auxGetHWND(), &place); } if(::OpenClipboard(::auxGetHWND())==FALSE) return;// false; if(::EmptyClipboard()==FALSE) return;// false; if(::SetClipboardData(CF_BITMAP, hbitmap)==NULL) return;// false; if(::CloseClipboard()==TRUE) { ::MessageBeep(MB_ICONASTERISK);//OK return;// true; } #endif return;// false; } void CALLBACK GCopyToClipboardVoid() { GCopyToClipboard(NULL); } void GCaption(const TextString& captext) {//xxx not ported #ifdef WIN32 ::SendMessage(::auxGetHWND(), WM_SETTEXT, WPARAM(captext.c_str()), LPARAM(captext.c_str())); #endif } void GBrowse(const TextString& url) { #ifdef WIN32 if(url.length()<64) { ::ShellExecute(0, "open", url.c_str(), 0, 0, SW_SHOWNORMAL); } #else const int lenurl=url.length(); basearray run(lenurl+64); strncpy(&run[0], "./web-browser-caller ", lenurl+63); run.back()='\0'; strncpy(&run[lenurl], url.c_str(), 63); run.back()='\0'; system(&run[0]); #endif } void GDraw(double x1, double y1, double x2, double y2) { ::glBegin(GL_LINES); ::glVertex2d(x1, y1); ::glVertex2d(x2, y2); ::glEnd(); } void GFrame(double x1, double y1, double x2, double y2) { ::glBegin(GL_LINE_LOOP); ::glVertex2d(x1, y1); ::glVertex2d(x2, y1); ::glVertex2d(x2, y2); ::glVertex2d(x1, y2); ::glEnd(); } void GBox(double x1, double y1, double x2, double y2) { ::glBegin(GL_QUADS); ::glVertex2d(x1, y1); ::glVertex2d(x2, y1); ::glVertex2d(x2, y2); ::glVertex2d(x1, y2); ::glEnd(); } void GDisk(double x1, double y1, double r) { ::glBegin(GL_POLYGON); for(double ang=0; ang<7; ang+=.1) { ::glVertex2d(x1+r*sin(ang), y1+r*cos(ang)); } ::glEnd(); } void GPlot(double x1, double y1) { ::glBegin(GL_POINTS); ::glVertex2d(x1, y1); ::glEnd(); } void GArrow(double xstart, double ystart) { ::glBegin(GL_LINES); ::glVertex2d(xstart+3, ystart+3); ::glVertex2d(xstart+5, ystart+8); ::glVertex2d(xstart+3, ystart+3); ::glVertex2d(xstart+15, ystart+15); ::glVertex2d(xstart+3, ystart+3); ::glVertex2d(xstart+8, ystart+5); ::glEnd(); } void GArrowRel(double xstart, double ystart, double dx, double dy, double len=0) { if(len==0) len=sqrt(dx*dx+dy*dy); ::glBegin(GL_LINES); ::glVertex2d(xstart, ystart); const double xend=xstart+dx; const double yend=ystart+dy; ::glVertex2d(xend, yend); double ang=atan2(dy, dx)+_PI+.2; ::glVertex2d(xend, yend); ::glVertex2d(xend+len*cos(ang), yend+len*sin(ang)); ang-=.4; ::glVertex2d(xend, yend); ::glVertex2d(xend+len*cos(ang), yend+len*sin(ang)); ::glEnd(); } inline void GArrow(double xstart, double ystart, double ang, double len, double len2) { GArrowRel(xstart, ystart, len*cos(ang), len*sin(ang), len2); } void _ADJUSTFONT() { int i; memcpy(rasters['0'-32], rasters['O'-32], 13*sizeof(unsigned char));// O --> zer0 memcpy(rasters[185-32], rasters['a'-32], 13*sizeof(unsigned char)); for(i=10; i<13; i++) rasters[185-32][i-10]|=(rasters['\''-32][i]>>1); memcpy(rasters[230-32], rasters['c'-32], 13*sizeof(unsigned char)); for(i=0; i<13; i++) rasters[230-32][i]|=rasters['\''-32][i]; memcpy(rasters[234-32], rasters['e'-32], 13*sizeof(unsigned char)); for(i=10; i<13; i++) rasters[234-32][i-10]|=(rasters['\''-32][i]>>1); memcpy(rasters[179-32], rasters['l'-32], 13*sizeof(unsigned char)); for(i=2; i<10; i++) rasters[179-32][i+2]|=rasters['/'-32][i]; memcpy(rasters[241-32], rasters['n'-32], 13*sizeof(unsigned char)); for(i=0; i<13; i++) rasters[241-32][i]|=rasters['\''-32][i]; memcpy(rasters[243-32], rasters['o'-32], 13*sizeof(unsigned char)); for(i=0; i<13; i++) rasters[243-32][i]|=rasters['\''-32][i]; memcpy(rasters[156-32], rasters['s'-32], 13*sizeof(unsigned char)); for(i=0; i<13; i++) rasters[156-32][i]|=rasters['\''-32][i]; for(i=0; i<13; i++) rasters[156-32][i]|=rasters['\''-32][i]; memcpy(rasters[159-32], rasters['z'-32], 13*sizeof(unsigned char)); for(i=0; i<13; i++) rasters[159-32][i]|=rasters['\''-32][i]; memcpy(rasters[191-32], rasters['z'-32], 13*sizeof(unsigned char)); memcpy(rasters[165-32], rasters['A'-32], 13*sizeof(unsigned char)); for(i=10; i<13; i++) rasters[165-32][i-10]|=(rasters['\''-32][i]>>1); memcpy(rasters[198-32], rasters['C'-32], 13*sizeof(unsigned char)); memcpy(rasters[202-32], rasters['E'-32], 13*sizeof(unsigned char)); for(i=10; i<13; i++) rasters[202-32][i-10]|=(rasters['\''-32][i]>>1); memcpy(rasters[163-32], rasters['L'-32], 13*sizeof(unsigned char)); for(i=2; i<10; i++) rasters[163-32][i+2]|=rasters['/'-32][i]; memcpy(rasters[209-32], rasters['N'-32], 13*sizeof(unsigned char)); memcpy(rasters[211-32], rasters['O'-32], 13*sizeof(unsigned char)); memcpy(rasters[140-32], rasters['S'-32], 13*sizeof(unsigned char)); memcpy(rasters[143-32], rasters['Z'-32], 13*sizeof(unsigned char)); memcpy(rasters[175-32], rasters['Z'-32], 13*sizeof(unsigned char)); memcpy(rasters[250-32], rasters['e'-32], 13*sizeof(unsigned char));//e accent aigu == oct 372 for(i=0; i<13; i++) rasters[250-32][i]|=rasters['\''-32][i]; memcpy(rasters[251-32], rasters['e'-32], 13*sizeof(unsigned char));//e accent grave == oct 373 for(i=0; i<13; i++) rasters[251-32][i]|=rasters['`'-32][i]; } void GText(double x, double y, const TextString& s) { ::glRasterPos2d(x, y); static int fontOffset=0; if(fontOffset==0) { _ADJUSTFONT(); ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); fontOffset=::glGenLists(256); assert(fontOffset!=0); for(int k=32; k<256; k++) { ::glNewList(k+fontOffset, GL_COMPILE); ::glBitmap(8, 13, 0, 2, 9, 0, rasters[k-32]); ::glEndList(); } } ::glPushAttrib(GL_LIST_BIT); ::glListBase(fontOffset); ::glCallLists(s.length(), GL_UNSIGNED_BYTE, const_cast(s.c_str())); ::glPopAttrib(); } void GNumber(double x, double y, double n) { char number[50]; number[49]='\0'; sprintf(&number[0], "%g", n); assert(number[49]=='\0'); number[49]='\0'; GText(x, y, &number[0]); } void GNumber(double x, double y, long double n) { char number[50]; number[49]='\0'; sprintf(&number[0], "%g", static_cast(n)); assert(number[49]=='\0'); number[49]='\0'; GText(x, y, &number[0]); } void GNumber(double x, double y, int n) { char number[50]; number[49]='\0'; sprintf(&number[0], "%d", n); assert(number[49]=='\0'); number[49]='\0'; GText(x, y, &number[0]); } void CALLBACK GIdle() { } void CALLBACK GReshape(int w, int h) { if(h<=0 || w<=0) { return; } _xmax=w; _ymax=h; ::glViewport(0, 0, w, h); ::glMatrixMode(GL_PROJECTION); ::glLoadIdentity(); const double depth=(h<=w ? h : w); ::glOrtho(0, w, 0, h, -depth, depth); ::glMatrixMode(GL_MODELVIEW); ::glLoadIdentity(); } bool _GDBL=false; void GUpdateScreen() { ::glFlush(); if(_GDBL==true) { #ifdef WIN32 ::auxSwapBuffers(); #else ::glutSwapBuffers(); #endif } } void GOpenWindow(const TextString& initcaption, bool dbl) { _GDBL=dbl; int x1=0; int x2=_xmax; int y1=0; int y2=_ymax; PCenter(0, x1, x2, GMaxx()); PCenter(0, y1, y2, GMaxy()); #ifdef WIN32 ::auxInitPosition(x1, y1, _xmax, _ymax); if(_GDBL==true) ::auxInitDisplayMode(AUX_DOUBLE| AUX_RGB); else ::auxInitDisplayMode(AUX_SINGLE| AUX_RGB); ::auxInitWindow(initcaption.c_str()); #else ::glutInitWindowSize(_xmax, _ymax); ::glutInitWindowPosition(x1, x2); if(_GDBL==true) ::glutInitDisplayMode(GLUT_DOUBLE); else ::glutInitDisplayMode(GLUT_SINGLE); ::glutCreateWindow(initcaption.c_str()); #endif } void GReshapeFunc(void CALLBACK func(int, int)) { #ifdef WIN32 ::auxReshapeFunc(func); #else ::glutReshapeFunc(func); #endif } void GIdleFunc(void CALLBACK func()) { #ifdef WIN32 ::auxIdleFunc(func); #else ::glutIdleFunc(func); #endif } #ifdef WIN32 void GMainLoop(void CALLBACK func()) { ::auxMainLoop(func); } #else void(*_GDISPLAYFUNC)()=NULL; void GMainLoop(void (*func)()) { _GDISPLAYFUNC=func; ::glutDisplayFunc(func); ::glutMainLoop(); } #endif #ifndef WIN32 int _GKEYS=0; basearray _GKEY(256); basearray _GKEYFUNC(256); void GKeyboard(unsigned char key, int mousex, int mousey) { /* GNumber(100, 40, a); GNumber(100, 20, b); GNumber(56, 67, key); GUpdateScreen();*/ for(int i=0; i<_GKEYS; i++) { if(key==_GKEY[i]) { _GKEYFUNC[i](); #ifndef WIN32 _GDISPLAYFUNC(); #endif return; } } } #endif bool GShiftOn() { #ifdef WIN32 return ::GetAsyncKeyState(VK_SHIFT)<0; #else return ::glutGetModifiers()&GLUT_ACTIVE_SHIFT; #endif } void GKeyFunc(char key, void CALLBACK func()) { // GNumber(100, 100, GShiftOn()); // GUpdateScreen(); #ifdef WIN32 ::auxKeyFunc(key, func); #else static bool set=false; if(set==false) { ::glutKeyboardFunc(GKeyboard); set=true; } assert(_GKEYS<250); if(_GKEYS<250) { _GKEY[_GKEYS]=key; _GKEYFUNC[_GKEYS]=func; _GKEYS++; } #endif } #ifndef WIN32 unsigned char _GSPECIALS=0; int _GSPECIAL[256]; typedef void CALLBACK callfunc(); callfunc *_GSPECIALFUNC[256]; void GSpecialKey(int speckey, int mousex, int mousey) { /* GNumber(100, 40, mousex); GNumber(100, 20, mousey); GNumber(56, 67, speckey); GUpdateScreen();*/ for(unsigned char i=0; i<_GSPECIALS; i++) { if(speckey==_GSPECIAL[i]) { _GSPECIALFUNC[i](); return; } } } #endif #ifndef WIN32 void GSpecialKeyFunc(int speckey, void CALLBACK func()) { static bool set=false; if(set==false) { ::glutSpecialFunc(GSpecialKey); set=true; } assert(_GSPECIALS<250); if(_GSPECIALS<250) { _GSPECIAL[_GSPECIALS]=speckey; _GSPECIALFUNC[_GSPECIALS]=func; _GSPECIALS++; } } #endif #endif // _INCLUDED_L3_OPGL_H