-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathofAppAndroidWindow.h
More file actions
130 lines (95 loc) · 3.3 KB
/
ofAppAndroidWindow.h
File metadata and controls
130 lines (95 loc) · 3.3 KB
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
/*
* ofAppAndroidWindow.h
*
* Created on: 24/05/2010
* Author: arturo
*/
#pragma once
#include "ofAppBaseWindow.h"
#include "ofEvents.h"
#include "ofConstants.h"
#include "ofTypes.h"
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
class ofxAndroidWindowSettings : public ofGLESWindowSettings
{
public:
ofxAndroidWindowSettings()
: preserveContextOnPause( true ){}
ofxAndroidWindowSettings( const ofGLESWindowSettings & settings )
: ofGLESWindowSettings( settings ), preserveContextOnPause( true ) {
const ofxAndroidWindowSettings * androidSettings = dynamic_cast<const ofxAndroidWindowSettings*>(&settings);
if(androidSettings){
preserveContextOnPause = androidSettings->preserveContextOnPause;
}
}
/**
This corresponds to GLSurfaceView.setPreserveEGLContextOnPause.
If this is false, all opengl resources (textures, shaders, ...) will be destroyed when the App is minimized (Activity::onStop).
I would suggest to have this set to 'true' when releasing the App, but try to run it with this set to 'false'
from time to time to make sure that opengl resources reloading works properly.
Use events ofxAndroidEventsClass::unloadGL and ofxAndroidEventsClass::loadGL to track when the opengl context is lost.
*/
void setPreserveContextOnPause(bool preserve){
preserveContextOnPause = preserve;
}
bool preserveContextOnPause = true;
};
class ofAppAndroidWindow: public ofAppBaseGLESWindow {
public:
ofAppAndroidWindow();
ofAppAndroidWindow(ofAppBaseWindow &other);
virtual ~ofAppAndroidWindow();
static bool doesLoop(){ return true; }
static void loop(){ }
static bool needsPolling(){ return false; }
static void pollEvents(){}
static bool allowsMultiWindow(){ return false; }
static bool isSurfaceDestroyed();
using ofAppBaseWindow::setup;
void setup(const ofGLESWindowSettings & settings);
void setup(const ofxAndroidWindowSettings & settings);
void update();
void draw();
void setCurrentWindow();
void hideCursor() {}
void showCursor() {}
void setWindowPosition(int x, int y) {}
void setWindowShape(int w, int h) {}
glm::vec2 getWindowPosition() {return glm::vec2(); }
glm::vec2 getWindowSize();
glm::vec2 getScreenSize(){return getWindowSize(); }
int getWidth();
int getHeight();
bool doesHWOrientation(){return true;}
void setWindowTitle(std::string title){}
ofWindowMode getWindowMode() {return OF_WINDOW;}
void makeCurrent();
void setFullscreen(bool fullscreen);
void toggleFullscreen();
void enableSetupScreen();
void disableSetupScreen();
void setOrientation(ofOrientation orientation);
ofOrientation getOrientation();
void setSampleSize(int samples);
int getSamples();
ofCoreEvents & events();
std::shared_ptr<ofBaseRenderer> & renderer();
void setThreadedEvents(bool threadedEvents);
void setAccumulateTouchEvents(bool accumEvents);
void setMultiWindowMode(bool multiWindowMode);
bool getIsThreadedEvents();
bool getIsAccumulateTouchEvents();
bool getIsMultiWindowMode();
int getGlesVersion();
int getGlesVersionMinor();
AAssetManager& getAssetManager();
void setAssetManager(AAssetManager* assetManager);
int glesVersion;
int glesVersionMinor;
private:
ofCoreEvents coreEvents;
std::shared_ptr<ofBaseRenderer> currentRenderer;
int msaaSamples;
AAssetManager* assetManager = nullptr;
};