/
ofxFenster.h
105 lines (82 loc) · 2.27 KB
/
ofxFenster.h
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
/*
* ofxFenster.h
* ofxFensterExample
*
* Created by Philip Whitfield on 5/19/10.
* Copyright 2010 undef.ch. All rights reserved.
*
*/
#ifndef _CLASS_ofxFenster_
#define _CLASS_ofxFenster_
#include "ofMain.h"
#include "ofAppGlutWindow.h"
//seems code block wont link glut automatically we need to add following include
#include <glut.h>
class ofxFenster;
class ofxFensterEvent{
public:
ofxFenster* fenster;
};
class ofxFensterResizeEvent: public ofxFensterEvent{
public:
int w;
int h;
};
class ofxFensterEventsStruct{
public:
ofEvent<ofxFensterEvent> draw;
ofEvent<ofxFensterEvent> update;
ofEvent<ofxFensterResizeEvent> resize;
};
extern ofxFensterEventsStruct ofxFensterEvents;
class ofxFensterListener{
public:
virtual void fensterUpdate(){}
virtual void fensterDraw(){ofGetAppPtr()->draw();};
virtual void fensterKeyPressed (int key){ofGetAppPtr()->keyPressed(key);};
virtual void fensterKeyReleased(int key){ofGetAppPtr()->keyReleased(key);};
virtual void fensterMouseMoved(int x, int y ){ofGetAppPtr()->mouseMoved(x, y);};
virtual void fensterMouseDragged(int x, int y, int button){ofGetAppPtr()->mouseDragged(x, y, button);};
virtual void fensterMousePressed(int x, int y, int button){ofGetAppPtr()->mousePressed(x, y, button);};
virtual void fensterMouseReleased(int x, int y, int button){ofGetAppPtr()->mouseReleased(x, y, button);};
virtual void fensterWindowResized(int w, int h){};
ofxFenster* fenster;
};
class ofxFenster: public ofRectangle{
public:
ofxFenster();
~ofxFenster();
void init(ofxFensterListener* l, string title=""); //open the window
void update();
void draw(bool force=false);
void setFPS(int fps);
void setFPS(int fpsU, int fpsD);
void toContext();
void toMainContext();
ofRectangle getBounds();
void setBounds(ofRectangle r);
void setBounds(int x, int y, int w, int h);
void toggleFullscreen();
void setBackground(int r, int g, int b, int a=255);
ofxFensterListener* listener;
int getX();
int getY();
int getWidth();
int getHeight();
protected:
private:
void update(ofEventArgs &e);
void draw(ofEventArgs &e);
int fpsUpdate;
int fpsDraw;
int winRef;
int mainWinRef;
int nextRender();
int nextWinUpdate;
int nextWinDraw;
bool hasGlut;
bool isFullscreen;
int mainContextSkip;
ofRectangle origSize;
};
#endif