1145519Sdarrenr/*
2145510Sdarrenr * Copyright 2008 Haiku Inc. All rights reserved.
3145510Sdarrenr * Distributed under the terms of the MIT License.
4255332Scy *
5145510Sdarrenr */
6145510Sdarrenr
7145510Sdarrenr/*
8255332Scy	Copyright 1999, Be Incorporated.   All Rights Reserved.
9145510Sdarrenr	This file may be used under the terms of the Be Sample Code License.
10145510Sdarrenr*/
11145510Sdarrenr
12145510Sdarrenr#ifndef OBJECT_VIEW_H
13145510Sdarrenr#define OBJECT_VIEW_H
14255332Scy
15255332Scy#include <GL/glu.h>
16145510Sdarrenr#include <GLView.h>
17145510Sdarrenr
18145510Sdarrenr#define kMsgFPS			'fps '
19145510Sdarrenr#define kMsgAddModel	'addm'
20145510Sdarrenr#define kMsgGouraud		'gour'
21145510Sdarrenr#define kMsgZBuffer		'zbuf'
22145510Sdarrenr#define kMsgCulling		'cull'
23145510Sdarrenr#define kMsgTextured	'txtr'
24145510Sdarrenr#define kMsgFog			'fog '
25145510Sdarrenr#define kMsgLighting	'lite'
26145510Sdarrenr#define kMsgLights		'lits'
27145510Sdarrenr#define kMsgFilled		'fill'
28161357Sguido#define kMsgPerspective	'prsp'
29161357Sguido
30161357Sguidoenum lights {
31161357Sguido	lightNone = 0,
32145510Sdarrenr	lightWhite,
33145510Sdarrenr	lightYellow,
34145510Sdarrenr	lightRed,
35145510Sdarrenr	lightBlue,
36145510Sdarrenr	lightGreen
37145510Sdarrenr};
38145510Sdarrenr
39145510Sdarrenr#define HISTSIZE 10
40145510Sdarrenr
41145510Sdarrenrclass ResScroll;
42145510Sdarrenrclass GLObject;
43145510Sdarrenr
44145510Sdarrenrstruct TrackingInfo {
45145510Sdarrenr	float		lastX;
46145510Sdarrenr	float		lastY;
47145510Sdarrenr	float		lastDx;
48145510Sdarrenr	float		lastDy;
49145510Sdarrenr	bool		isTracking;
50145510Sdarrenr	GLObject	*pickedObject;
51145510Sdarrenr	uint32		buttons;
52145510Sdarrenr};
53145510Sdarrenr
54145510Sdarrenrclass ObjectView : public BGLView {
55145510Sdarrenr	public:
56145510Sdarrenr						ObjectView(BRect rect, const char* name,
57145510Sdarrenr							ulong resizingMode, ulong options);
58145510Sdarrenr						~ObjectView();
59145510Sdarrenr
60145510Sdarrenr		virtual	void	MouseDown(BPoint point);
61145510Sdarrenr		virtual	void	MouseUp(BPoint point);
62145510Sdarrenr		virtual	void	MouseMoved(BPoint point, uint32 transit, const BMessage *msg);
63145510Sdarrenr
64145510Sdarrenr		virtual	void	MessageReceived(BMessage* msg);
65145510Sdarrenr		virtual	void	AttachedToWindow();
66145510Sdarrenr		virtual	void	DetachedFromWindow();
67145510Sdarrenr		virtual	void	FrameResized(float width, float height);
68145510Sdarrenr				bool	SpinIt();
69145510Sdarrenr				int		ObjectAtPoint(const BPoint &point);
70145510Sdarrenr		virtual	void	DrawFrame(bool noPause);
71145510Sdarrenr		virtual	void	Pulse();
72145510Sdarrenr				void	EnforceState();
73145510Sdarrenr				bool	RepositionView();
74145510Sdarrenr
75145510Sdarrenr		sem_id			drawEvent;
76145510Sdarrenr		sem_id			quittingSem;
77145510Sdarrenr
78145510Sdarrenr	private:
79145510Sdarrenr		thread_id		fDrawThread;
80145510Sdarrenr		ResScroll*		fResScroll;
81145510Sdarrenr		BList			fObjects;
82145510Sdarrenr		BLocker			fObjListLock;
83145510Sdarrenr		uint64			fLastFrame;
84		int32			fHistEntries,fOldestEntry;
85		bool			fFps, fLastGouraud, fGouraud;
86		bool			fLastZbuf, fZbuf, fLastCulling, fCulling;
87		bool			fLastLighting, fLighting, fLastFilled, fFilled;
88		bool			fLastPersp, fPersp, fLastTextured, fTextured;
89		bool			fLastFog, fFog, fForceRedraw;
90		float			fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE];
91		float			fObjectDistance, fLastObjectDistance;
92		TrackingInfo	fTrackingInfo;
93};
94
95#endif // OBJECT_VIEW_H
96