summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-08 21:48:20 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-11 18:15:54 +0300
commit5f23fe21b29083922dab55feb33258f3f855ca9e (patch)
tree09637f98663093435066a6436b931612c4a53d82
parent167fe73b9dde166cc84927262cdd8c20ed2f4ac4 (diff)
downloadplus-5f23fe21b29083922dab55feb33258f3f855ca9e.tar.gz
plus-5f23fe21b29083922dab55feb33258f3f855ca9e.tar.bz2
plus-5f23fe21b29083922dab55feb33258f3f855ca9e.tar.xz
plus-5f23fe21b29083922dab55feb33258f3f855ca9e.zip
Add nacl gl init and nacl defines and includes in most files.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/graphicsmanager.cpp6
-rw-r--r--src/render/mgl.hpp46
-rw-r--r--src/render/mgltypes.h64
-rw-r--r--src/render/mobileopengl2graphics.cpp3
-rw-r--r--src/render/mobileopenglgraphics.cpp4
-rw-r--r--src/render/mobileopenglgraphics.h4
-rw-r--r--src/render/modernopenglgraphics.cpp3
-rw-r--r--src/render/naclgles.cpp49
-rw-r--r--src/render/naclgles.h34
-rw-r--r--src/render/shaders/shaderprogram.cpp3
-rw-r--r--src/render/shaders/shadersmanager.cpp3
13 files changed, 168 insertions, 55 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bcaa63983..a1fb32532 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1013,6 +1013,8 @@ SET(SRCS
render/mobileopenglgraphics.h
render/modernopenglgraphics.cpp
render/modernopenglgraphics.h
+ render/naclgles.cpp
+ render/naclgles.h
input/mouseinput.h
mumblemanager.cpp
mumblemanager.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 782775d9b..aeb73164b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -520,6 +520,8 @@ SRC += events/actionevent.h \
render/mobileopenglgraphics.h \
render/modernopenglgraphics.cpp \
render/modernopenglgraphics.h \
+ render/naclgles.cpp \
+ render/naclgles.h \
render/naclglfunctions.h \
render/normalopenglgraphics.cpp \
render/normalopenglgraphics.h \
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 70c4346bf..83be30964 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -33,6 +33,7 @@
#endif // USE_SDL2
#elif defined(__native_client__)
#include <GL/Regal.h>
+#include "render/naclgles.h"
#else // ANDROID
#include <GL/glx.h>
#endif // ANDROID
@@ -893,6 +894,10 @@ void GraphicsManager::deleteFBO(FBOInfo *const fbo)
void GraphicsManager::initOpenGLFunctions()
{
+#ifdef __native_client__
+ NaclGles::initGles();
+ emulateFunction(glTextureSubImage2D);
+#else
const bool is10 = checkGLVersion(1, 0);
const bool is11 = checkGLVersion(1, 1);
const bool is12 = checkGLVersion(1, 2);
@@ -1263,6 +1268,7 @@ void GraphicsManager::initOpenGLFunctions()
#ifdef WIN32
assignFunctionARB(wglGetExtensionsString);
#endif
+#endif
}
void GraphicsManager::updateLimits()
diff --git a/src/render/mgl.hpp b/src/render/mgl.hpp
index 118b9491c..0370cde74 100644
--- a/src/render/mgl.hpp
+++ b/src/render/mgl.hpp
@@ -43,39 +43,43 @@ defName(glPopGroupMarker);
defName(glGenVertexArrays);
defName(glBindVertexArray);
defName(glDeleteVertexArrays);
-defName(glVertexAttribPointer);
-defName(glEnableVertexAttribArray);
defName(glDisableVertexAttribArray);
-defName(glGenBuffers);
-defName(glDeleteBuffers);
-defName(glBindBuffer);
-defName(glBufferData);
-defName(glCreateShader);
defName(glDeleteShader);
-defName(glGetShaderiv);
defName(glGetShaderInfoLog);
defName(glGetShaderSource);
-defName(glShaderSource);
-defName(glCompileShader);
-defName(glLinkProgram);
-defName(glDeleteProgram);
-defName(glCreateProgram);
-defName(glAttachShader);
defName(glDetachShader);
defName(glGetAttachedShaders);
-defName(glGetUniformLocation);
defName(glGetActiveUniform);
-defName(glGetProgramiv);
defName(glBindFragDataLocation);
+#ifndef __native_client__
+defName(glDeleteProgram);
+defName(glCreateProgram);
+defName(glGetProgramiv);
+defName(glLinkProgram);
+defName(glAttachShader);
+defName(glGetShaderiv);
+defName(glCompileShader);
+defName(glShaderSource);
+defName(glCreateShader);
+defName(glGetUniformLocation);
+defName(glGenBuffers);
+defName(glDeleteBuffers);
+defName(glBindBuffer);
+defName(glBufferData);
+defName(glEnableVertexAttribArray);
+defName(glVertexAttribPointer);
defName(glUseProgram);
-defName(glValidateProgram);
-defName(glGetAttribLocation);
defName(glUniform1f);
defName(glUniform2f);
-defName(glUniform3f);
defName(glUniform4f);
-defName(glCheckFramebufferStatus);
+defName(glValidateProgram);
defName(glGetProgramInfoLog);
+defName(glBindAttribLocation);
+defName(glActiveTexture);
+#endif
+defName(glGetAttribLocation);
+defName(glUniform3f);
+defName(glCheckFramebufferStatus);
defName(glProgramUniform1f);
defName(glProgramUniform2f);
defName(glProgramUniform3f);
@@ -102,8 +106,6 @@ defName(glGetQueryObjectui64v);
defName(glTextureSubImage2D);
defName(glClearTexImage);
defName(glClearTexSubImage);
-defName(glBindAttribLocation);
-defName(glActiveTexture);
#ifdef WIN32
defName(wglGetExtensionsString);
#endif
diff --git a/src/render/mgltypes.h b/src/render/mgltypes.h
index 479f5e177..1937bb6a2 100644
--- a/src/render/mgltypes.h
+++ b/src/render/mgltypes.h
@@ -85,55 +85,60 @@ typedef void (APIENTRY *glPopGroupMarker_t) (void);
typedef void (APIENTRY *glGenVertexArrays_t) (GLsizei n, GLuint *arrays);
typedef void (APIENTRY *glBindVertexArray_t) (GLuint array);
typedef void (APIENTRY *glDeleteVertexArrays_t) (GLsizei n, GLuint *arrays);
-typedef void (APIENTRY *glVertexAttribPointer_t) (GLuint index, GLint size,
- GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRY *glEnableVertexAttribArray_t) (GLuint index);
typedef void (APIENTRY *glDisableVertexAttribArray_t) (GLuint index);
-typedef void (APIENTRY *glGenBuffers_t) (GLsizei n, GLuint *buffers);
-typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers);
-typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer);
-typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size,
- const GLvoid *data, GLenum usage);
-typedef GLuint (APIENTRY *glCreateShader_t) (GLenum shaderType);
typedef void (APIENTRY *glDeleteShader_t) (GLenum shader);
-typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader,
- GLenum pname, GLint *params);
typedef void (APIENTRY *glGetShaderInfoLog_t) (GLuint shader,
GLsizei maxLength, GLsizei *length, GLchar *infoLog);
typedef void (APIENTRY *glGetShaderSource_t) (GLuint shader,
GLsizei bufSize, GLsizei *length, GLchar *source);
-typedef void (APIENTRY *glShaderSource_t) (GLuint shader,
- GLsizei count, const GLchar **string, const GLint *length);
-typedef void (APIENTRY *glCompileShader_t) (GLuint shader);
-typedef void (APIENTRY *glLinkProgram_t) (GLuint program);
-typedef void (APIENTRY *glDeleteProgram_t) (GLuint program);
-typedef GLuint (APIENTRY *glCreateProgram_t) (void);
-typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader);
typedef void (APIENTRY *glDetachShader_t) (GLuint program, GLuint shader);
typedef void (APIENTRY *glGetAttachedShaders_t) (GLuint program,
GLsizei maxCount, GLsizei *count, GLuint *shaders);
-typedef GLint (APIENTRY *glGetUniformLocation_t) (GLuint program,
- const GLchar *name);
typedef void (APIENTRY *glGetActiveUniform_t) (GLuint program, GLuint index,
GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (APIENTRY *glGetProgramiv_t) (GLuint program,
- GLenum pname, GLint *params);
typedef GLint (APIENTRY *glBindFragDataLocation_t) (GLuint program,
GLuint colorNumber, const char *name);
-typedef void (APIENTRY *glUseProgram_t) (GLuint program);
-typedef void (APIENTRY *glValidateProgram_t) (GLuint program);
-typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program,
+#ifndef __native_client__
+typedef void (APIENTRY *glDeleteProgram_t) (GLuint program);
+typedef GLuint (APIENTRY *glCreateProgram_t) (void);
+typedef void (APIENTRY *glGetProgramiv_t) (GLuint program,
+ GLenum pname, GLint *params);
+typedef void (APIENTRY *glLinkProgram_t) (GLuint program);
+typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader);
+typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader,
+ GLenum pname, GLint *params);
+typedef void (APIENTRY *glCompileShader_t) (GLuint shader);
+typedef void (APIENTRY *glShaderSource_t) (GLuint shader,
+ GLsizei count, const GLchar **string, const GLint *length);
+typedef GLuint (APIENTRY *glCreateShader_t) (GLenum shaderType);
+typedef GLint (APIENTRY *glGetUniformLocation_t) (GLuint program,
const GLchar *name);
+typedef void (APIENTRY *glGenBuffers_t) (GLsizei n, GLuint *buffers);
+typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers);
+typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer);
+typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size,
+ const GLvoid *data, GLenum usage);
+typedef void (APIENTRY *glEnableVertexAttribArray_t) (GLuint index);
+typedef void (APIENTRY *glVertexAttribPointer_t) (GLuint index, GLint size,
+ GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRY *glUseProgram_t) (GLuint program);
typedef void (APIENTRY *glUniform1f_t) (GLint location, GLfloat v0);
typedef void (APIENTRY *glUniform2f_t) (GLint location,
GLfloat v0, GLfloat v1);
-typedef void (APIENTRY *glUniform3f_t) (GLint location,
- GLfloat v0, GLfloat v1, GLfloat v2);
typedef void (APIENTRY *glUniform4f_t) (GLint location,
GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef GLenum (APIENTRY *glCheckFramebufferStatus_t) (GLenum target);
+typedef void (APIENTRY *glValidateProgram_t) (GLuint program);
typedef void (APIENTRY *glGetProgramInfoLog_t) (GLuint program,
GLsizei maxLength, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRY *glBindAttribLocation_t) (GLuint program,
+ GLuint index, const GLchar *name);
+typedef void (APIENTRY *glActiveTexture_t) (GLenum texture);
+#endif
+typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program,
+ const GLchar *name);
+typedef void (APIENTRY *glUniform3f_t) (GLint location,
+ GLfloat v0, GLfloat v1, GLfloat v2);
+typedef GLenum (APIENTRY *glCheckFramebufferStatus_t) (GLenum target);
typedef void (APIENTRY *glProgramUniform1f_t) (GLuint program,
GLint location, GLfloat v0);
typedef void (APIENTRY *glProgramUniform2f_t) (GLuint program,
@@ -185,9 +190,6 @@ typedef void (APIENTRY *glClearTexImage_t) (GLuint texture, GLint level,
typedef void (APIENTRY *glClearTexSubImage_t) (GLuint texture, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height,
GLsizei depth, GLenum format, GLenum type, const void * data);
-typedef void (APIENTRY *glBindAttribLocation_t) (GLuint program,
- GLuint index, const GLchar *name);
-typedef void (APIENTRY *glActiveTexture_t) (GLenum texture);
// callback
typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id,
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index 90c145240..8a46f05fb 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -30,6 +30,9 @@
#include "logger.h"
#include "render/mgl.h"
+#ifdef __native_client__
+#include "render/naclglfunctions.h"
+#endif
#include "render/shaders/shaderprogram.h"
#include "render/shaders/shadersmanager.h"
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index caba7a9e9..75d13f9cd 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -30,6 +30,9 @@
#include "logger.h"
#include "render/mgl.h"
+#ifdef __native_client__
+#include "render/naclglfunctions.h"
+#endif
#include "resources/image.h"
#include "resources/imagerect.h"
@@ -867,6 +870,7 @@ void MobileOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
calcImageRect(vert, x, y, w, h, imgRect);
}
+
void MobileOpenGLGraphics::updateScreen()
{
BLOCK_START("Graphics::updateScreen")
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index 657581ac1..5011bae9e 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -55,6 +55,8 @@ class MobileOpenGLGraphics final : public Graphics
~MobileOpenGLGraphics();
+ void postInit() override final;
+
inline void drawTriangleArrayfs(const GLshort *const shortVertArray,
const GLfloat *const floatTexArray,
const int size);
@@ -65,8 +67,6 @@ class MobileOpenGLGraphics final : public Graphics
inline void drawLineArrays(const int size);
- void postInit() override final;
-
#include "render/graphicsdef.hpp"
#include "render/openglgraphicsdef1.hpp"
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index e544254b4..8bfe30200 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -30,6 +30,9 @@
#include "logger.h"
#include "render/mgl.h"
+#ifdef __native_client__
+#include "render/naclglfunctions.h"
+#endif
#include "render/shaders/shaderprogram.h"
#include "render/shaders/shadersmanager.h"
diff --git a/src/render/naclgles.cpp b/src/render/naclgles.cpp
new file mode 100644
index 000000000..ef53e6849
--- /dev/null
+++ b/src/render/naclgles.cpp
@@ -0,0 +1,49 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if defined(__native_client__) && defined(USE_OPENGL)
+
+#include "render/naclgles.h"
+
+#include "logger.h"
+
+#include "render/mglfunctions.h"
+
+#include <ppapi_simple/ps.h>
+
+#include <ppapi/c/ppb_opengles2.h>
+
+#include <ppapi/gles2/gl2ext_ppapi.h>
+
+#include "debug.h"
+
+const struct PPB_OpenGLES2* gles2Interface = nullptr;
+PP_Resource gles2Context = nullptr;
+
+void NaclGles::initGles()
+{
+ gles2Interface = static_cast<const PPB_OpenGLES2*>(
+ PSGetInterface(PPB_OPENGLES2_INTERFACE));
+ gles2Context = glGetCurrentContextPPAPI();
+
+ logger->log("InitGles: %p, %d", gles2Interface, gles2Context);
+}
+
+#endif // defined(__native_client__) && defined(USE_OPENGL)
diff --git a/src/render/naclgles.h b/src/render/naclgles.h
new file mode 100644
index 000000000..44b1a1f97
--- /dev/null
+++ b/src/render/naclgles.h
@@ -0,0 +1,34 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RENDER_NACLGLES_H
+#define RENDER_NACLGLES_H
+
+#if defined(__native_client__) && defined(USE_OPENGL)
+
+#include <ppapi/c/ppb_opengles2.h>
+
+namespace NaclGles
+{
+ void initGles();
+} // namespace NaclGles
+
+#endif // defined(__native_client__) && defined(USE_OPENGL)
+#endif // RENDER_NACLGLES_H
diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp
index e910be3d3..4cb4786c8 100644
--- a/src/render/shaders/shaderprogram.cpp
+++ b/src/render/shaders/shaderprogram.cpp
@@ -23,6 +23,9 @@
#include "render/shaders/shaderprogram.h"
#include "render/mgl.h"
+#ifdef __native_client__
+#include "render/naclglfunctions.h"
+#endif
#include "render/shaders/shader.h"
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index c79abe2cc..9caed603d 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -26,6 +26,9 @@
#include "logger.h"
#include "render/mgl.h"
+#ifdef __native_client__
+#include "render/naclglfunctions.h"
+#endif
#include "render/shaders/shader.h"
#include "render/shaders/shaderprogram.h"