mirror of https://github.com/buggins/dlangui.git
allow stripping out legacy OpenGL; disable legacy opengl for Android #119
This commit is contained in:
parent
7a71c97491
commit
013e8e956b
|
@ -151,11 +151,12 @@ DLANGUI_LDLIBS="\
|
||||||
-landroid \
|
-landroid \
|
||||||
-lEGL \
|
-lEGL \
|
||||||
-lGLESv3 \
|
-lGLESv3 \
|
||||||
-lGLESv1_CM \
|
|
||||||
-lc \
|
-lc \
|
||||||
-lm \
|
-lm \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
#-lGLESv1_CM \
|
||||||
|
|
||||||
#echo "Import paths: $DLANGUI_IMPORT_PATHS"
|
#echo "Import paths: $DLANGUI_IMPORT_PATHS"
|
||||||
#echo "Source paths: $DLANGUI_SOURCE_PATHS"
|
#echo "Source paths: $DLANGUI_SOURCE_PATHS"
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ int engine_init_display(engine* engine) {
|
||||||
// Initialize GL state.
|
// Initialize GL state.
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glShadeModel(GL_SMOOTH);
|
//glShadeModel(GL_SMOOTH);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -31,15 +31,21 @@ import std.string;
|
||||||
import std.array;
|
import std.array;
|
||||||
|
|
||||||
version (Android) {
|
version (Android) {
|
||||||
|
enum SUPPORT_LEGACY_OPENGL = false;
|
||||||
public import EGL.eglplatform : EGLint;
|
public import EGL.eglplatform : EGLint;
|
||||||
public import EGL.egl, GLES3.gl3;
|
public import EGL.egl;
|
||||||
public import GLES.gl : glEnableClientState, glLightfv, glColor4f, GL_ALPHA_TEST, GL_VERTEX_ARRAY,
|
//public import GLES2.gl2;
|
||||||
GL_COLOR_ARRAY, glVertexPointer, glColorPointer, glDisableClientState,
|
public import GLES3.gl3;
|
||||||
GL_TEXTURE_COORD_ARRAY, glTexCoordPointer, glColorPointer, glMatrixMode,
|
|
||||||
glLoadMatrixf, glLoadIdentity, GL_PROJECTION, GL_MODELVIEW;
|
static if (SUPPORT_LEGACY_OPENGL) {
|
||||||
|
public import GLES.gl : glEnableClientState, glLightfv, glColor4f, GL_ALPHA_TEST, GL_VERTEX_ARRAY,
|
||||||
|
GL_COLOR_ARRAY, glVertexPointer, glColorPointer, glDisableClientState,
|
||||||
|
GL_TEXTURE_COORD_ARRAY, glTexCoordPointer, glColorPointer, glMatrixMode,
|
||||||
|
glLoadMatrixf, glLoadIdentity, GL_PROJECTION, GL_MODELVIEW;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
enum SUPPORT_LEGACY_OPENGL = true;
|
||||||
public import derelict.opengl3.types;
|
public import derelict.opengl3.types;
|
||||||
public import derelict.opengl3.gl3;
|
public import derelict.opengl3.gl3;
|
||||||
public import derelict.opengl3.gl;
|
public import derelict.opengl3.gl;
|
||||||
|
@ -882,22 +888,24 @@ final class GLSupport {
|
||||||
x1,y1,Z_2D];
|
x1,y1,Z_2D];
|
||||||
|
|
||||||
if (_legacyMode) {
|
if (_legacyMode) {
|
||||||
glColor4f(1,1,1,1);
|
static if (SUPPORT_LEGACY_OPENGL) {
|
||||||
glDisable(GL_CULL_FACE);
|
glColor4f(1,1,1,1);
|
||||||
glEnable(GL_BLEND);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glEnable(GL_BLEND);
|
||||||
checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glDisable(GL_ALPHA_TEST);
|
||||||
checkgl!glEnableClientState(GL_VERTEX_ARRAY);
|
checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
checkgl!glEnableClientState(GL_COLOR_ARRAY);
|
checkgl!glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
checkgl!glVertexPointer(3, GL_FLOAT, 0, cast(void*)vertices.ptr);
|
checkgl!glEnableClientState(GL_COLOR_ARRAY);
|
||||||
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors);
|
checkgl!glVertexPointer(3, GL_FLOAT, 0, cast(void*)vertices.ptr);
|
||||||
|
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors);
|
||||||
|
|
||||||
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_solidFillProgram !is null) {
|
if (_solidFillProgram !is null) {
|
||||||
_solidFillProgram.execute(vertices, cast(float[])colors);
|
_solidFillProgram.execute(vertices, cast(float[])colors);
|
||||||
|
@ -936,32 +944,34 @@ final class GLSupport {
|
||||||
float[2 * 4] texcoords = [srcx0,srcy0, srcx0,srcy1, srcx1,srcy0, srcx1,srcy1];
|
float[2 * 4] texcoords = [srcx0,srcy0, srcx0,srcy1, srcx1,srcy0, srcx1,srcy1];
|
||||||
|
|
||||||
if (_legacyMode) {
|
if (_legacyMode) {
|
||||||
glDisable(GL_CULL_FACE);
|
static if (SUPPORT_LEGACY_OPENGL) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glDisable(GL_CULL_FACE);
|
||||||
texture.setup();
|
glEnable(GL_TEXTURE_2D);
|
||||||
texture.setSamplerParams(linear);
|
texture.setup();
|
||||||
|
texture.setSamplerParams(linear);
|
||||||
|
|
||||||
glColor4f(1,1,1,1);
|
glColor4f(1,1,1,1);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
checkgl!glEnableClientState(GL_COLOR_ARRAY);
|
checkgl!glEnableClientState(GL_COLOR_ARRAY);
|
||||||
checkgl!glEnableClientState(GL_VERTEX_ARRAY);
|
checkgl!glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
checkgl!glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
checkgl!glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
checkgl!glVertexPointer(3, GL_FLOAT, 0, cast(void*)vertices.ptr);
|
checkgl!glVertexPointer(3, GL_FLOAT, 0, cast(void*)vertices.ptr);
|
||||||
checkgl!glTexCoordPointer(2, GL_FLOAT, 0, cast(void*)texcoords.ptr);
|
checkgl!glTexCoordPointer(2, GL_FLOAT, 0, cast(void*)texcoords.ptr);
|
||||||
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors.ptr);
|
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors.ptr);
|
||||||
|
|
||||||
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_textureProgram.execute(vertices, cast(float[])colors, texcoords, texture, linear);
|
_textureProgram.execute(vertices, cast(float[])colors, texcoords, texture, linear);
|
||||||
}
|
}
|
||||||
|
@ -1115,14 +1125,16 @@ final class GLSupport {
|
||||||
_projectionMatrix.setOrtho(view.left, view.right, view.top, view.bottom, 0.5f, 50.0f);
|
_projectionMatrix.setOrtho(view.left, view.right, view.top, view.bottom, 0.5f, 50.0f);
|
||||||
|
|
||||||
if (_legacyMode) {
|
if (_legacyMode) {
|
||||||
glMatrixMode(GL_PROJECTION);
|
static if (SUPPORT_LEGACY_OPENGL) {
|
||||||
//checkgl!glPushMatrix();
|
glMatrixMode(GL_PROJECTION);
|
||||||
//glLoadIdentity();
|
//checkgl!glPushMatrix();
|
||||||
glLoadMatrixf(_projectionMatrix.m.ptr);
|
//glLoadIdentity();
|
||||||
//glOrthof(0, _dx, 0, _dy, -1.0f, 1.0f);
|
glLoadMatrixf(_projectionMatrix.m.ptr);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
//glOrthof(0, _dx, 0, _dy, -1.0f, 1.0f);
|
||||||
//checkgl!glPushMatrix();
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
//checkgl!glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
checkgl!glViewport(view.left, currentFBO ? view.top : windowRect.height - view.bottom, view.width, view.height);
|
checkgl!glViewport(view.left, currentFBO ? view.top : windowRect.height - view.bottom, view.width, view.height);
|
||||||
}
|
}
|
||||||
|
@ -1134,14 +1146,16 @@ final class GLSupport {
|
||||||
float aspectRatio = cast(float)view.width / cast(float)view.height;
|
float aspectRatio = cast(float)view.width / cast(float)view.height;
|
||||||
_projectionMatrix.setPerspective(fieldOfView, aspectRatio, nearPlane, farPlane);
|
_projectionMatrix.setPerspective(fieldOfView, aspectRatio, nearPlane, farPlane);
|
||||||
if (_legacyMode) {
|
if (_legacyMode) {
|
||||||
glMatrixMode(GL_PROJECTION);
|
static if (SUPPORT_LEGACY_OPENGL) {
|
||||||
//checkgl!glPushMatrix();
|
glMatrixMode(GL_PROJECTION);
|
||||||
//glLoadIdentity();
|
//checkgl!glPushMatrix();
|
||||||
glLoadMatrixf(_projectionMatrix.m.ptr);
|
//glLoadIdentity();
|
||||||
//glOrthof(0, _dx, 0, _dy, -1.0f, 1.0f);
|
glLoadMatrixf(_projectionMatrix.m.ptr);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
//glOrthof(0, _dx, 0, _dy, -1.0f, 1.0f);
|
||||||
//checkgl!glPushMatrix();
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
//checkgl!glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
checkgl!glViewport(view.left, currentFBO ? view.top : windowRect.height - view.bottom, view.width, view.height);
|
checkgl!glViewport(view.left, currentFBO ? view.top : windowRect.height - view.bottom, view.width, view.height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue