Panda3D
config_androiddisplay.cxx
1 // Filename: config_androiddisplay.cxx
2 // Created by: rdb (11Jan13)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_androiddisplay.h"
16 #include "androidGraphicsPipe.h"
17 #include "androidGraphicsWindow.h"
18 #include "androidGraphicsStateGuardian.h"
19 #include "graphicsPipeSelection.h"
20 #include "dconfig.h"
21 #include "pandaSystem.h"
22 
23 #include "config_display.h"
24 
25 Configure(config_androiddisplay);
26 NotifyCategoryDef(androiddisplay, "display");
27 
28 ConfigureFn(config_androiddisplay) {
29  init_libandroiddisplay();
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: init_libandroiddisplay
34 // Description: Initializes the library. This must be called at
35 // least once before any of the functions or classes in
36 // this library can be used. Normally it will be
37 // called by the static initializers and need not be
38 // called explicitly, but special cases exist.
39 ////////////////////////////////////////////////////////////////////
40 void
41 init_libandroiddisplay() {
42  static bool initialized = false;
43  if (initialized) {
44  return;
45  }
46  initialized = true;
47 
48  init_libdisplay();
49  display_cat.get_safe_ptr();
50 
51  AndroidGraphicsPipe::init_type();
52  AndroidGraphicsWindow::init_type();
53  AndroidGraphicsStateGuardian::init_type();
54 
56  selection->add_pipe_type(AndroidGraphicsPipe::get_class_type(),
57  AndroidGraphicsPipe::pipe_constructor);
58 
60 #ifdef OPENGLES_2
61  ps->set_system_tag("OpenGL ES 2", "window_system", "Android");
62 #else
63  ps->set_system_tag("OpenGL ES", "window_system", "Android");
64 #endif
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: get_egl_error_string
69 // Description: Returns the given EGL error as string.
70 ////////////////////////////////////////////////////////////////////
71 const string get_egl_error_string(int error) {
72  switch (error) {
73  case 0x3000: return "EGL_SUCCESS"; break;
74  case 0x3001: return "EGL_NOT_INITIALIZED"; break;
75  case 0x3002: return "EGL_BAD_ACCESS"; break;
76  case 0x3003: return "EGL_BAD_ALLOC"; break;
77  case 0x3004: return "EGL_BAD_ATTRIBUTE"; break;
78  case 0x3005: return "EGL_BAD_CONFIG"; break;
79  case 0x3006: return "EGL_BAD_CONTEXT"; break;
80  case 0x3007: return "EGL_BAD_CURRENT_SURFACE"; break;
81  case 0x3008: return "EGL_BAD_DISPLAY"; break;
82  case 0x3009: return "EGL_BAD_MATCH"; break;
83  case 0x300A: return "EGL_BAD_NATIVE_PIXMAP"; break;
84  case 0x300B: return "EGL_BAD_NATIVE_WINDOW"; break;
85  case 0x300C: return "EGL_BAD_PARAMETER"; break;
86  case 0x300D: return "EGL_BAD_SURFACE"; break;
87  case 0x300E: return "EGL_CONTEXT_LOST"; break;
88  default: return "Unknown error";
89  }
90 }
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
This maintains a list of GraphicsPipes by type that are available for creation.
static GraphicsPipeSelection * get_global_ptr()
Returns a pointer to the one global GraphicsPipeSelection object.
bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func)
Adds a new kind of GraphicsPipe to the list of available pipes for creation.
void set_system_tag(const string &system, const string &tag, const string &value)
Intended for use by each subsystem to register its set of capabilities at startup.