1 /* 2 * Copyright 2008 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 */ 6 7 /* 8 Copyright 1999, Be Incorporated. All Rights Reserved. 9 This file may be used under the terms of the Be Sample Code License. 10 */ 11 12 #ifndef OBJECT_VIEW_H 13 #define OBJECT_VIEW_H 14 15 #include <GL/glu.h> 16 #include <GLView.h> 17 18 #define kMsgFPS 'fps ' 19 #define kMsgLimitFps 'lfps' 20 #define kMsgAddModel 'addm' 21 #define kMsgGouraud 'gour' 22 #define kMsgZBuffer 'zbuf' 23 #define kMsgCulling 'cull' 24 #define kMsgTextured 'txtr' 25 #define kMsgFog 'fog ' 26 #define kMsgLighting 'lite' 27 #define kMsgLights 'lits' 28 #define kMsgFilled 'fill' 29 #define kMsgPerspective 'prsp' 30 31 enum lights { 32 lightNone = 0, 33 lightWhite, 34 lightYellow, 35 lightRed, 36 lightBlue, 37 lightGreen 38 }; 39 40 #define HISTSIZE 10 41 42 class ResScroll; 43 class GLObject; 44 45 struct TrackingInfo { 46 float lastX; 47 float lastY; 48 float lastDx; 49 float lastDy; 50 bool isTracking; 51 GLObject *pickedObject; 52 uint32 buttons; 53 }; 54 55 class ObjectView : public BGLView { 56 public: 57 ObjectView(BRect rect, const char* name, 58 ulong resizingMode, ulong options); 59 ~ObjectView(); 60 61 virtual void MouseDown(BPoint point); 62 virtual void MouseUp(BPoint point); 63 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg); 64 65 virtual void MessageReceived(BMessage* msg); 66 virtual void AttachedToWindow(); 67 virtual void DetachedFromWindow(); 68 virtual void FrameResized(float width, float height); 69 bool SpinIt(); LimitFps()70 bool LimitFps() { return fLimitFps; }; 71 int ObjectAtPoint(const BPoint &point); 72 virtual void DrawFrame(bool noPause); 73 virtual void Pulse(); 74 void EnforceState(); 75 bool RepositionView(); 76 77 sem_id drawEvent; 78 sem_id quittingSem; 79 80 private: 81 thread_id fDrawThread; 82 ResScroll* fResScroll; 83 BList fObjects; 84 BLocker fObjListLock; 85 uint64 fLastFrame; 86 int32 fHistEntries,fOldestEntry; 87 bool fFps, fLimitFps, fLastGouraud, fGouraud; 88 bool fLastZbuf, fZbuf, fLastCulling, fCulling; 89 bool fLastLighting, fLighting, fLastFilled, fFilled; 90 bool fLastPersp, fPersp, fLastTextured, fTextured; 91 bool fLastFog, fFog, fForceRedraw; 92 float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE]; 93 float fObjectDistance, fLastObjectDistance; 94 TrackingInfo fTrackingInfo; 95 }; 96 97 #endif // OBJECT_VIEW_H 98