Compleate abstraction of the standard openGl system to to compatible with openGL-ES-2 ==> must be tested
This commit is contained in:
parent
ed0b62b13f
commit
2eaed4f16e
102
Sources/libetk/etk/Matrix.cpp
Normal file
102
Sources/libetk/etk/Matrix.cpp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file etk/Matix.cpp
|
||||||
|
* @brief Ewol Tool Kit : generique Matrix type (Sources)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 29/08/2012
|
||||||
|
* @par Project
|
||||||
|
* Ewol TK
|
||||||
|
*
|
||||||
|
* @par Copyright
|
||||||
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Licence summary :
|
||||||
|
* You can modify and redistribute the sources code and binaries.
|
||||||
|
* You can send me the bug-fix
|
||||||
|
*
|
||||||
|
* Term of the licence in in the file licence.txt.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <etk/Matrix.h>
|
||||||
|
#include <etk/DebugInternal.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
etk::Matrix etk::matrix::Perspective(float left, float right, float bottom, float top, float nearVal, float farVal)
|
||||||
|
{
|
||||||
|
etk::Matrix tmp;
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
tmp.m_mat[iii] = 0;
|
||||||
|
}
|
||||||
|
tmp.m_mat[0] = 2.0 / (right - left);
|
||||||
|
tmp.m_mat[5] = 2.0 / (top - bottom);
|
||||||
|
tmp.m_mat[10] = -2.0 / (farVal - nearVal);
|
||||||
|
tmp.m_mat[3] = -1*(right + left) / (right - left);
|
||||||
|
tmp.m_mat[7] = -1*(top + bottom) / (top - bottom);
|
||||||
|
tmp.m_mat[11] = -1*(farVal + nearVal) / (farVal - nearVal);
|
||||||
|
tmp.m_mat[15] = 1;
|
||||||
|
//TK_INFO("Perspective :");
|
||||||
|
//etk::matrix::Display(tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Matrix etk::matrix::Translate(float x, float y, float z)
|
||||||
|
{
|
||||||
|
etk::Matrix tmp;
|
||||||
|
// set translation :
|
||||||
|
tmp.m_mat[3] = x;
|
||||||
|
tmp.m_mat[7] = y;
|
||||||
|
tmp.m_mat[11] = z;
|
||||||
|
//TK_INFO("Translate :");
|
||||||
|
//etk::matrix::Display(tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Matrix etk::matrix::Scale(float x, float y, float z)
|
||||||
|
{
|
||||||
|
etk::Matrix tmp;
|
||||||
|
// set scale :
|
||||||
|
tmp.m_mat[0] = x;
|
||||||
|
tmp.m_mat[5] = y;
|
||||||
|
tmp.m_mat[10] = z;
|
||||||
|
//TK_INFO("Scale :");
|
||||||
|
//etk::matrix::Display(tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Matrix etk::matrix::rotate(float x, float y, float z, float angleRad)
|
||||||
|
{
|
||||||
|
etk::Matrix tmp;
|
||||||
|
float cosVal = cos(angleRad);
|
||||||
|
float sinVal = sin(angleRad);
|
||||||
|
float invVal = 1.0-cosVal;
|
||||||
|
// set rotation :
|
||||||
|
tmp.m_mat[0] = x*x*invVal + cosVal;
|
||||||
|
tmp.m_mat[1] = x*y*invVal - z*cosVal;
|
||||||
|
tmp.m_mat[2] = x*z*invVal + y*sinVal;
|
||||||
|
|
||||||
|
tmp.m_mat[4] = y*x*invVal + z*sinVal;
|
||||||
|
tmp.m_mat[5] = y*y*invVal + cosVal;
|
||||||
|
tmp.m_mat[6] = y*z*invVal - x*sinVal;
|
||||||
|
|
||||||
|
tmp.m_mat[8] = z*x*invVal - y*sinVal;
|
||||||
|
tmp.m_mat[9] = z*y*invVal + x*sinVal;
|
||||||
|
tmp.m_mat[10] = z*z*invVal + cosVal;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void etk::matrix::Display(etk::Matrix& tmp)
|
||||||
|
{
|
||||||
|
TK_INFO("matrix : (" << tmp.m_mat[0] << " , " << tmp.m_mat[1] << " , " << tmp.m_mat[2] << " , " << tmp.m_mat[3] << " , ");
|
||||||
|
TK_INFO(" " << tmp.m_mat[4] << " , " << tmp.m_mat[5] << " , " << tmp.m_mat[6] << " , " << tmp.m_mat[7] << " , ");
|
||||||
|
TK_INFO(" " << tmp.m_mat[8] << " , " << tmp.m_mat[9] << " , " << tmp.m_mat[10] << " , " << tmp.m_mat[11] << " , ");
|
||||||
|
TK_INFO(" " << tmp.m_mat[12] << " , " << tmp.m_mat[13] << " , " << tmp.m_mat[14] << " , " << tmp.m_mat[15] << " )");
|
||||||
|
}
|
199
Sources/libetk/etk/Matrix.h
Normal file
199
Sources/libetk/etk/Matrix.h
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file etk/Matix.h
|
||||||
|
* @brief Ewol Tool Kit : generique Matrix type (header)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 29/08/2012
|
||||||
|
* @par Project
|
||||||
|
* Ewol TK
|
||||||
|
*
|
||||||
|
* @par Copyright
|
||||||
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Licence summary :
|
||||||
|
* You can modify and redistribute the sources code and binaries.
|
||||||
|
* You can send me the bug-fix
|
||||||
|
*
|
||||||
|
* Term of the licence in in the file licence.txt.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ETK_TYPES_MATRIX_H__
|
||||||
|
#define __ETK_TYPES_MATRIX_H__
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
|
||||||
|
class Matrix
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float m_mat[4*4];
|
||||||
|
void Identity(void) {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] = 0;
|
||||||
|
}
|
||||||
|
m_mat[0] = 1.0;
|
||||||
|
m_mat[5] = 1.0;
|
||||||
|
m_mat[10] = 1.0;
|
||||||
|
m_mat[15] = 1.0;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* Constructor
|
||||||
|
*****************************************************/
|
||||||
|
Matrix(void) {
|
||||||
|
Identity();
|
||||||
|
}
|
||||||
|
Matrix(const Matrix& obj) {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] = obj.m_mat[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Matrix(float a1, float b1, float c1, float d1,
|
||||||
|
float a2, float b2, float c2, float d2,
|
||||||
|
float a3, float b3, float c3, float d3,
|
||||||
|
float a4, float b4, float c4, float d4) {
|
||||||
|
m_mat[0] = a1;
|
||||||
|
m_mat[1] = b1;
|
||||||
|
m_mat[2] = c1;
|
||||||
|
m_mat[3] = d1;
|
||||||
|
m_mat[4] = a2;
|
||||||
|
m_mat[5] = b2;
|
||||||
|
m_mat[6] = c2;
|
||||||
|
m_mat[7] = d2;
|
||||||
|
m_mat[8] = a3;
|
||||||
|
m_mat[9] = b3;
|
||||||
|
m_mat[10] = c3;
|
||||||
|
m_mat[11] = d3;
|
||||||
|
m_mat[12] = a4;
|
||||||
|
m_mat[13] = b4;
|
||||||
|
m_mat[14] = c4;
|
||||||
|
m_mat[15] = d4;
|
||||||
|
}
|
||||||
|
Matrix(float * obj) {
|
||||||
|
if (NULL == obj) {
|
||||||
|
Identity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] = obj[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* Destructor
|
||||||
|
*****************************************************/
|
||||||
|
~Matrix() {
|
||||||
|
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* = assigment
|
||||||
|
*****************************************************/
|
||||||
|
const Matrix& operator= (const Matrix& obj ) {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] = obj.m_mat[iii];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* == operator
|
||||||
|
*****************************************************/
|
||||||
|
bool operator== (const Matrix& obj) const {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
if(m_mat[iii] != obj.m_mat[iii]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* != operator
|
||||||
|
*****************************************************/
|
||||||
|
bool operator!= (const Matrix& obj) const {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
if(m_mat[iii] != obj.m_mat[iii]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* += operator
|
||||||
|
*****************************************************/
|
||||||
|
const Matrix& operator+= (const Matrix& obj) {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] += obj.m_mat[iii];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* + operator
|
||||||
|
*****************************************************/
|
||||||
|
Matrix operator+ (const Matrix& obj) {
|
||||||
|
Matrix tmpp(*this);
|
||||||
|
tmpp += obj;
|
||||||
|
return tmpp;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* -= operator
|
||||||
|
*****************************************************/
|
||||||
|
const Matrix& operator-= (const Matrix& obj) {
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] -= obj.m_mat[iii];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* - operator
|
||||||
|
*****************************************************/
|
||||||
|
Matrix operator- (const Matrix& obj) {
|
||||||
|
Matrix tmpp(*this);
|
||||||
|
tmpp += obj;
|
||||||
|
return tmpp;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* *= operator
|
||||||
|
*****************************************************/
|
||||||
|
const Matrix& operator*= (const Matrix& obj) {
|
||||||
|
// output Matrix
|
||||||
|
float matrixOut[4*4];
|
||||||
|
for(int32_t jjj=0; jjj<4 ; jjj++) {
|
||||||
|
float* tmpLeft = m_mat + jjj*4;
|
||||||
|
for(int32_t iii=0; iii<4 ; iii++) {
|
||||||
|
const float* tmpUpper = obj.m_mat+iii;
|
||||||
|
float* tmpLeft2 = tmpLeft;
|
||||||
|
float tmpElement = 0;
|
||||||
|
for(int32_t kkk=0; kkk<4 ; kkk++) {
|
||||||
|
tmpElement += *tmpUpper * *tmpLeft2;
|
||||||
|
tmpUpper += 4;
|
||||||
|
tmpLeft2++;
|
||||||
|
}
|
||||||
|
matrixOut[jjj*4+iii] = tmpElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set it at the output
|
||||||
|
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||||
|
m_mat[iii] = matrixOut[iii];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/*****************************************************
|
||||||
|
* * operator
|
||||||
|
*****************************************************/
|
||||||
|
Matrix operator* (const Matrix& obj) {
|
||||||
|
Matrix tmpp(*this);
|
||||||
|
tmpp *= obj;
|
||||||
|
return tmpp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
namespace matrix {
|
||||||
|
Matrix Perspective(float left, float right, float bottom, float top, float nearVal, float farVal);
|
||||||
|
Matrix Translate(float x=0.0, float y=0.0, float z=0.0);
|
||||||
|
Matrix Scale(float x=1.0, float y=1.0, float z=1.0);
|
||||||
|
Matrix rotate(float x, float y, float z, float angleRad=0.0);
|
||||||
|
void Display(Matrix& tmp);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -101,7 +101,7 @@ template <typename T> class Vector2D
|
|||||||
Vector2D<T> tmpp(x,y);
|
Vector2D<T> tmpp(x,y);
|
||||||
tmpp.x -= (T)obj.x;
|
tmpp.x -= (T)obj.x;
|
||||||
tmpp.y -= (T)obj.y;
|
tmpp.y -= (T)obj.y;
|
||||||
return *this;
|
return tmpp;
|
||||||
}
|
}
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* /= operator
|
* /= operator
|
||||||
@ -118,7 +118,7 @@ template <typename T> class Vector2D
|
|||||||
Vector2D<T> tmpp(x,y);
|
Vector2D<T> tmpp(x,y);
|
||||||
tmpp.x /= (T)obj.x;
|
tmpp.x /= (T)obj.x;
|
||||||
tmpp.y /= (T)obj.y;
|
tmpp.y /= (T)obj.y;
|
||||||
return *this;
|
return tmpp;
|
||||||
}
|
}
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* *= operator
|
* *= operator
|
||||||
@ -135,7 +135,7 @@ template <typename T> class Vector2D
|
|||||||
Vector2D<T> tmpp(x,y);
|
Vector2D<T> tmpp(x,y);
|
||||||
tmpp.x *= (T)obj.x;
|
tmpp.x *= (T)obj.x;
|
||||||
tmpp.y *= (T)obj.y;
|
tmpp.y *= (T)obj.y;
|
||||||
return *this;
|
return tmpp;
|
||||||
}
|
}
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* ++ operator
|
* ++ operator
|
||||||
|
@ -10,7 +10,8 @@ FILE_LIST = \
|
|||||||
etk/Stream.cpp \
|
etk/Stream.cpp \
|
||||||
etk/File.cpp \
|
etk/File.cpp \
|
||||||
etk/RegExp.cpp \
|
etk/RegExp.cpp \
|
||||||
etk/tool.cpp
|
etk/tool.cpp \
|
||||||
|
etk/Matrix.cpp
|
||||||
|
|
||||||
ifeq ("$(TARGET_OS)","Windows")
|
ifeq ("$(TARGET_OS)","Windows")
|
||||||
FILE_LIST += etk/Mutex.Windows.cpp
|
FILE_LIST += etk/Mutex.Windows.cpp
|
||||||
|
@ -26,12 +26,11 @@ LOCAL_EXPORT_LDLIBS := -lGL -lX11
|
|||||||
LOCAL_CFLAGS := -Wno-write-strings \
|
LOCAL_CFLAGS := -Wno-write-strings \
|
||||||
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
|
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
|
||||||
-DLUA_COMPAT_ALL \
|
-DLUA_COMPAT_ALL \
|
||||||
-D__VIDEO__OPENGL_ES_2 \
|
|
||||||
-Wall
|
-Wall
|
||||||
|
|
||||||
|
|
||||||
#LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
|
LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
|
||||||
#LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
|
LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
|
||||||
|
|
||||||
|
|
||||||
# load the common sources file of the platform
|
# load the common sources file of the platform
|
||||||
|
@ -196,9 +196,9 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::Font*& object)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object)
|
bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object)
|
||||||
{
|
{
|
||||||
EWOL_VERBOSE("KEEP : Program : file : \"" << filename << "\"");
|
EWOL_VERBOSE("KEEP : Program : file : \"" << filename << "\"");
|
||||||
object = static_cast<ewol::Program*>(LocalKeep(filename));
|
object = static_cast<ewol::Program*>(LocalKeep(filename));
|
||||||
if (NULL != object) {
|
if (NULL != object) {
|
||||||
@ -212,11 +212,12 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object)
|
|||||||
}
|
}
|
||||||
LocalAdd(object);
|
LocalAdd(object);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object)
|
bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object)
|
||||||
{
|
{
|
||||||
EWOL_VERBOSE("KEEP : Shader : file : \"" << filename << "\"");
|
EWOL_VERBOSE("KEEP : Shader : file : \"" << filename << "\"");
|
||||||
object = static_cast<ewol::Shader*>(LocalKeep(filename));
|
object = static_cast<ewol::Shader*>(LocalKeep(filename));
|
||||||
if (NULL != object) {
|
if (NULL != object) {
|
||||||
@ -230,7 +231,8 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object)
|
|||||||
}
|
}
|
||||||
LocalAdd(object);
|
LocalAdd(object);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ewol::resource::Keep(ewol::Texture*& object)
|
bool ewol::resource::Keep(ewol::Texture*& object)
|
||||||
{
|
{
|
||||||
@ -315,18 +317,22 @@ void ewol::resource::Release(ewol::Font*& object)
|
|||||||
Release(object2);
|
Release(object2);
|
||||||
object = NULL;
|
object = NULL;
|
||||||
}
|
}
|
||||||
void ewol::resource::Release(ewol::Program*& object)
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
{
|
void ewol::resource::Release(ewol::Program*& object)
|
||||||
|
{
|
||||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||||
Release(object2);
|
Release(object2);
|
||||||
object = NULL;
|
object = NULL;
|
||||||
}
|
}
|
||||||
void ewol::resource::Release(ewol::Shader*& object)
|
#endif
|
||||||
{
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
void ewol::resource::Release(ewol::Shader*& object)
|
||||||
|
{
|
||||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||||
Release(object2);
|
Release(object2);
|
||||||
object = NULL;
|
object = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
void ewol::resource::Release(ewol::Texture*& object)
|
void ewol::resource::Release(ewol::Texture*& object)
|
||||||
{
|
{
|
||||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||||
|
@ -50,16 +50,20 @@ namespace ewol
|
|||||||
// return the type of the resource ...
|
// return the type of the resource ...
|
||||||
bool Keep(etk::UString& filename, ewol::TexturedFont*& object);
|
bool Keep(etk::UString& filename, ewol::TexturedFont*& object);
|
||||||
bool Keep(etk::UString& filename, ewol::Font*& object);
|
bool Keep(etk::UString& filename, ewol::Font*& object);
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
bool Keep(etk::UString& filename, ewol::Program*& object);
|
bool Keep(etk::UString& filename, ewol::Program*& object);
|
||||||
bool Keep(etk::UString& filename, ewol::Shader*& object);
|
bool Keep(etk::UString& filename, ewol::Shader*& object);
|
||||||
|
#endif
|
||||||
bool Keep(ewol::Texture*& object); // no name needed here ...
|
bool Keep(ewol::Texture*& object); // no name needed here ...
|
||||||
bool Keep(etk::UString& filename, ewol::TextureFile*& object, Vector2D<int32_t> size);
|
bool Keep(etk::UString& filename, ewol::TextureFile*& object, Vector2D<int32_t> size);
|
||||||
|
|
||||||
void Release(ewol::Resource*& object);
|
void Release(ewol::Resource*& object);
|
||||||
void Release(ewol::TexturedFont*& object);
|
void Release(ewol::TexturedFont*& object);
|
||||||
void Release(ewol::Font*& object);
|
void Release(ewol::Font*& object);
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
void Release(ewol::Program*& object);
|
void Release(ewol::Program*& object);
|
||||||
void Release(ewol::Shader*& object);
|
void Release(ewol::Shader*& object);
|
||||||
|
#endif
|
||||||
void Release(ewol::Texture*& object);
|
void Release(ewol::Texture*& object);
|
||||||
void Release(ewol::TextureFile*& object);
|
void Release(ewol::TextureFile*& object);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ ewol::OObject2DColored::OObject2DColored(void)
|
|||||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -52,7 +52,9 @@ ewol::OObject2DColored::~OObject2DColored(void)
|
|||||||
{
|
{
|
||||||
m_coord.Clear();
|
m_coord.Clear();
|
||||||
m_coordColor.Clear();
|
m_coordColor.Clear();
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::resource::Release(m_GLprogram);
|
ewol::resource::Release(m_GLprogram);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,30 +63,21 @@ void ewol::OObject2DColored::Draw(void)
|
|||||||
if (m_coord.Size()<=0) {
|
if (m_coord.Size()<=0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
if (m_GLprogram==NULL) {
|
if (m_GLprogram==NULL) {
|
||||||
EWOL_ERROR("No shader ...");
|
EWOL_ERROR("No shader ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glScalef(m_scaling.x, m_scaling.y, 1.0);
|
glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
|
// set Matrix : translation/positionMatrix
|
||||||
|
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
|
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// position :
|
// position :
|
||||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
2, // number of elements per vertex, here (x,y)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coord[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLPosition);
|
|
||||||
// color :
|
// color :
|
||||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
4, // number of elements per vertex, here (r,g,b,a)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordColor[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLColor);
|
|
||||||
// Request the draw od the elements :
|
// Request the draw od the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
@ -99,8 +92,7 @@ void ewol::OObject2DColored::Draw(void)
|
|||||||
|
|
||||||
// Set the vertex pointer to our vertex data
|
// Set the vertex pointer to our vertex data
|
||||||
glVertexPointer(2, GL_FLOAT, 0, &m_coord[0] );
|
glVertexPointer(2, GL_FLOAT, 0, &m_coord[0] );
|
||||||
//glColorPointer(4, oglTypeFloat_t, 0, &m_coordColor[0] );
|
glColorPointer(4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] );
|
||||||
glColorPointer(4, GL_FLOAT, 0, &m_coordColor[0] );
|
|
||||||
// Render : draw all of the triangles at once
|
// Render : draw all of the triangles at once
|
||||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||||
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
|
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
|
||||||
|
@ -39,9 +39,9 @@ namespace ewol {
|
|||||||
protected:
|
protected:
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::Program* m_GLprogram;
|
ewol::Program* m_GLprogram;
|
||||||
GLint m_GLPosition;
|
int32_t m_GLPosition;
|
||||||
GLint m_GLMatrix;
|
int32_t m_GLMatrix;
|
||||||
GLint m_GLColor;
|
int32_t m_GLColor;
|
||||||
#endif
|
#endif
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
@ -80,7 +80,7 @@ ewol::OObject2DTextColored::OObject2DTextColored(etk::UString fontName, int32_t
|
|||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -101,7 +101,7 @@ ewol::OObject2DTextColored::OObject2DTextColored(void) :
|
|||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -137,39 +137,19 @@ void ewol::OObject2DTextColored::Draw(void)
|
|||||||
}
|
}
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
glEnable(GL_TEXTURE_2D);
|
// set Matrix : translation/positionMatrix
|
||||||
glActiveTexture(GL_TEXTURE0);
|
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
glBindTexture(GL_TEXTURE_2D, m_font->GetId());
|
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// TextureID
|
// TextureID
|
||||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
|
||||||
// position :
|
// position :
|
||||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
2, // number of elements per vertex, here (x,y)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coord[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLPosition);
|
|
||||||
// Texture :
|
// Texture :
|
||||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||||
2, // number of elements per vertex, here (u,v)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordTex[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLtexture);
|
|
||||||
// color :
|
// color :
|
||||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
4, // number of elements per vertex, here (r,g,b,a)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordColor[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLColor);
|
|
||||||
|
|
||||||
// Request the draw od the elements :
|
// Request the draw od the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
#else
|
#else
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@ -47,11 +47,11 @@ namespace ewol {
|
|||||||
protected:
|
protected:
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::Program* m_GLprogram;
|
ewol::Program* m_GLprogram;
|
||||||
GLint m_GLPosition;
|
int32_t m_GLPosition;
|
||||||
GLint m_GLMatrix;
|
int32_t m_GLMatrix;
|
||||||
GLint m_GLColor;
|
int32_t m_GLColor;
|
||||||
GLint m_GLtexture;
|
int32_t m_GLtexture;
|
||||||
GLint m_GLtexID;
|
int32_t m_GLtexID;
|
||||||
#endif
|
#endif
|
||||||
ewol::TexturedFont* m_font; //!< ewol font system
|
ewol::TexturedFont* m_font; //!< ewol font system
|
||||||
draw::Color m_color; //!< tmp text color ...
|
draw::Color m_color; //!< tmp text color ...
|
||||||
|
@ -44,7 +44,7 @@ ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX
|
|||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -77,39 +77,19 @@ void ewol::OObject2DTextured::Draw(void)
|
|||||||
}
|
}
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
glEnable(GL_TEXTURE_2D);
|
// set Matrix : translation/positionMatrix
|
||||||
glActiveTexture(GL_TEXTURE0);
|
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
glBindTexture(GL_TEXTURE_2D, m_resource->GetId());
|
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// TextureID
|
// TextureID
|
||||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
|
||||||
// position :
|
// position :
|
||||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
2, // number of elements per vertex, here (x,y)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coord[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLPosition);
|
|
||||||
// Texture :
|
// Texture :
|
||||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||||
2, // number of elements per vertex, here (u,v)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordTex[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLtexture);
|
|
||||||
// color :
|
// color :
|
||||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
4, // number of elements per vertex, here (r,g,b,a)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordColor[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLColor);
|
|
||||||
|
|
||||||
// Request the draw od the elements :
|
// Request the draw od the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
#else
|
#else
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
|
@ -42,11 +42,11 @@ namespace ewol {
|
|||||||
protected:
|
protected:
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::Program* m_GLprogram;
|
ewol::Program* m_GLprogram;
|
||||||
GLint m_GLPosition;
|
int32_t m_GLPosition;
|
||||||
GLint m_GLMatrix;
|
int32_t m_GLMatrix;
|
||||||
GLint m_GLColor;
|
int32_t m_GLColor;
|
||||||
GLint m_GLtexture;
|
int32_t m_GLtexture;
|
||||||
GLint m_GLtexID;
|
int32_t m_GLtexID;
|
||||||
#endif
|
#endif
|
||||||
ewol::TextureFile* m_resource; //!< texture resources
|
ewol::TextureFile* m_resource; //!< texture resources
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
|
@ -44,7 +44,7 @@ ewol::OObject3DTextured::OObject3DTextured(etk::UString textureName, float sizeX
|
|||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -77,39 +77,19 @@ void ewol::OObject3DTextured::Draw(void)
|
|||||||
}
|
}
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
glEnable(GL_TEXTURE_2D);
|
// set Matrix : translation/positionMatrix
|
||||||
glActiveTexture(GL_TEXTURE0);
|
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
glBindTexture(GL_TEXTURE_2D, m_resource->GetId());
|
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// TextureID
|
// TextureID
|
||||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
|
||||||
// position :
|
// position :
|
||||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_coord[0]);
|
||||||
3, // number of elements per vertex, here (x,y)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coord[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLPosition);
|
|
||||||
// Texture :
|
// Texture :
|
||||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||||
2, // number of elements per vertex, here (u,v)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordTex[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLtexture);
|
|
||||||
// color :
|
// color :
|
||||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
4, // number of elements per vertex, here (r,g,b,a)
|
|
||||||
GL_FLOAT, // the type of each element
|
|
||||||
GL_FALSE, // take our values as-is
|
|
||||||
0, // no extra data between each position
|
|
||||||
&m_coordColor[0]); // Pointer on the buffer
|
|
||||||
glEnableVertexAttribArray(m_GLColor);
|
|
||||||
|
|
||||||
// Request the draw od the elements :
|
// Request the draw od the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
#else
|
#else
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
|
@ -42,11 +42,11 @@ namespace ewol {
|
|||||||
protected:
|
protected:
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::Program* m_GLprogram;
|
ewol::Program* m_GLprogram;
|
||||||
GLint m_GLPosition;
|
int32_t m_GLPosition;
|
||||||
GLint m_GLMatrix;
|
int32_t m_GLMatrix;
|
||||||
GLint m_GLColor;
|
int32_t m_GLColor;
|
||||||
GLint m_GLtexture;
|
int32_t m_GLtexture;
|
||||||
GLint m_GLtexID;
|
int32_t m_GLtexID;
|
||||||
#endif
|
#endif
|
||||||
ewol::TextureFile* m_resource; //!< texture resources
|
ewol::TextureFile* m_resource; //!< texture resources
|
||||||
etk::Vector<Vector3D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector3D<float> > m_coord; //!< internal coord of the object
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/openGL/Program.h>
|
#include <ewol/openGL/Program.h>
|
||||||
@ -29,7 +31,8 @@
|
|||||||
|
|
||||||
ewol::Program::Program(etk::UString& filename) :
|
ewol::Program::Program(etk::UString& filename) :
|
||||||
ewol::Resource(filename),
|
ewol::Resource(filename),
|
||||||
m_program(0)
|
m_program(0),
|
||||||
|
m_hasTexture(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// load data from file "all the time ..."
|
// load data from file "all the time ..."
|
||||||
@ -89,6 +92,8 @@ ewol::Program::~Program(void)
|
|||||||
glDeleteProgram(m_program);
|
glDeleteProgram(m_program);
|
||||||
m_program = 0;
|
m_program = 0;
|
||||||
}
|
}
|
||||||
|
m_elementList.Clear();
|
||||||
|
m_hasTexture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkGlError(const char* op)
|
static void checkGlError(const char* op)
|
||||||
@ -131,55 +136,104 @@ bool ewol::Program::CreateAndLink(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Set it dynamic to prevent reload system error ...
|
int32_t ewol::Program::GetAttribute(etk::UString tmpElement)
|
||||||
GLint ewol::Program::GetAttribute(etk::UString& tmpElement)
|
|
||||||
{
|
{
|
||||||
GLint elem = glGetAttribLocation(m_program, tmpElement.c_str());
|
// check if it exist previously :
|
||||||
if (elem<0) {
|
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
|
||||||
|
if (m_elementList[iii].m_name == tmpElement) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progAttributeElement tmp;
|
||||||
|
tmp.m_name = tmpElement;
|
||||||
|
tmp.m_isAttribute = true;
|
||||||
|
tmp.m_elementId = glGetAttribLocation(m_program, tmp.m_name.c_str());
|
||||||
|
if (tmp.m_elementId<0) {
|
||||||
checkGlError("glGetAttribLocation");
|
checkGlError("glGetAttribLocation");
|
||||||
EWOL_INFO("glGetAttribLocation(\"" << tmpElement << "\") = " << elem);
|
EWOL_INFO("glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return elem;
|
m_elementList.PushBack(tmp);
|
||||||
}
|
return m_elementList.Size()-1;
|
||||||
GLint ewol::Program::GetAttribute(const char* tmpElement)
|
|
||||||
{
|
|
||||||
GLint elem = glGetAttribLocation(m_program, tmpElement);
|
|
||||||
if (elem<0) {
|
|
||||||
checkGlError("glGetAttribLocation");
|
|
||||||
EWOL_INFO("glGetAttribLocation(\"" << tmpElement << "\") = " << elem);
|
|
||||||
}
|
|
||||||
return elem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint ewol::Program::GetUniform(etk::UString& tmpElement)
|
int32_t ewol::Program::GetUniform(etk::UString tmpElement)
|
||||||
{
|
{
|
||||||
GLint elem = glGetUniformLocation(m_program, tmpElement.c_str());
|
// check if it exist previously :
|
||||||
if (elem<0) {
|
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
|
||||||
|
if (m_elementList[iii].m_name == tmpElement) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progAttributeElement tmp;
|
||||||
|
tmp.m_name = tmpElement;
|
||||||
|
tmp.m_isAttribute = false;
|
||||||
|
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
|
||||||
|
if (tmp.m_elementId<0) {
|
||||||
checkGlError("glGetUniformLocation");
|
checkGlError("glGetUniformLocation");
|
||||||
EWOL_INFO("glGetUniformLocation(\"" << tmpElement << "\") = " << elem);
|
EWOL_INFO("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return elem;
|
m_elementList.PushBack(tmp);
|
||||||
|
return m_elementList.Size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample)
|
||||||
GLint ewol::Program::GetUniform(const char* tmpElement)
|
|
||||||
{
|
{
|
||||||
GLint elem = glGetUniformLocation(m_program, tmpElement);
|
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||||
if (elem<0) {
|
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||||
checkGlError("glGetUniformLocation");
|
return;
|
||||||
EWOL_INFO("glGetUniformLocation(\"" << tmpElement << "\") = " << elem);
|
|
||||||
}
|
}
|
||||||
return elem;
|
glVertexAttribPointer(m_elementList[idElem].m_elementId, // attribute ID of OpenGL
|
||||||
|
nbElement, // number of elements per vertex, here (r,g,b,a)
|
||||||
|
GL_FLOAT, // the type of each element
|
||||||
|
GL_FALSE, // take our values as-is
|
||||||
|
jumpBetweenSample, // no extra data between each position
|
||||||
|
pointer); // Pointer on the buffer
|
||||||
|
glEnableVertexAttribArray(m_elementList[idElem].m_elementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Program::SendUniformMatrix4fv(int32_t idElem, int32_t nbElement, float* pointer)
|
||||||
|
{
|
||||||
|
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||||
|
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glUniformMatrix4fv(m_elementList[idElem].m_elementId, nbElement, GL_TRUE, pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Program::Use(void)
|
void ewol::Program::Use(void)
|
||||||
{
|
{
|
||||||
glUseProgram(m_program);
|
glUseProgram(m_program);
|
||||||
checkGlError("glUseProgram");
|
checkGlError("glUseProgram");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Program::SetTexture0(int32_t idElem, GLint textureOpenGlID)
|
||||||
|
{
|
||||||
|
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
// set the textureID
|
||||||
|
glBindTexture(GL_TEXTURE_2D, textureOpenGlID);
|
||||||
|
// Set the texture on the uniform attribute
|
||||||
|
glUniform1i(m_elementList[idElem].m_elementId, /*GL_TEXTURE*/0);
|
||||||
|
m_hasTexture = true;
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::Program::UnUse(void)
|
void ewol::Program::UnUse(void)
|
||||||
{
|
{
|
||||||
|
if (true == m_hasTexture) {
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
m_hasTexture = false;
|
||||||
|
}
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
checkGlError("glUseProgram");
|
checkGlError("glUseProgram");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -24,35 +24,44 @@
|
|||||||
|
|
||||||
#ifndef __OPEN_GL__PROGRAM_H__
|
#ifndef __OPEN_GL__PROGRAM_H__
|
||||||
#define __OPEN_GL__PROGRAM_H__
|
#define __OPEN_GL__PROGRAM_H__
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <ewol/Resource.h>
|
||||||
|
#include <ewol/openGL/openGL.h>
|
||||||
|
#include <ewol/openGL/Shader.h>
|
||||||
|
|
||||||
#include <etk/Types.h>
|
namespace ewol
|
||||||
#include <ewol/Debug.h>
|
{
|
||||||
#include <ewol/Resource.h>
|
class progAttributeElement
|
||||||
#include <ewol/openGL/openGL.h>
|
{
|
||||||
#include <ewol/openGL/Shader.h>
|
public :
|
||||||
|
etk::UString m_name;
|
||||||
|
GLint m_elementId;
|
||||||
|
bool m_isAttribute;
|
||||||
|
};
|
||||||
|
|
||||||
namespace ewol
|
|
||||||
{
|
|
||||||
class Program : public ewol::Resource
|
class Program : public ewol::Resource
|
||||||
{
|
{
|
||||||
private :
|
private :
|
||||||
GLuint m_program;
|
GLuint m_program;
|
||||||
etk::Vector<ewol::Shader*> m_shaderList;
|
etk::Vector<ewol::Shader*> m_shaderList;
|
||||||
|
etk::Vector<ewol::progAttributeElement> m_elementList;
|
||||||
|
bool m_hasTexture;
|
||||||
public:
|
public:
|
||||||
Program(etk::UString& filename);
|
Program(etk::UString& filename);
|
||||||
virtual ~Program(void);
|
virtual ~Program(void);
|
||||||
const char* GetType(void) { return "ewol::Program"; };
|
const char* GetType(void) { return "ewol::Program"; };
|
||||||
GLuint GetGL_ID(void) { return m_program; };
|
|
||||||
bool CreateAndLink(void);
|
bool CreateAndLink(void);
|
||||||
GLint GetAttribute(etk::UString& tmpElement);
|
int32_t GetAttribute(etk::UString tmpElement);
|
||||||
GLint GetAttribute(const char* tmpElement);
|
void SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample=0);
|
||||||
GLint GetUniform(etk::UString& tmpElement);
|
int32_t GetUniform(etk::UString tmpElement);
|
||||||
GLint GetUniform(const char* tmpElement);
|
void SendUniformMatrix4fv(int32_t idElem, int32_t nbElement, float* pointer);
|
||||||
void Use(void);
|
void Use(void);
|
||||||
|
void SetTexture0(int32_t idElem, GLint textureOpenGlID);
|
||||||
void UnUse(void);
|
void UnUse(void);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <etk/File.h>
|
#include <etk/File.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
@ -132,3 +134,5 @@ bool ewol::Shader::CompileAndSendShader(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
|
|
||||||
#ifndef __OPEN_GL__SHADER_H__
|
#ifndef __OPEN_GL__SHADER_H__
|
||||||
#define __OPEN_GL__SHADER_H__
|
#define __OPEN_GL__SHADER_H__
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <ewol/Resource.h>
|
||||||
|
#include <ewol/openGL/openGL.h>
|
||||||
|
|
||||||
#include <etk/Types.h>
|
namespace ewol
|
||||||
#include <ewol/Debug.h>
|
{
|
||||||
#include <ewol/Resource.h>
|
|
||||||
#include <ewol/openGL/openGL.h>
|
|
||||||
|
|
||||||
namespace ewol
|
|
||||||
{
|
|
||||||
class Shader : public ewol::Resource
|
class Shader : public ewol::Resource
|
||||||
{
|
{
|
||||||
private :
|
private :
|
||||||
@ -46,8 +46,7 @@ namespace ewol
|
|||||||
GLenum GetShaderType(void) { return m_type; };
|
GLenum GetShaderType(void) { return m_type; };
|
||||||
bool CompileAndSendShader(void);
|
bool CompileAndSendShader(void);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/openGL/openGL.h>
|
#include <ewol/openGL/openGL.h>
|
||||||
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
|
|
||||||
void glOrthoMatrix(GLfloat left,
|
void glOrthoMatrix(GLfloat left,
|
||||||
@ -67,107 +68,72 @@ void glOrthoEwol(GLfloat left,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ewol::OglMatrix::OglMatrix(float left, float right, float bottom, float top, float nearVal, float farVal)
|
etk::Vector<etk::Matrix> l_matrixList;
|
||||||
|
|
||||||
|
void ewol::openGL::Init(void)
|
||||||
{
|
{
|
||||||
Generate(left, right, bottom, top, nearVal, farVal);
|
// remove deprecated pb ...
|
||||||
|
l_matrixList.Clear();
|
||||||
|
etk::Matrix tmpMat;
|
||||||
|
l_matrixList.PushBack(tmpMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OglMatrix::Generate(float left, float right, float bottom, float top, float nearVal, float farVal)
|
|
||||||
|
void ewol::openGL::UnInit(void)
|
||||||
{
|
{
|
||||||
int iii;
|
l_matrixList.Clear();
|
||||||
for(iii=0; iii<4*4 ; iii++) {
|
|
||||||
m_Matrix[iii] = 0;
|
|
||||||
}
|
|
||||||
m_Matrix[0] = 2.0 / (right - left);
|
|
||||||
m_Matrix[5] = 2.0 / (top - bottom);
|
|
||||||
m_Matrix[10] = -2.0 / (farVal - nearVal);
|
|
||||||
m_Matrix[3] = -1*(right + left) / (right - left);
|
|
||||||
m_Matrix[7] = -1*(top + bottom) / (top - bottom);
|
|
||||||
m_Matrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
|
|
||||||
m_Matrix[15] = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::OglMatrix::~OglMatrix()
|
void ewol::openGL::SetBasicMatrix(etk::Matrix& newOne)
|
||||||
{
|
{
|
||||||
|
if (l_matrixList.Size()!=1) {
|
||||||
}
|
EWOL_ERROR("matrix is not corect size in the stack : " << l_matrixList.Size());
|
||||||
//http://www.siteduzero.com/tutoriel-3-5003-les-matrices.html
|
|
||||||
static void MultiplyMatrix(float* inOut, float* mult)
|
|
||||||
{
|
|
||||||
|
|
||||||
// output Matrix
|
|
||||||
float matrixOut[4*4];
|
|
||||||
for(int32_t jjj=0; jjj<4 ; jjj++) {
|
|
||||||
float* tmpLeft = inOut + jjj*4;
|
|
||||||
for(int32_t iii=0; iii<4 ; iii++) {
|
|
||||||
float* tmpUpper = mult+iii;
|
|
||||||
float* tmpLeft2 = tmpLeft;
|
|
||||||
float tmpElement = 0;
|
|
||||||
for(int32_t kkk=0; kkk<4 ; kkk++) {
|
|
||||||
tmpElement += *tmpUpper * *tmpLeft2;
|
|
||||||
tmpUpper += 4;
|
|
||||||
tmpLeft2++;
|
|
||||||
}
|
|
||||||
matrixOut[jjj*4+iii] = tmpElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// set it at the output
|
|
||||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
|
||||||
inOut[iii] = matrixOut[iii];
|
|
||||||
}
|
}
|
||||||
|
l_matrixList.Clear();
|
||||||
|
l_matrixList.PushBack(newOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OglMatrix::Translate(float x, float y, float z)
|
void ewol::openGL::SetMatrix(etk::Matrix& newOne)
|
||||||
{
|
{
|
||||||
float matrix[4*4];
|
if (l_matrixList.Size()==0) {
|
||||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||||
matrix[iii] = 0;
|
l_matrixList.PushBack(newOne);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// set identity :
|
l_matrixList[l_matrixList.Size()-1] = newOne;
|
||||||
matrix[0] = 1;
|
|
||||||
matrix[5] = 1;
|
|
||||||
matrix[10] = 1;
|
|
||||||
matrix[15] = 1;
|
|
||||||
// set translation :
|
|
||||||
matrix[3] = x;
|
|
||||||
matrix[7] = y;
|
|
||||||
matrix[11] = y;
|
|
||||||
// generate output :
|
|
||||||
MultiplyMatrix(m_Matrix, matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OglMatrix::Scale(float x, float y, float z)
|
void ewol::openGL::Push(void)
|
||||||
{
|
{
|
||||||
float matrix[4*4];
|
if (l_matrixList.Size()==0) {
|
||||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||||
matrix[iii] = 0;
|
etk::Matrix tmp;
|
||||||
|
l_matrixList.PushBack(tmp);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// set identity :
|
etk::Matrix tmp = l_matrixList[l_matrixList.Size()-1];
|
||||||
matrix[0] = 1;
|
l_matrixList.PushBack(tmp);
|
||||||
matrix[5] = 1;
|
|
||||||
matrix[10] = 1;
|
|
||||||
matrix[15] = 1;
|
|
||||||
// set scale :
|
|
||||||
matrix[0] = x;
|
|
||||||
matrix[5] = y;
|
|
||||||
matrix[10] = z;
|
|
||||||
// generate output :
|
|
||||||
MultiplyMatrix(m_Matrix, matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OglMatrix::rotate(float x, float y, float z, float angle)
|
void ewol::openGL::Pop(void)
|
||||||
{
|
{
|
||||||
float matrix[4*4];
|
if (l_matrixList.Size()<=1) {
|
||||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||||
matrix[iii] = 0;
|
l_matrixList.Clear();
|
||||||
|
etk::Matrix tmp;
|
||||||
|
l_matrixList.PushBack(tmp);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// set identity :
|
l_matrixList.PopBack();
|
||||||
matrix[0] = 1;
|
}
|
||||||
matrix[5] = 1;
|
|
||||||
matrix[10] = 1;
|
etk::Matrix& ewol::openGL::GetMatrix(void)
|
||||||
matrix[15] = 1;
|
{
|
||||||
// TODO ...
|
if (l_matrixList.Size()==0) {
|
||||||
// generate output :
|
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||||
MultiplyMatrix(m_Matrix, matrix);
|
etk::Matrix tmp;
|
||||||
|
l_matrixList.PushBack(tmp);
|
||||||
|
}
|
||||||
|
return l_matrixList[l_matrixList.Size()-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,29 +25,38 @@
|
|||||||
#ifndef __OPEN_GL_H__
|
#ifndef __OPEN_GL_H__
|
||||||
#define __OPEN_GL_H__
|
#define __OPEN_GL_H__
|
||||||
|
|
||||||
|
#include <etk/Matrix.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__TARGET_OS__Linux)
|
#if defined(__TARGET_OS__Linux) || defined(__TARGET_OS__Windows)
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
// TO ENABLE THE SHADER api ...
|
// TO ENABLE THE SHADER api ...
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
// This is to prevent the use of these element that is not allowed in the OpenGL ES
|
||||||
|
#undef glVertexPointer
|
||||||
|
#undef glTexCoordPointer
|
||||||
|
#undef glColorPointer
|
||||||
|
#undef glPopMatrix
|
||||||
|
#undef glPushMatrix
|
||||||
|
#undef glMatrixMode
|
||||||
|
#undef glLoadIdentity
|
||||||
|
#undef glTranslatef
|
||||||
|
#endif
|
||||||
#elif defined(__TARGET_OS__Android)
|
#elif defined(__TARGET_OS__Android)
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
// Include openGL ES 2
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
#else
|
#else
|
||||||
|
// Include openGL ES 1
|
||||||
|
#include <GLES/gl.h>
|
||||||
#endif
|
#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>
|
|
||||||
#elif defined(__TARGET_OS__MacOs)
|
#elif defined(__TARGET_OS__MacOs)
|
||||||
|
|
||||||
#elif defined(__TARGET_OS__IOs)
|
#elif defined(__TARGET_OS__IOs)
|
||||||
@ -56,18 +65,20 @@ extern "C" {
|
|||||||
#error you need to specify a __TAGET_OS__ ...
|
#error you need to specify a __TAGET_OS__ ...
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO : Remove : deprecated ....
|
||||||
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class OglMatrix{
|
namespace openGL {
|
||||||
public :
|
void Init(void);
|
||||||
float m_Matrix[4*4];
|
void UnInit(void);
|
||||||
OglMatrix(float left, float right, float bottom, float top, float nearVal, float farVal);
|
// reset the basic element at this one ... remove all previous
|
||||||
~OglMatrix();
|
void SetBasicMatrix(etk::Matrix& newOne);
|
||||||
void Generate(float left, float right, float bottom, float top, float nearVal, float farVal);
|
// this is the same system as openGL-ES-1 but in openGL-ES-2 (here is the abstraction)
|
||||||
void Translate(float x=0.0, float y=0.0, float z=0.0);
|
void SetMatrix(etk::Matrix& newOne);
|
||||||
void Scale(float x=1.0, float y=1.0, float z=1.0);
|
void Push(void);
|
||||||
void rotate(float x, float y, float z, float angle=0.0);
|
void Pop(void);
|
||||||
|
etk::Matrix& GetMatrix(void);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -240,6 +240,7 @@ void eSystem::Init(void)
|
|||||||
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
|
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
|
||||||
EWOL_INFO("Build Date: " BUILD_TIME);
|
EWOL_INFO("Build Date: " BUILD_TIME);
|
||||||
etk::InitDefaultFolder("ewolApplNoName");
|
etk::InitDefaultFolder("ewolApplNoName");
|
||||||
|
ewol::openGL::Init();
|
||||||
ewol::EObjectManager::Init();
|
ewol::EObjectManager::Init();
|
||||||
ewol::EObjectMessageMultiCast::Init();
|
ewol::EObjectMessageMultiCast::Init();
|
||||||
l_managementInput.Reset();
|
l_managementInput.Reset();
|
||||||
@ -271,6 +272,7 @@ void eSystem::UnInit(void)
|
|||||||
ewol::EObjectMessageMultiCast::UnInit();
|
ewol::EObjectMessageMultiCast::UnInit();
|
||||||
ewol::EObjectManager::UnInit();
|
ewol::EObjectManager::UnInit();
|
||||||
ewol::resource::UnInit();
|
ewol::resource::UnInit();
|
||||||
|
ewol::openGL::UnInit();
|
||||||
l_managementInput.Reset();
|
l_managementInput.Reset();
|
||||||
l_msgSystem.Clean();
|
l_msgSystem.Clean();
|
||||||
}
|
}
|
||||||
|
@ -1178,19 +1178,6 @@ int main(int argc, char *argv[])
|
|||||||
etk::File myIcon = APP_Icon();
|
etk::File myIcon = APP_Icon();
|
||||||
SetIcon(myIcon);
|
SetIcon(myIcon);
|
||||||
|
|
||||||
GLuint shader;
|
|
||||||
/* creation */
|
|
||||||
shader = glCreateShader(GL_VERTEX_SHADER);
|
|
||||||
if(shader == 0) {
|
|
||||||
/* erreur de creation :( */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* utilisation ... */
|
|
||||||
/* suppression */
|
|
||||||
glDeleteShader(shader);
|
|
||||||
shader = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// Run ...
|
// Run ...
|
||||||
X11_Run();
|
X11_Run();
|
||||||
// close X11 :
|
// close X11 :
|
||||||
|
@ -225,7 +225,11 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
|||||||
// widget is hidden ...
|
// widget is hidden ...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
ewol::openGL::Push();
|
||||||
|
#else
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
#endif
|
||||||
if( (displayProp.m_origin.x > m_origin.x)
|
if( (displayProp.m_origin.x > m_origin.x)
|
||||||
|| (displayProp.m_origin.x + displayProp.m_size.x < m_size.x + m_origin.x) ) {
|
|| (displayProp.m_origin.x + displayProp.m_size.x < m_size.x + m_origin.x) ) {
|
||||||
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
|
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
|
||||||
@ -243,6 +247,13 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
|||||||
tmpOriginY,
|
tmpOriginY,
|
||||||
tmpclipX,
|
tmpclipX,
|
||||||
m_size.y);
|
m_size.y);
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
etk::Matrix tmpTranslate = etk::matrix::Translate(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
|
||||||
|
etk::Matrix tmpProjection = etk::matrix::Perspective(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
|
||||||
|
etk::Matrix tmpMat = tmpProjection * tmpTranslate;
|
||||||
|
// set internal matrix system :
|
||||||
|
ewol::openGL::SetMatrix(tmpMat);
|
||||||
|
#else
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrthoEwol(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
|
glOrthoEwol(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
|
||||||
@ -251,6 +262,8 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
|
glTranslatef(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
|
||||||
|
#endif
|
||||||
|
glLoadIdentity();
|
||||||
// Call the widget drawing methode
|
// Call the widget drawing methode
|
||||||
displayProp.m_origin.x = tmpOriginX;
|
displayProp.m_origin.x = tmpOriginX;
|
||||||
displayProp.m_origin.y = tmpOriginY;
|
displayProp.m_origin.y = tmpOriginY;
|
||||||
@ -262,6 +275,17 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
|||||||
m_origin.y,
|
m_origin.y,
|
||||||
m_size.x,
|
m_size.x,
|
||||||
m_size.y);
|
m_size.y);
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
#if 1
|
||||||
|
etk::Matrix tmpTranslate = etk::matrix::Translate(-m_size.x/2, -m_size.y/2, -1.0);
|
||||||
|
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 tmpMat = tmpProjection * tmpTranslate;
|
||||||
|
#else
|
||||||
|
etk::Matrix tmpMat = etk::matrix::Perspective(0, m_size.x, 0, m_size.y, -1, 1);
|
||||||
|
#endif
|
||||||
|
// set internal matrix system :
|
||||||
|
ewol::openGL::SetMatrix(tmpMat);
|
||||||
|
#else
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
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);
|
||||||
@ -269,12 +293,17 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
|||||||
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);
|
||||||
|
#endif
|
||||||
// Call the widget drawing methode
|
// Call the widget drawing methode
|
||||||
displayProp.m_origin = m_origin;
|
displayProp.m_origin = m_origin;
|
||||||
displayProp.m_size = m_size;
|
displayProp.m_size = m_size;
|
||||||
OnDraw(displayProp);
|
OnDraw(displayProp);
|
||||||
}
|
}
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
ewol::openGL::Pop();
|
||||||
|
#else
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/widget/Windows.h>
|
#include <ewol/widget/Windows.h>
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/openGL/openGL.h>
|
||||||
#include <ewol/texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
#include <ewol/font/Font.h>
|
#include <ewol/font/Font.h>
|
||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
@ -124,6 +125,10 @@ void ewol::Windows::SysDraw(void)
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
// clear the matrix system :
|
||||||
|
etk::Matrix newOne;
|
||||||
|
ewol::openGL::SetBasicMatrix(newOne);
|
||||||
|
|
||||||
ewol::DrawProperty displayProp;
|
ewol::DrawProperty displayProp;
|
||||||
displayProp.m_windowsSize = m_size;
|
displayProp.m_windowsSize = m_size;
|
||||||
displayProp.m_origin.x = 0;
|
displayProp.m_origin.x = 0;
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
basicShader.vert
|
|
||||||
basicShader.frag
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
attribute vec4 vPosition;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_Position = vPosition;
|
|
||||||
}
|
|
||||||
|
|
@ -7,8 +7,7 @@ uniform mat4 EW_MatrixTransformation;
|
|||||||
varying vec4 f_color;
|
varying vec4 f_color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
//gl_Position = vec4(EW_coord2d, 0.0, 1.0);
|
|
||||||
f_color = EW_color;
|
f_color = EW_color;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ varying vec4 f_color;
|
|||||||
varying vec2 f_texcoord;
|
varying vec2 f_texcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
// set texture output coord
|
// set texture output coord
|
||||||
f_texcoord = EW_texture2d;
|
f_texcoord = EW_texture2d;
|
||||||
// set output color :
|
// set output color :
|
||||||
|
@ -9,8 +9,8 @@ varying vec4 f_color;
|
|||||||
varying vec2 f_texcoord;
|
varying vec2 f_texcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord3d, 1.0);
|
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord3d, 1.0);
|
||||||
// set texture output coord
|
// set texture output coord
|
||||||
f_texcoord = EW_texture2d;
|
f_texcoord = EW_texture2d;
|
||||||
// set output color :
|
// set output color :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user