set the OpenGl clipping instead of using internal clipping
This commit is contained in:
parent
ac952176f2
commit
36534c0882
@ -18,15 +18,14 @@ LOCAL_CFLAGS := -D__PLATFORM__Android \
|
|||||||
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
|
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
|
||||||
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
|
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
|
||||||
-DEWOL_USE_FREE_TYPE \
|
-DEWOL_USE_FREE_TYPE \
|
||||||
-DDATA_IN_APK
|
-DDATA_IN_APK \
|
||||||
|
-frtti
|
||||||
|
|
||||||
# load the common sources file of the platform
|
# load the common sources file of the platform
|
||||||
include $(LOCAL_PATH)/file.mk
|
include $(LOCAL_PATH)/file.mk
|
||||||
|
|
||||||
LOCAL_SRC_FILES := ewol/base/guiAndroid.cpp $(FILE_LIST)
|
LOCAL_SRC_FILES := ewol/base/guiAndroid.cpp $(FILE_LIST)
|
||||||
|
|
||||||
#for freetype : https://github.com/cdave1/freetype2-android
|
|
||||||
|
|
||||||
# Ewol Test Software :
|
# Ewol Test Software :
|
||||||
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
|
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ void ewol::OObject2DColored::Draw(void)
|
|||||||
glEnableClientState( GL_VERTEX_ARRAY );
|
glEnableClientState( GL_VERTEX_ARRAY );
|
||||||
glEnableClientState( GL_COLOR_ARRAY );
|
glEnableClientState( GL_COLOR_ARRAY );
|
||||||
|
|
||||||
|
//glPushMatrix();
|
||||||
|
|
||||||
// Set the vertex pointer to our vertex data
|
// Set the vertex pointer to our vertex data
|
||||||
glVertexPointer(2, oglTypeFloat_t, 0, &m_coord[0] );
|
glVertexPointer(2, oglTypeFloat_t, 0, &m_coord[0] );
|
||||||
|
@ -236,13 +236,49 @@ void ewol::Widget::SetCanHaveFocus(bool canFocusState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_CLIPPING_SIZE (10)
|
||||||
|
//#define TEST_CLIPPING_SIZE (3)
|
||||||
|
//#define TEST_CLIPPING_SIZE (0)
|
||||||
|
|
||||||
|
#ifdef __PLATFORM__Android
|
||||||
|
# define clipping_type GLfloat
|
||||||
|
# define clipping_function glClipPlanef
|
||||||
|
#else
|
||||||
|
# define clipping_type GLdouble
|
||||||
|
# define clipping_function glClipPlane
|
||||||
|
#endif
|
||||||
bool ewol::Widget::GenDraw(void)
|
bool ewol::Widget::GenDraw(void)
|
||||||
{
|
{
|
||||||
|
glPushMatrix();
|
||||||
|
#if 1
|
||||||
glTranslatef(m_origin.x,m_origin.y, 0);
|
glTranslatef(m_origin.x,m_origin.y, 0);
|
||||||
//EWOL_DEBUG("Draw Custum...");
|
//GLfloat
|
||||||
|
clipping_type eqn1[4] = {0.0, 1.0, 0.0, -TEST_CLIPPING_SIZE}; // less the Y pos ...
|
||||||
|
clipping_type eqn2[4] = {0.0, -1.0, 0.0, m_size.y-TEST_CLIPPING_SIZE}; // upper the y pos ...
|
||||||
|
clipping_type eqn3[4] = {1.0, 0.0, 0.0, -TEST_CLIPPING_SIZE}; // less the x pos ...
|
||||||
|
clipping_type eqn4[4] = {-1.0, 0.0, 0.0, m_size.x-TEST_CLIPPING_SIZE}; // upper the x pos ...
|
||||||
|
//EWOL_DEBUG("widget size (" << m_size.x << "," << m_size.y << ")" );
|
||||||
|
/* clip lower half -- y < 0 */
|
||||||
|
glEnable(GL_CLIP_PLANE0);
|
||||||
|
clipping_function(GL_CLIP_PLANE0, eqn1);
|
||||||
|
glEnable(GL_CLIP_PLANE1);
|
||||||
|
clipping_function(GL_CLIP_PLANE1, eqn2);
|
||||||
|
glEnable(GL_CLIP_PLANE2);
|
||||||
|
clipping_function(GL_CLIP_PLANE2, eqn3);
|
||||||
|
glEnable(GL_CLIP_PLANE3);
|
||||||
|
clipping_function(GL_CLIP_PLANE3, eqn4);
|
||||||
|
#else
|
||||||
|
glTranslatef(m_origin.x,m_origin.y, 0);
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glScissor(TEST_CLIPPING_SIZE, TEST_CLIPPING_SIZE, m_size.x-TEST_CLIPPING_SIZE, m_size.y-TEST_CLIPPING_SIZE);
|
||||||
|
#endif
|
||||||
bool valRet = OnDraw();
|
bool valRet = OnDraw();
|
||||||
glTranslatef(-m_origin.x,-m_origin.y, 0);
|
/*
|
||||||
|
glDisable(GL_CLIP_PLANE3);
|
||||||
|
glDisable(GL_CLIP_PLANE2);
|
||||||
|
glDisable(GL_CLIP_PLANE1);
|
||||||
|
glDisable(GL_CLIP_PLANE0);
|
||||||
|
*/
|
||||||
|
glPopMatrix();
|
||||||
return valRet;
|
return valRet;
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,35 @@ void ewol::Windows::SysDraw(void)
|
|||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
//#if defined(__PLATFORM__Android)
|
||||||
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
|
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
|
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
|
||||||
|
/*
|
||||||
|
#else
|
||||||
|
glOrtho(0., m_size.x, 0., -m_size.y, 1., 20.);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslatef(0, -m_size.y, -5);
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
//http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html
|
||||||
|
|
||||||
|
//glEnable(GL_POLYGON_SMOOTH);
|
||||||
|
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
//glShadeModel(GL_POLYGON_SMOOTH);
|
||||||
|
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
|
|
||||||
|
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
|
||||||
|
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
||||||
|
|
||||||
GenDraw();
|
GenDraw();
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -95,7 +95,7 @@ void EWOL_NativeRender(void)
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
//glOrtho(0., width, 0., -height, 1., 20.);
|
//glOrtho(0., width, 0., -height, 1., 20.);
|
||||||
glOrtho(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
|
glOrthoEwol(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
@ -220,40 +220,6 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void glOrtho(GLfloat left,
|
|
||||||
GLfloat right,
|
|
||||||
GLfloat bottom,
|
|
||||||
GLfloat top,
|
|
||||||
GLfloat nearVal,
|
|
||||||
GLfloat farVal)
|
|
||||||
{
|
|
||||||
GLfloat myMatrix[4*4];
|
|
||||||
int iii;
|
|
||||||
for(iii=0; iii<4*4 ; iii++) {
|
|
||||||
myMatrix[iii] = 0;
|
|
||||||
}
|
|
||||||
myMatrix[0] = 2.0 / (right - left);
|
|
||||||
myMatrix[5] = 2.0 / (top - bottom);
|
|
||||||
myMatrix[10] = -2.0 / (farVal - nearVal);
|
|
||||||
#if 1
|
|
||||||
myMatrix[3] = -1*(right + left) / (right - left);
|
|
||||||
myMatrix[7] = -1*(top + bottom) / (top - bottom);
|
|
||||||
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
|
|
||||||
#else
|
|
||||||
// test if matrix is not corectly instanciate ...
|
|
||||||
myMatrix[12] = -1*(right + left) / (right - left);
|
|
||||||
myMatrix[13] = -1*(top + bottom) / (top - bottom);
|
|
||||||
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
|
|
||||||
#endif
|
|
||||||
myMatrix[15] = 1;
|
|
||||||
|
|
||||||
glLoadMatrixf(myMatrix);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
int32_t ewol::CmdLineNb(void)
|
int32_t ewol::CmdLineNb(void)
|
||||||
{
|
{
|
||||||
|
@ -9,15 +9,12 @@ extern "C" {
|
|||||||
#if defined(__PLATFORM__Linux)
|
#if defined(__PLATFORM__Linux)
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
|
||||||
#elif defined(__PLATFORM__DoubleBuffer)
|
#elif defined(__PLATFORM__DoubleBuffer)
|
||||||
|
|
||||||
#elif defined(__PLATFORM__Android)
|
#elif defined(__PLATFORM__Android)
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
void glOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
|
||||||
#elif defined(__PLATFORM__AndroidTablet)
|
#elif defined(__PLATFORM__AndroidTablet)
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
void glOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
|
||||||
#elif defined(__PLATFORM__IPhone)
|
#elif defined(__PLATFORM__IPhone)
|
||||||
|
|
||||||
#elif defined(__PLATFORM__IPad)
|
#elif defined(__PLATFORM__IPad)
|
||||||
@ -26,6 +23,7 @@ extern "C" {
|
|||||||
#error you need to specify a platform ...
|
#error you need to specify a platform ...
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user