aboutsummaryrefslogtreecommitdiff
path: root/externals/gridflow/bundled/Base/GemBase.h
blob: a5ae3d1ef2548f1e4b64daa8573ea0db64b88482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*-----------------------------------------------------------------
  LOG
  GEM - Graphics Environment for Multimedia

  The base class for all of the gem objects

  Copyright (c) 1997-1999 Mark Danks. mark@danks.org
  Copyright (c) Günther Geiger.
  Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM
  For information on usage and redistribution, and for a DISCLAIMER OF ALL
  WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
	
  -----------------------------------------------------------------*/

#ifndef INCLUDE_GEMBASE_H_
#define INCLUDE_GEMBASE_H_

#include "Base/GemGL.h"

#include "Base/CPPExtern.h"
#include "Base/GemState.h"

class GemCache;

/*-----------------------------------------------------------------
  -------------------------------------------------------------------
  CLASS
  GemBase
    
  Base class for gem objects

  DESCRIPTION
    
  -----------------------------------------------------------------*/
class GEM_EXTERN GemBase : public CPPExtern
{
 protected:
    	
  //////////
  // Constructor
  GemBase();
    	
  //////////
  // Destructor
  virtual     	~GemBase();

  //////////
  virtual void 	render(GemState *state) = 0;

  //////////
  void    continueRender(GemState *state);

  //////////
  // After objects below you in the chain have finished.
  // You should reset all GEM/OpenGL states here.
  virtual void 	postrender(GemState *)              { ; }

  //////////
  // Called when rendering stops

#if 1/*(jmz) this seems to be for gem2pdp*/
  virtual void 	stoprender()			{ realStopRendering(); }
#endif

  //////////
  // If you care about the start of rendering
  virtual void	startRendering()                    { ; }

  //////////
  // If you care about the stop of rendering
  virtual void	stopRendering()    	                { ; }


  //////////
  // has rendering started ?
  bool            gem_amRendering;
    	
  //////////
  // If anything in the object has changed
  virtual void  	setModified();

  //////////
  // Don't mess with this unless you know what you are doing.
  GemCache    	*m_cache;
  //////////
  // check whether this object has changed
  bool             m_modified;

  //////////
  // The outlet
  t_outlet    	*m_out1;


  //////////
  // this gets called in the before the startRendering() routine
  // if it returns TRUE, the object's startRendering(), render() and stopRendering() functions will be called
  // it it returns FALSE, the object will be disabled 
  // when rendering is restarted, this function get's called again
  // the default is to enable rendering
  // this function is important if you want to disable an object because it cannot be used (e.g. missing driver support)
  virtual bool isRunnable(void);

  //////////
  // creation callback
  static void 	real_obj_setupCallback(t_class *classPtr)
    { CPPExtern::real_obj_setupCallback(classPtr); GemBase::obj_setupCallback(classPtr); }

    	
 private:
    
  void	    	realStopRendering();
  void            gem_startstopMess(int state);
  void            gem_renderMess(GemCache* state, GemState* state2);
  	    	
  static inline GemBase *GetMyClass(void *data) {return((GemBase *)((Obj_header *)data)->data);}

  friend class    gemhead;
  static void 	obj_setupCallback(t_class *classPtr);
  static void 	gem_MessCallback(void *, t_symbol *,int, t_atom*);
  static void 	renderCallback(GemBase *data, GemState *state);
  static void 	postrenderCallback(GemBase *data, GemState *state);
#if 1 /*jmz this seems to be for gem2pdp*/
  static void	stoprenderCallback(GemBase *data);	//DH
#endif

  /* whether the object is internally disabled or not 
   * objects are to be disabled, if the system cannot make use of them, e.g. because of unsupported openGL features
   */
  bool  m_enabled;

};

#endif	// for header file