CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/android/jni/AndroidJavaGLContext.cpp
Views: 1401
1
#include "AndroidJavaGLContext.h"
2
#include "Common/System/Display.h"
3
#include "Common/GPU/OpenGL/GLFeatures.h"
4
#include "Common/Log.h"
5
#include "Core/Config.h"
6
#include "Core/ConfigValues.h"
7
#include "Core/System.h"
8
9
AndroidJavaEGLGraphicsContext::AndroidJavaEGLGraphicsContext() {
10
SetGPUBackend(GPUBackend::OPENGL);
11
}
12
13
bool AndroidJavaEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) {
14
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::InitFromRenderThread");
15
if (!CheckGLExtensions()) {
16
ERROR_LOG(Log::G3D, "CheckGLExtensions failed - not gonna attempt starting up.");
17
state_ = GraphicsContextState::FAILED_INIT;
18
return false;
19
}
20
21
// OpenGL handles rotated rendering in the driver.
22
g_display.rotation = DisplayRotation::ROTATE_0;
23
g_display.rot_matrix.setIdentity();
24
25
draw_ = Draw::T3DCreateGLContext(false); // Can't fail
26
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
27
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
28
29
if (!draw_->CreatePresets()) {
30
// This can't really happen now that compilation is async - they're only really queued for compile here.
31
_assert_msg_(false, "Failed to compile preset shaders");
32
state_ = GraphicsContextState::FAILED_INIT;
33
return false;
34
}
35
state_ = GraphicsContextState::INITIALIZED;
36
return true;
37
}
38
39
void AndroidJavaEGLGraphicsContext::ShutdownFromRenderThread() {
40
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::Shutdown");
41
renderManager_ = nullptr; // owned by draw_.
42
delete draw_;
43
draw_ = nullptr;
44
state_ = GraphicsContextState::SHUTDOWN;
45
}
46
47