00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifdef FK_D3D
00073 #include "./D3D/Window.h"
00074 #else
00075
00076
00077
00078 #ifndef __FK_WINDOW_HEADER__
00079 #define __FK_WINDOW_HEADER__
00080
00081 #include <stdarg.h>
00082
00083
00084 #include <FL/Fl_Gl_Window.H>
00085 #include <FL/Fl_Multi_Browser.h>
00086
00087
00088 #include <FK/Engine.H>
00089
00090
00092 typedef unsigned int fk_FrameMode;
00093
00094 const fk_FrameMode FK_DEFAULT_FRAME = 0x0000;
00095 const fk_FrameMode FK_WAIT_FRAME = 0x0001;
00096 const fk_FrameMode FK_SKIP_FRAME = 0x0002;
00097
00099 enum fk_SpecialKey {
00100 FK_SHIFT_R,
00101 FK_SHIFT_L,
00102 FK_CTRL_R,
00103 FK_CTRL_L,
00104 FK_ALT_R,
00105 FK_ALT_L,
00106 FK_ENTER,
00107 FK_BACKSPACE,
00108 FK_DELETE,
00109 FK_CAPS_LOCK,
00110 FK_TAB,
00111 FK_PAGE_UP,
00112 FK_PAGE_DOWN,
00113 FK_HOME,
00114 FK_END,
00115 FK_INSERT,
00116 FK_LEFT,
00117 FK_RIGHT,
00118 FK_UP,
00119 FK_DOWN,
00120 FK_F1,
00121 FK_F2,
00122 FK_F3,
00123 FK_F4,
00124 FK_F5,
00125 FK_F6,
00126 FK_F7,
00127 FK_F8,
00128 FK_F9,
00129 FK_F10,
00130 FK_F11,
00131 FK_F12
00132 };
00133
00135 enum fk_MouseButton {
00136 FK_MOUSE1,
00137 FK_MOUSE2,
00138 FK_MOUSE3
00139 };
00140
00142 enum fk_PutStrMode {
00143 FK_PUTSTR_NONE,
00144 FK_PUTSTR_CONSOLE,
00145 FK_PUTSTR_ERR_CONSOLE,
00146 FK_PUTSTR_BROWSER,
00147 FK_PUTSTR_FILE
00148 };
00149
00150
00152
00187 class fk_Window : public Fl_Gl_Window, public fk_BaseObject {
00188
00189 private:
00190
00191 fk_GraphicsEngine engine;
00192
00193 fk_Image snapBuffer;
00194
00195 bool winOpenFlag;
00196 int GLWinWSize;
00197 int GLWinHSize;
00198 int GLWinXPosition;
00199 int GLWinYPosition;
00200 char lastKey;
00201
00202 fk_FrameMode frameMode;
00203 unsigned long frameTime, prevTime;
00204 unsigned long frameInterval;
00205 int skipCount;
00206
00207 static Fl_Window *putWin;
00208 static Fl_Multi_Browser *browser;
00209 static fk_PutStrMode putStrMode;
00210 static FILE *putStrFP;
00211 static int winNum;
00212
00213 void SetPickViewPort(int &, int &);
00214 bool IsInsideWindow(void);
00215 void GetPickData(bool, fk_PickData *, int, int, int);
00216
00217 void draw();
00218
00219 static void PutBrowser(const std::string &);
00220
00221 #ifdef WIN32
00222 bool SnapImageGDI(fk_Image *);
00223 #endif
00224
00225 public:
00226
00228
00235 fk_Window(int x = 0, int y = 0,
00236 int w = 300, int h = 300, std::string name = "FK Window");
00237
00239 ~fk_Window();
00240
00241
00243
00244
00246
00251 void setScene(fk_Scene *scene);
00252
00253
00255
00257
00272 int drawWindow(bool drawFlag = true);
00273
00275
00284 bool winOpenStatus(void);
00285
00287
00295 void resizeWindow(int x, int y, int w, int h);
00296
00298
00331 bool getKeyStatus(char key, bool insideFlag = true);
00332
00334
00369 bool getSpecialKeyStatus(fk_SpecialKey key, bool insideFlag = true);
00370
00372
00390 char getLastKey(void);
00391
00393
00422 void getMousePosition(int *x, int *y, bool insideFlag = true);
00423
00425
00449 bool getMouseStatus(fk_MouseButton button, bool insideFlag = true);
00450
00452
00466 int getMouseWheelStatus(void);
00467
00469
00490 void getPickModel(fk_PickData *data, int pixel);
00491
00493
00514 void getPickModel(fk_PickData *data, int pixel, int x, int y);
00515
00516
00518
00519
00521
00547 void setFrameMode(fk_FrameMode mode);
00548
00550
00557 fk_FrameMode getFrameMode(void);
00558
00560
00576 void setFrameInterval(int ms);
00577
00579
00586 int getFrameInterval(void);
00587
00589
00598 int getSkipFrame(void);
00599
00600
00602
00603
00605
00623 bool getProjectPosition(double x, double y,
00624 fk_Plane *plane, fk_Vector *pos);
00625
00627
00641 bool getProjectPosition(double x, double y,
00642 double dist, fk_Vector *pos);
00643
00645
00661 bool getWindowPosition(fk_Vector pos_3D, fk_Vector *pos_2D);
00662
00663
00665
00667
00685 void setOGLPointerMode(bool mode);
00686
00688
00698 bool getOGLPointerMode(void);
00699
00701
00713 void clearTextureMemory(void);
00714
00716
00726 virtual void preInit(void) {}
00727
00729
00739 virtual void postInit(void) {}
00740
00742
00750 virtual void preDraw(void) {}
00751
00753
00761 virtual void postDraw(void) {}
00762
00763
00765
00766
00768
00784 bool snapImage(std::string fileName,
00785 fk_ImageType format = FK_IMAGE_BMP,
00786 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00787
00789
00802 bool snapImage(fk_Image *image,
00803 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00804
00805
00807
00808
00810
00824 static unsigned long getNow(void);
00825
00826
00828
00829
00831
00855 static void setPutStrMode(const fk_PutStrMode mode);
00856
00858
00865 static fk_PutStrMode getPutStrMode(void);
00866
00868
00886 static bool setPutFile(const std::string &fileName);
00887
00889
00904 static void putString(const std::string &str);
00905
00907
00922 static void printf(const char *format, ...);
00923
00925
00939 static void clearBrowser(void);
00940
00941
00942 #ifndef FK_DOXYGEN_USER_PROCESS
00943
00944 void setOGLTextureBindMode(bool);
00945 bool getOGLTextureBindMode(void);
00946
00947 #endif
00948
00949 };
00950
00951
00952 #endif
00953
00954 #endif