build is now ok for android with openGL ES 2.0 ==> not work : use unimplement fuction???

This commit is contained in:
Edouard Dupin 2012-08-30 01:29:28 +02:00
parent 2eaed4f16e
commit 085b7cb9cd
15 changed files with 146 additions and 199 deletions

View File

@ -26,6 +26,8 @@ package org.ewol;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
//import javax.microedition.khronos.opengl.GLES20;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
// inport the ewol package :

View File

@ -23,6 +23,10 @@ LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
-DDATA_IN_APK
LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk

View File

@ -25,7 +25,6 @@ LOCAL_EXPORT_LDLIBS := -lGL -lX11
LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
-DLUA_COMPAT_ALL \
-Wall

View File

@ -20,9 +20,12 @@ LOCAL_EXPORT_LDLIBS := -lopengl32 -lgdi32
LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
-DLUA_COMPAT_ALL \
-Wall
#LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
#LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk

View File

@ -68,8 +68,7 @@ void ewol::OObject2DColored::Draw(void)
EWOL_ERROR("No shader ...");
return;
}
glPushMatrix();
glScalef(m_scaling.x, m_scaling.y, 1.0);
//glScalef(m_scaling.x, m_scaling.y, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
@ -81,7 +80,6 @@ void ewol::OObject2DColored::Draw(void)
// Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
m_GLprogram->UnUse();
glPopMatrix();
#else
glPushMatrix();
// Enable Pointers

View File

@ -135,7 +135,6 @@ void ewol::OObject2DTextColored::Draw(void)
EWOL_ERROR("No shader ...");
return;
}
glColor4f(1.0, 1.0, 1.0, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();

View File

@ -75,7 +75,6 @@ void ewol::OObject2DTextured::Draw(void)
EWOL_ERROR("No shader ...");
return;
}
glColor4f(1.0, 1.0, 1.0, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();

View File

@ -75,7 +75,6 @@ void ewol::OObject3DTextured::Draw(void)
EWOL_ERROR("No shader ...");
return;
}
glColor4f(1.0, 1.0, 1.0, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();

View File

@ -26,47 +26,47 @@
#include <ewol/openGL/openGL.h>
#include <etk/Vector.h>
void glOrthoMatrix(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal,
GLfloat* myMatrix)
{
int iii;
for(iii=0; iii<4*4 ; iii++) {
myMatrix[iii] = 0;
#ifndef __VIDEO__OPENGL_ES_2
void glOrthoMatrix(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal,
GLfloat* myMatrix)
{
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;
}
void glOrthoEwol(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal)
{
GLfloat myMatrix[4*4];
glOrthoMatrix(left, right, bottom, top, nearVal, farVal, myMatrix);
glLoadMatrixf(myMatrix);
}
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;
}
void glOrthoEwol(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal)
{
GLfloat myMatrix[4*4];
glOrthoMatrix(left, right, bottom, top, nearVal, farVal, myMatrix);
glLoadMatrixf(myMatrix);
}
etk::Vector<etk::Matrix> l_matrixList;

View File

@ -31,7 +31,7 @@
extern "C" {
#endif
#if defined(__TARGET_OS__Linux) || defined(__TARGET_OS__Windows)
#if defined(__TARGET_OS__Linux)
#ifdef __VIDEO__OPENGL_ES_2
// TO ENABLE THE SHADER api ...
#define GL_GLEXT_PROTOTYPES
@ -57,6 +57,14 @@ extern "C" {
// Include openGL ES 1
#include <GLES/gl.h>
#endif
#elif defined(__TARGET_OS__Windows)
#ifdef __VIDEO__OPENGL_ES_2
// TO ENABLE THE SHADER api ...
#define GL_GLEXT_PROTOTYPES
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#elif defined(__TARGET_OS__MacOs)
#elif defined(__TARGET_OS__IOs)
@ -65,9 +73,10 @@ extern "C" {
#error you need to specify a __TAGET_OS__ ...
#endif
// TODO : Remove : deprecated ....
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
#ifndef __VIDEO__OPENGL_ES_2
// TODO : Remove : deprecated ....
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
#endif
namespace ewol {
namespace openGL {
void Init(void);

View File

@ -419,107 +419,6 @@ void eSystem::ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID)
}
static float gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
static float gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
static void BasicOpenGlDraw(void)
{
Vector2D<int32_t> tmpSize = eSystem::GetSize();
// set the size of the open GL system
glViewport(0, 0, tmpSize.x, tmpSize.y);
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrthoEwol(-tmpSize.x/2, tmpSize.x/2, tmpSize.y/2, -tmpSize.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-tmpSize.x/2, -tmpSize.y/2, -1.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnableClientState( GL_VERTEX_ARRAY );
//LOGI("engine_draw_frame (%d,%d)",width,height);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
glDrawArrays( GL_TRIANGLES, 0, 6);
static int vallllll = 0;
static float transparency = 0.0;
if (vallllll <= 1) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 0.0, 0.0, 1.0);
} else {
glColor4f(1.0, 0.0, 0.0, transparency);
}
} else if (vallllll <= 2) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 1.0, 0.0, 1.0);
} else {
glColor4f(1.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 3) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 0.0, 1.0);
} else {
glColor4f(0.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 4) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 1.0, 1.0);
} else {
glColor4f(0.0, 1.0, 1.0, transparency);
}
} else if (vallllll <= 5) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 0.0, 1.0, 1.0);
} else {
glColor4f(0.0, 0.0, 1.0, transparency);
}
} else {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll = 0;
transparency = 0.0;
glColor4f(1.0, 0.0, 1.0, 1.0);
} else {
glColor4f(1.0, 0.0, 1.0, transparency);
}
}
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
}
static ewol::Fps l_FpsSystem;
bool eSystem::Draw(bool displayEveryTime)
@ -538,7 +437,7 @@ bool eSystem::Draw(bool displayEveryTime)
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
// check if the user selected a windows
if (NULL == tmpWindows) {
BasicOpenGlDraw();
// TODO : Display a stipid texture
} else {
// Redraw all needed elements
tmpWindows->OnRegenerateDisplay();

View File

@ -147,42 +147,58 @@ void ewol::Scene::PeriodicCall(int64_t localTime)
*/
void ewol::Scene::GenDraw(DrawProperty displayProp)
{
glPushMatrix();
#ifdef __VIDEO__OPENGL_ES_2
ewol::openGL::Push();
#else
glPushMatrix();
#endif
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x,
m_origin.y,
m_size.x,
m_size.y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -100, 100);
float ratio = m_size.x / m_size.y;
m_zoom = 1.0/1000.0;
//EWOL_INFO("ratio : " << ratio);
if (ratio >= 0.0) {
glOrthoEwol(-ratio, ratio, -1, 1, -1, 1);
} else {
ratio = 1.0/ratio;
glOrthoEwol(-1, 1, -ratio, ratio, -1, 1);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
m_zoom = 1.0/1000.0;
#ifdef __VIDEO__OPENGL_ES_2
etk::Matrix tmpProjection;
if (ratio >= 0.0) {
tmpProjection = etk::matrix::Perspective(-ratio, ratio, -1, 1, -1, 1);
} else {
ratio = 1.0/ratio;
tmpProjection = etk::matrix::Perspective(-1, 1, -ratio, ratio, -1, 1);
}
etk::Matrix tmpScale = etk::matrix::Scale(m_zoom, m_zoom, m_zoom);
etk::Matrix tmpMat = tmpProjection * tmpScale;
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
#else
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (ratio >= 0.0) {
glOrthoEwol(-ratio, ratio, -1, 1, -1, 1);
} else {
ratio = 1.0/ratio;
glOrthoEwol(-1, 1, -ratio, ratio, -1, 1);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(m_zoom, m_zoom, m_zoom);
#endif
// Clear the screen with transparency ...
glClearColor(0.0, 0.0, 0.0, 1.0);
//glEnable(GL_DEPTH_TEST);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_BLEND);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glScalef(m_zoom, m_zoom, m_zoom);
//glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
// Call the widget drawing methode
OnDraw(displayProp);
//glDisable(GL_BLEND);
//glDisable(GL_DEPTH_TEST);
glPopMatrix();
#ifdef __VIDEO__OPENGL_ES_2
ewol::openGL::Pop();
#else
glPopMatrix();
#endif
}
/**

View File

@ -263,7 +263,6 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
glLoadIdentity();
glTranslatef(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
#endif
glLoadIdentity();
// Call the widget drawing methode
displayProp.m_origin.x = tmpOriginX;
displayProp.m_origin.y = tmpOriginY;

View File

@ -346,46 +346,67 @@ void ewol::WidgetScrooled::OnDraw(DrawProperty& displayProp)
*/
void ewol::WidgetScrooled::GenDraw(DrawProperty displayProp)
{
#ifdef __VIDEO__OPENGL_ES_2
ewol::openGL::Push();
#else
glPushMatrix();
#endif
if (SCROLL_MODE_CENTER == m_scroollingMode) {
glPushMatrix();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x,
m_origin.y,
m_size.x,
m_size.y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(m_zoom, m_zoom, 1.0);
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
#ifdef __VIDEO__OPENGL_ES_2
etk::Matrix tmpProjection = etk::matrix::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
etk::Matrix tmpScale = etk::matrix::Scale(m_zoom, m_zoom, 1.0);
etk::Matrix tmpTranslate = etk::matrix::Translate(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
etk::Matrix tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
#else
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(m_zoom, m_zoom, 1.0);
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
#endif
// Call the widget drawing methode
OnDraw(displayProp);
glPopMatrix();
} if (SCROLL_MODE_GAME == m_scroollingMode) {
glPushMatrix();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x,
m_origin.y,
m_size.x,
m_size.y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glScalef(m_zoom, m_zoom, 1.0);
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
#ifdef __VIDEO__OPENGL_ES_2
etk::Matrix tmpProjection = etk::matrix::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
etk::Matrix tmpTranslate = etk::matrix::Translate(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
etk::Matrix tmpMat = tmpProjection * tmpTranslate;
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
#else
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glScalef(m_zoom, m_zoom, 1.0);
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
#endif
// Call the widget drawing methode
OnDraw(displayProp);
glPopMatrix();
} else {
ewol::Widget::GenDraw(displayProp);
}
#ifdef __VIDEO__OPENGL_ES_2
ewol::openGL::Pop();
#else
glPopMatrix();
#endif
}

@ -1 +1 @@
Subproject commit ff5881a51a76141535a0e2e45c5d47bc1730b1df
Subproject commit 871233acc6e0d578b5aaedca8f5dc82c7d2132e2