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);
|
||||
tmpp.x -= (T)obj.x;
|
||||
tmpp.y -= (T)obj.y;
|
||||
return *this;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* /= operator
|
||||
@ -118,7 +118,7 @@ template <typename T> class Vector2D
|
||||
Vector2D<T> tmpp(x,y);
|
||||
tmpp.x /= (T)obj.x;
|
||||
tmpp.y /= (T)obj.y;
|
||||
return *this;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* *= operator
|
||||
@ -135,7 +135,7 @@ template <typename T> class Vector2D
|
||||
Vector2D<T> tmpp(x,y);
|
||||
tmpp.x *= (T)obj.x;
|
||||
tmpp.y *= (T)obj.y;
|
||||
return *this;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* ++ operator
|
||||
|
@ -10,7 +10,8 @@ FILE_LIST = \
|
||||
etk/Stream.cpp \
|
||||
etk/File.cpp \
|
||||
etk/RegExp.cpp \
|
||||
etk/tool.cpp
|
||||
etk/tool.cpp \
|
||||
etk/Matrix.cpp
|
||||
|
||||
ifeq ("$(TARGET_OS)","Windows")
|
||||
FILE_LIST += etk/Mutex.Windows.cpp
|
||||
|
@ -26,12 +26,11 @@ LOCAL_EXPORT_LDLIBS := -lGL -lX11
|
||||
LOCAL_CFLAGS := -Wno-write-strings \
|
||||
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
|
||||
-DLUA_COMPAT_ALL \
|
||||
-D__VIDEO__OPENGL_ES_2 \
|
||||
-Wall
|
||||
|
||||
|
||||
#LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
|
||||
#LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
|
||||
LOCAL_CFLAGS += -D__VIDEO__OPENGL_ES_2
|
||||
LOCAL_EXPORT_CFLAGS := -D__VIDEO__OPENGL_ES_2
|
||||
|
||||
|
||||
# load the common sources file of the platform
|
||||
|
@ -196,41 +196,43 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::Font*& object)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object)
|
||||
{
|
||||
EWOL_VERBOSE("KEEP : Program : file : \"" << filename << "\"");
|
||||
object = static_cast<ewol::Program*>(LocalKeep(filename));
|
||||
if (NULL != object) {
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object)
|
||||
{
|
||||
EWOL_VERBOSE("KEEP : Program : file : \"" << filename << "\"");
|
||||
object = static_cast<ewol::Program*>(LocalKeep(filename));
|
||||
if (NULL != object) {
|
||||
return true;
|
||||
}
|
||||
// need to crate a new one ...
|
||||
object = new ewol::Program(filename);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : " << filename);
|
||||
return false;
|
||||
}
|
||||
LocalAdd(object);
|
||||
return true;
|
||||
}
|
||||
// need to crate a new one ...
|
||||
object = new ewol::Program(filename);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : " << filename);
|
||||
return false;
|
||||
}
|
||||
LocalAdd(object);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object)
|
||||
{
|
||||
EWOL_VERBOSE("KEEP : Shader : file : \"" << filename << "\"");
|
||||
object = static_cast<ewol::Shader*>(LocalKeep(filename));
|
||||
if (NULL != object) {
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object)
|
||||
{
|
||||
EWOL_VERBOSE("KEEP : Shader : file : \"" << filename << "\"");
|
||||
object = static_cast<ewol::Shader*>(LocalKeep(filename));
|
||||
if (NULL != object) {
|
||||
return true;
|
||||
}
|
||||
// need to crate a new one ...
|
||||
object = new ewol::Shader(filename);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : " << filename);
|
||||
return false;
|
||||
}
|
||||
LocalAdd(object);
|
||||
return true;
|
||||
}
|
||||
// need to crate a new one ...
|
||||
object = new ewol::Shader(filename);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : " << filename);
|
||||
return false;
|
||||
}
|
||||
LocalAdd(object);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ewol::resource::Keep(ewol::Texture*& object)
|
||||
{
|
||||
@ -315,18 +317,22 @@ void ewol::resource::Release(ewol::Font*& object)
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
void ewol::resource::Release(ewol::Program*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
void ewol::resource::Release(ewol::Shader*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
void ewol::resource::Release(ewol::Program*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
void ewol::resource::Release(ewol::Shader*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
#endif
|
||||
void ewol::resource::Release(ewol::Texture*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
|
@ -50,16 +50,20 @@ namespace ewol
|
||||
// return the type of the resource ...
|
||||
bool Keep(etk::UString& filename, ewol::TexturedFont*& object);
|
||||
bool Keep(etk::UString& filename, ewol::Font*& object);
|
||||
bool Keep(etk::UString& filename, ewol::Program*& object);
|
||||
bool Keep(etk::UString& filename, ewol::Shader*& object);
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
bool Keep(etk::UString& filename, ewol::Program*& object);
|
||||
bool Keep(etk::UString& filename, ewol::Shader*& object);
|
||||
#endif
|
||||
bool Keep(ewol::Texture*& object); // no name needed here ...
|
||||
bool Keep(etk::UString& filename, ewol::TextureFile*& object, Vector2D<int32_t> size);
|
||||
|
||||
void Release(ewol::Resource*& object);
|
||||
void Release(ewol::TexturedFont*& object);
|
||||
void Release(ewol::Font*& object);
|
||||
void Release(ewol::Program*& object);
|
||||
void Release(ewol::Shader*& object);
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
void Release(ewol::Program*& object);
|
||||
void Release(ewol::Shader*& object);
|
||||
#endif
|
||||
void Release(ewol::Texture*& object);
|
||||
void Release(ewol::TextureFile*& object);
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ ewol::OObject2DColored::OObject2DColored(void)
|
||||
m_triElement = 0;
|
||||
SetColor(1.0, 1.0, 1.0, 1.0);
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
etk::UString tmpString("color.prog");
|
||||
// get the shader resource :
|
||||
etk::UString tmpString("color.prog");
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||
//m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -52,7 +52,9 @@ ewol::OObject2DColored::~OObject2DColored(void)
|
||||
{
|
||||
m_coord.Clear();
|
||||
m_coordColor.Clear();
|
||||
ewol::resource::Release(m_GLprogram);
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::resource::Release(m_GLprogram);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -61,30 +63,21 @@ void ewol::OObject2DColored::Draw(void)
|
||||
if (m_coord.Size()<=0) {
|
||||
return;
|
||||
}
|
||||
if (m_GLprogram==NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
if (m_GLprogram==NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
glPushMatrix();
|
||||
glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||
m_GLprogram->Use();
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// position :
|
||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// color :
|
||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
m_GLprogram->UnUse();
|
||||
@ -99,8 +92,7 @@ void ewol::OObject2DColored::Draw(void)
|
||||
|
||||
// Set the vertex pointer to our vertex data
|
||||
glVertexPointer(2, GL_FLOAT, 0, &m_coord[0] );
|
||||
//glColorPointer(4, oglTypeFloat_t, 0, &m_coordColor[0] );
|
||||
glColorPointer(4, GL_FLOAT, 0, &m_coordColor[0] );
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] );
|
||||
// Render : draw all of the triangles at once
|
||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
|
||||
|
@ -39,9 +39,9 @@ namespace ewol {
|
||||
protected:
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::Program* m_GLprogram;
|
||||
GLint m_GLPosition;
|
||||
GLint m_GLMatrix;
|
||||
GLint m_GLColor;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLColor;
|
||||
#endif
|
||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||
#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_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
@ -101,7 +101,7 @@ ewol::OObject2DTextColored::OObject2DTextColored(void) :
|
||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
@ -137,39 +137,19 @@ void ewol::OObject2DTextColored::Draw(void)
|
||||
}
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
m_GLprogram->Use();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_font->GetId());
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
||||
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
|
||||
// position :
|
||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// Texture :
|
||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
||||
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);
|
||||
|
||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
m_GLprogram->UnUse();
|
||||
#else
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
@ -47,11 +47,11 @@ namespace ewol {
|
||||
protected:
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::Program* m_GLprogram;
|
||||
GLint m_GLPosition;
|
||||
GLint m_GLMatrix;
|
||||
GLint m_GLColor;
|
||||
GLint m_GLtexture;
|
||||
GLint m_GLtexID;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLColor;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_GLtexID;
|
||||
#endif
|
||||
ewol::TexturedFont* m_font; //!< ewol font system
|
||||
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_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
@ -77,39 +77,19 @@ void ewol::OObject2DTextured::Draw(void)
|
||||
}
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
m_GLprogram->Use();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_resource->GetId());
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
||||
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
|
||||
// position :
|
||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// Texture :
|
||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
||||
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);
|
||||
|
||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
m_GLprogram->UnUse();
|
||||
#else
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
@ -42,11 +42,11 @@ namespace ewol {
|
||||
protected:
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::Program* m_GLprogram;
|
||||
GLint m_GLPosition;
|
||||
GLint m_GLMatrix;
|
||||
GLint m_GLColor;
|
||||
GLint m_GLtexture;
|
||||
GLint m_GLtexID;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLColor;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_GLtexID;
|
||||
#endif
|
||||
ewol::TextureFile* m_resource; //!< texture resources
|
||||
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_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
@ -77,39 +77,19 @@ void ewol::OObject3DTextured::Draw(void)
|
||||
}
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
m_GLprogram->Use();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_resource->GetId());
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
glUniform1i(m_GLtexID, /*GL_TEXTURE*/0);
|
||||
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
|
||||
// position :
|
||||
glVertexAttribPointer(m_GLPosition, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_coord[0]);
|
||||
// Texture :
|
||||
glVertexAttribPointer(m_GLtexture, // attribute ID of OpenGL
|
||||
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);
|
||||
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
glVertexAttribPointer(m_GLColor, // attribute ID of OpenGL
|
||||
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);
|
||||
|
||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
m_GLprogram->UnUse();
|
||||
#else
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
@ -42,11 +42,11 @@ namespace ewol {
|
||||
protected:
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::Program* m_GLprogram;
|
||||
GLint m_GLPosition;
|
||||
GLint m_GLMatrix;
|
||||
GLint m_GLColor;
|
||||
GLint m_GLtexture;
|
||||
GLint m_GLtexID;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLColor;
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_GLtexID;
|
||||
#endif
|
||||
ewol::TextureFile* m_resource; //!< texture resources
|
||||
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 <ewol/Debug.h>
|
||||
#include <ewol/openGL/Program.h>
|
||||
@ -29,7 +31,8 @@
|
||||
|
||||
ewol::Program::Program(etk::UString& filename) :
|
||||
ewol::Resource(filename),
|
||||
m_program(0)
|
||||
m_program(0),
|
||||
m_hasTexture(false)
|
||||
{
|
||||
|
||||
// load data from file "all the time ..."
|
||||
@ -89,6 +92,8 @@ ewol::Program::~Program(void)
|
||||
glDeleteProgram(m_program);
|
||||
m_program = 0;
|
||||
}
|
||||
m_elementList.Clear();
|
||||
m_hasTexture = false;
|
||||
}
|
||||
|
||||
static void checkGlError(const char* op)
|
||||
@ -131,55 +136,104 @@ bool ewol::Program::CreateAndLink(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO : Set it dynamic to prevent reload system error ...
|
||||
GLint ewol::Program::GetAttribute(etk::UString& tmpElement)
|
||||
int32_t ewol::Program::GetAttribute(etk::UString tmpElement)
|
||||
{
|
||||
GLint elem = glGetAttribLocation(m_program, tmpElement.c_str());
|
||||
if (elem<0) {
|
||||
// check if it exist previously :
|
||||
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");
|
||||
EWOL_INFO("glGetAttribLocation(\"" << tmpElement << "\") = " << elem);
|
||||
EWOL_INFO("glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||
return -1;
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
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;
|
||||
m_elementList.PushBack(tmp);
|
||||
return m_elementList.Size()-1;
|
||||
}
|
||||
|
||||
GLint ewol::Program::GetUniform(etk::UString& tmpElement)
|
||||
int32_t ewol::Program::GetUniform(etk::UString tmpElement)
|
||||
{
|
||||
GLint elem = glGetUniformLocation(m_program, tmpElement.c_str());
|
||||
if (elem<0) {
|
||||
// check if it exist previously :
|
||||
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");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
GLint ewol::Program::GetUniform(const char* tmpElement)
|
||||
void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample)
|
||||
{
|
||||
GLint elem = glGetUniformLocation(m_program, tmpElement);
|
||||
if (elem<0) {
|
||||
checkGlError("glGetUniformLocation");
|
||||
EWOL_INFO("glGetUniformLocation(\"" << tmpElement << "\") = " << elem);
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
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)
|
||||
{
|
||||
glUseProgram(m_program);
|
||||
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)
|
||||
{
|
||||
if (true == m_hasTexture) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
m_hasTexture = false;
|
||||
}
|
||||
glUseProgram(0);
|
||||
checkGlError("glUseProgram");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -24,35 +24,44 @@
|
||||
|
||||
#ifndef __OPEN_GL__PROGRAM_H__
|
||||
#define __OPEN_GL__PROGRAM_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <ewol/openGL/Shader.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
class Program : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
GLuint m_program;
|
||||
etk::Vector<ewol::Shader*> m_shaderList;
|
||||
public:
|
||||
Program(etk::UString& filename);
|
||||
virtual ~Program(void);
|
||||
const char* GetType(void) { return "ewol::Program"; };
|
||||
GLuint GetGL_ID(void) { return m_program; };
|
||||
bool CreateAndLink(void);
|
||||
GLint GetAttribute(etk::UString& tmpElement);
|
||||
GLint GetAttribute(const char* tmpElement);
|
||||
GLint GetUniform(etk::UString& tmpElement);
|
||||
GLint GetUniform(const char* tmpElement);
|
||||
void Use(void);
|
||||
void UnUse(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#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>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
class progAttributeElement
|
||||
{
|
||||
public :
|
||||
etk::UString m_name;
|
||||
GLint m_elementId;
|
||||
bool m_isAttribute;
|
||||
};
|
||||
|
||||
class Program : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
GLuint m_program;
|
||||
etk::Vector<ewol::Shader*> m_shaderList;
|
||||
etk::Vector<ewol::progAttributeElement> m_elementList;
|
||||
bool m_hasTexture;
|
||||
public:
|
||||
Program(etk::UString& filename);
|
||||
virtual ~Program(void);
|
||||
const char* GetType(void) { return "ewol::Program"; };
|
||||
bool CreateAndLink(void);
|
||||
int32_t GetAttribute(etk::UString tmpElement);
|
||||
void SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample=0);
|
||||
int32_t GetUniform(etk::UString tmpElement);
|
||||
void SendUniformMatrix4fv(int32_t idElem, int32_t nbElement, float* pointer);
|
||||
void Use(void);
|
||||
void SetTexture0(int32_t idElem, GLint textureOpenGlID);
|
||||
void UnUse(void);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <etk/File.h>
|
||||
#include <ewol/Debug.h>
|
||||
@ -132,3 +134,5 @@ bool ewol::Shader::CompileAndSendShader(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -24,30 +24,29 @@
|
||||
|
||||
#ifndef __OPEN_GL__SHADER_H__
|
||||
#define __OPEN_GL__SHADER_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
class Shader : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
char* m_fileData;
|
||||
GLuint m_shader;
|
||||
GLenum m_type;
|
||||
public:
|
||||
Shader(etk::UString& filename);
|
||||
virtual ~Shader(void);
|
||||
const char* GetType(void) { return "ewol::Shader"; };
|
||||
GLuint GetGL_ID(void) { return m_shader; };
|
||||
GLenum GetShaderType(void) { return m_type; };
|
||||
bool CompileAndSendShader(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
class Shader : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
char* m_fileData;
|
||||
GLuint m_shader;
|
||||
GLenum m_type;
|
||||
public:
|
||||
Shader(etk::UString& filename);
|
||||
virtual ~Shader(void);
|
||||
const char* GetType(void) { return "ewol::Shader"; };
|
||||
GLuint GetGL_ID(void) { return m_shader; };
|
||||
GLenum GetShaderType(void) { return m_type; };
|
||||
bool CompileAndSendShader(void);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <etk/Vector.h>
|
||||
|
||||
|
||||
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;
|
||||
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;
|
||||
l_matrixList.Clear();
|
||||
}
|
||||
|
||||
ewol::OglMatrix::~OglMatrix()
|
||||
void ewol::openGL::SetBasicMatrix(etk::Matrix& newOne)
|
||||
{
|
||||
|
||||
}
|
||||
//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];
|
||||
if (l_matrixList.Size()!=1) {
|
||||
EWOL_ERROR("matrix is not corect size in the stack : " << l_matrixList.Size());
|
||||
}
|
||||
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];
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
matrix[iii] = 0;
|
||||
if (l_matrixList.Size()==0) {
|
||||
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||
l_matrixList.PushBack(newOne);
|
||||
return;
|
||||
}
|
||||
// set identity :
|
||||
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);
|
||||
l_matrixList[l_matrixList.Size()-1] = newOne;
|
||||
}
|
||||
|
||||
void ewol::OglMatrix::Scale(float x, float y, float z)
|
||||
void ewol::openGL::Push(void)
|
||||
{
|
||||
float matrix[4*4];
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
matrix[iii] = 0;
|
||||
if (l_matrixList.Size()==0) {
|
||||
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||
etk::Matrix tmp;
|
||||
l_matrixList.PushBack(tmp);
|
||||
return;
|
||||
}
|
||||
// set identity :
|
||||
matrix[0] = 1;
|
||||
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);
|
||||
etk::Matrix tmp = l_matrixList[l_matrixList.Size()-1];
|
||||
l_matrixList.PushBack(tmp);
|
||||
}
|
||||
|
||||
void ewol::OglMatrix::rotate(float x, float y, float z, float angle)
|
||||
void ewol::openGL::Pop(void)
|
||||
{
|
||||
float matrix[4*4];
|
||||
for(int32_t iii=0; iii<4*4 ; iii++) {
|
||||
matrix[iii] = 0;
|
||||
if (l_matrixList.Size()<=1) {
|
||||
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||
l_matrixList.Clear();
|
||||
etk::Matrix tmp;
|
||||
l_matrixList.PushBack(tmp);
|
||||
return;
|
||||
}
|
||||
// set identity :
|
||||
matrix[0] = 1;
|
||||
matrix[5] = 1;
|
||||
matrix[10] = 1;
|
||||
matrix[15] = 1;
|
||||
// TODO ...
|
||||
// generate output :
|
||||
MultiplyMatrix(m_Matrix, matrix);
|
||||
l_matrixList.PopBack();
|
||||
}
|
||||
|
||||
etk::Matrix& ewol::openGL::GetMatrix(void)
|
||||
{
|
||||
if (l_matrixList.Size()==0) {
|
||||
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.Size());
|
||||
etk::Matrix tmp;
|
||||
l_matrixList.PushBack(tmp);
|
||||
}
|
||||
return l_matrixList[l_matrixList.Size()-1];
|
||||
}
|
||||
|
||||
|
@ -25,29 +25,38 @@
|
||||
#ifndef __OPEN_GL_H__
|
||||
#define __OPEN_GL_H__
|
||||
|
||||
#include <etk/Matrix.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__TARGET_OS__Linux)
|
||||
#if defined(__TARGET_OS__Linux) || defined(__TARGET_OS__Windows)
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
// TO ENABLE THE SHADER api ...
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#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)
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
// Include openGL ES 2
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
|
||||
// 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>
|
||||
#elif defined(__TARGET_OS__MacOs)
|
||||
|
||||
#elif defined(__TARGET_OS__IOs)
|
||||
@ -56,18 +65,20 @@ 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);
|
||||
|
||||
namespace ewol {
|
||||
class OglMatrix{
|
||||
public :
|
||||
float m_Matrix[4*4];
|
||||
OglMatrix(float left, float right, float bottom, float top, float nearVal, float farVal);
|
||||
~OglMatrix();
|
||||
void Generate(float left, float right, float bottom, float top, float nearVal, float farVal);
|
||||
void Translate(float x=0.0, float y=0.0, float z=0.0);
|
||||
void Scale(float x=1.0, float y=1.0, float z=1.0);
|
||||
void rotate(float x, float y, float z, float angle=0.0);
|
||||
namespace openGL {
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
// reset the basic element at this one ... remove all previous
|
||||
void SetBasicMatrix(etk::Matrix& newOne);
|
||||
// this is the same system as openGL-ES-1 but in openGL-ES-2 (here is the abstraction)
|
||||
void SetMatrix(etk::Matrix& newOne);
|
||||
void Push(void);
|
||||
void Pop(void);
|
||||
etk::Matrix& GetMatrix(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -240,6 +240,7 @@ void eSystem::Init(void)
|
||||
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
|
||||
EWOL_INFO("Build Date: " BUILD_TIME);
|
||||
etk::InitDefaultFolder("ewolApplNoName");
|
||||
ewol::openGL::Init();
|
||||
ewol::EObjectManager::Init();
|
||||
ewol::EObjectMessageMultiCast::Init();
|
||||
l_managementInput.Reset();
|
||||
@ -271,6 +272,7 @@ void eSystem::UnInit(void)
|
||||
ewol::EObjectMessageMultiCast::UnInit();
|
||||
ewol::EObjectManager::UnInit();
|
||||
ewol::resource::UnInit();
|
||||
ewol::openGL::UnInit();
|
||||
l_managementInput.Reset();
|
||||
l_msgSystem.Clean();
|
||||
}
|
||||
|
@ -1178,19 +1178,6 @@ int main(int argc, char *argv[])
|
||||
etk::File myIcon = APP_Icon();
|
||||
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 ...
|
||||
X11_Run();
|
||||
// close X11 :
|
||||
|
@ -225,7 +225,11 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
||||
// widget is hidden ...
|
||||
return;
|
||||
}
|
||||
glPushMatrix();
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::openGL::Push();
|
||||
#else
|
||||
glPushMatrix();
|
||||
#endif
|
||||
if( (displayProp.m_origin.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
|
||||
@ -243,14 +247,23 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
||||
tmpOriginY,
|
||||
tmpclipX,
|
||||
m_size.y);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrthoEwol(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
|
||||
//glOrthoEwol(0., m_size.x, 0., -m_size.y, 1., 20.);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
|
||||
#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);
|
||||
glLoadIdentity();
|
||||
glOrthoEwol(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
|
||||
//glOrthoEwol(0., m_size.x, 0., -m_size.y, 1., 20.);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
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;
|
||||
@ -262,19 +275,35 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
||||
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();
|
||||
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
|
||||
#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);
|
||||
glLoadIdentity();
|
||||
glOrthoEwol(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
|
||||
#endif
|
||||
// Call the widget drawing methode
|
||||
displayProp.m_origin = m_origin;
|
||||
displayProp.m_size = m_size;
|
||||
OnDraw(displayProp);
|
||||
}
|
||||
glPopMatrix();
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
ewol::openGL::Pop();
|
||||
#else
|
||||
glPopMatrix();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/widget/Windows.h>
|
||||
#include <ewol/oObject/OObject.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <ewol/texture/Texture.h>
|
||||
#include <ewol/font/Font.h>
|
||||
#include <ewol/ewol.h>
|
||||
@ -124,6 +125,10 @@ void ewol::Windows::SysDraw(void)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// clear the matrix system :
|
||||
etk::Matrix newOne;
|
||||
ewol::openGL::SetBasicMatrix(newOne);
|
||||
|
||||
ewol::DrawProperty displayProp;
|
||||
displayProp.m_windowsSize = m_size;
|
||||
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;
|
||||
|
||||
void main(void) {
|
||||
//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 = 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);
|
||||
f_color = EW_color;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ varying vec4 f_color;
|
||||
varying vec2 f_texcoord;
|
||||
|
||||
void main(void) {
|
||||
//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 = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
||||
// set texture output coord
|
||||
f_texcoord = EW_texture2d;
|
||||
// set output color :
|
||||
|
@ -9,8 +9,8 @@ varying vec4 f_color;
|
||||
varying vec2 f_texcoord;
|
||||
|
||||
void main(void) {
|
||||
//gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord3d, 1.0);
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord3d, 1.0);
|
||||
// set texture output coord
|
||||
f_texcoord = EW_texture2d;
|
||||
// set output color :
|
||||
|
Loading…
x
Reference in New Issue
Block a user