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 bool stereoMode;
00208
00209 static Fl_Window *putWin;
00210 static Fl_Multi_Browser *browser;
00211 static fk_PutStrMode putStrMode;
00212 static FILE *putStrFP;
00213 static int winNum;
00214
00215 void SetPickViewPort(int &, int &);
00216 bool IsInsideWindow(void);
00217 void GetPickData(bool, fk_PickData *, int, int, int);
00218
00219 void draw();
00220
00221 static void PutBrowser(const std::string &);
00222
00223 #ifdef WIN32
00224 bool SnapImageGDI(fk_Image *);
00225 #endif
00226
00227 public:
00228
00230
00237 fk_Window(int x = 0, int y = 0,
00238 int w = 300, int h = 300, std::string name = "FK Window");
00239
00241 ~fk_Window();
00242
00243
00245
00246
00248
00253 void setScene(fk_Scene *scene);
00254
00255
00257
00259
00274 int drawWindow(bool drawFlag = true);
00275
00277
00286 bool winOpenStatus(void);
00287
00289
00297 void resizeWindow(int x, int y, int w, int h);
00298
00300
00333 bool getKeyStatus(char key, bool insideFlag = true);
00334
00336
00371 bool getSpecialKeyStatus(fk_SpecialKey key, bool insideFlag = true);
00372
00374
00392 char getLastKey(void);
00393
00395
00424 void getMousePosition(int *x, int *y, bool insideFlag = true);
00425
00427
00451 bool getMouseStatus(fk_MouseButton button, bool insideFlag = true);
00452
00454
00468 int getMouseWheelStatus(void);
00469
00471
00492 void getPickModel(fk_PickData *data, int pixel);
00493
00495
00516 void getPickModel(fk_PickData *data, int pixel, int x, int y);
00517
00518
00520
00521
00523
00549 void setFrameMode(fk_FrameMode mode);
00550
00552
00559 fk_FrameMode getFrameMode(void);
00560
00562
00578 void setFrameInterval(int ms);
00579
00581
00588 int getFrameInterval(void);
00589
00591
00600 int getSkipFrame(void);
00601
00602
00604
00605
00607
00625 bool getProjectPosition(double x, double y,
00626 fk_Plane *plane, fk_Vector *pos);
00627
00629
00643 bool getProjectPosition(double x, double y,
00644 double dist, fk_Vector *pos);
00645
00647
00663 bool getWindowPosition(fk_Vector pos_3D, fk_Vector *pos_2D);
00664
00665
00667
00669
00687 void setOGLPointerMode(bool mode);
00688
00690
00700 bool getOGLPointerMode(void);
00701
00703
00715 void clearTextureMemory(void);
00716
00718
00728 virtual void preInit(void) {}
00729
00731
00741 virtual void postInit(void) {}
00742
00744
00752 virtual void preDraw(void) {}
00753
00755
00763 virtual void postDraw(void) {}
00764
00765
00767
00768
00770
00786 bool snapImage(std::string fileName,
00787 fk_ImageType format = FK_IMAGE_BMP,
00788 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00789
00791
00804 bool snapImage(fk_Image *image,
00805 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00806
00807
00809
00810
00812
00826 static unsigned long getNow(void);
00827
00828
00830
00831
00833
00857 static void setPutStrMode(const fk_PutStrMode mode);
00858
00860
00867 static fk_PutStrMode getPutStrMode(void);
00868
00870
00888 static bool setPutFile(const std::string &fileName);
00889
00891
00906 static void putString(const std::string &str);
00907
00909
00924 static void printf(const char *format, ...);
00925
00927
00941 static void clearBrowser(void);
00942
00943
00945
00947
00967 void setOGLStereoMode(bool mode);
00968
00970
00979 bool getOGLStereoMode(void);
00980
00981
00982 #ifndef FK_DOXYGEN_USER_PROCESS
00983
00984 void setOGLTextureBindMode(bool);
00985 bool getOGLTextureBindMode(void);
00986
00987 #endif
00988
00989 };
00990
00991
00992 #endif
00993
00994 #endif