diff --git a/Sources/libewol/Linux.mk b/Sources/libewol/Linux.mk index 36e2a466..cc2388ea 100644 --- a/Sources/libewol/Linux.mk +++ b/Sources/libewol/Linux.mk @@ -26,8 +26,14 @@ 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 + + # load the common sources file of the platform include $(LOCAL_PATH)/file.mk diff --git a/Sources/libewol/ewol/Resource.h b/Sources/libewol/ewol/Resource.h index b7c20935..0f6fe843 100644 --- a/Sources/libewol/ewol/Resource.h +++ b/Sources/libewol/ewol/Resource.h @@ -55,6 +55,7 @@ namespace ewol virtual etk::UString GetName(void) { return m_name; }; void Increment(void) { m_counter++; }; bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; }; + int32_t GetCounter(void) { return m_counter; }; virtual const char* GetType(void) { return "unknow"; }; virtual void UpdateContext(void) { }; virtual void RemoveContext(void) { }; diff --git a/Sources/libewol/ewol/ResourceManager.cpp b/Sources/libewol/ewol/ResourceManager.cpp index e9949e6e..1bac7c78 100644 --- a/Sources/libewol/ewol/ResourceManager.cpp +++ b/Sources/libewol/ewol/ResourceManager.cpp @@ -46,11 +46,14 @@ void ewol::resource::Init(void) void ewol::resource::UnInit(void) { + Display(); l_resourceListToUpdate.Clear(); // remove all resources ... - for (int32_t iii=0; iii=0; iii--) { if (l_resourceList[iii] != NULL) { - EWOL_WARNING("Find a resource that is not removed : [" << l_resourceList[iii]->GetUID() << "]"); + EWOL_WARNING("Find a resource that is not removed : [" << l_resourceList[iii]->GetUID() << "]" + << "=\"" << l_resourceList[iii]->GetName() << "\" " + << l_resourceList[iii]->GetCounter() << " elements"); delete(l_resourceList[iii]); l_resourceList[iii] = NULL; } @@ -58,6 +61,21 @@ void ewol::resource::UnInit(void) l_resourceList.Clear(); } +void ewol::resource::Display(void) +{ + EWOL_INFO("Resources loaded : "); + // remove all resources ... + for (int32_t iii=l_resourceList.Size()-1; iii>=0; iii--) { + if (l_resourceList[iii] != NULL) { + EWOL_INFO(" [" << l_resourceList[iii]->GetUID() << "]" + << l_resourceList[iii]->GetType() + << "=\"" << l_resourceList[iii]->GetName() << "\" " + << l_resourceList[iii]->GetCounter() << " elements"); + } + } + EWOL_INFO("Resources ---"); +} + void ewol::resource::Update(ewol::Resource* object) { diff --git a/Sources/libewol/ewol/ResourceManager.h b/Sources/libewol/ewol/ResourceManager.h index aa778e0b..d26d9777 100644 --- a/Sources/libewol/ewol/ResourceManager.h +++ b/Sources/libewol/ewol/ResourceManager.h @@ -40,6 +40,7 @@ namespace ewol namespace resource { void Init(void); void UnInit(void); + void Display(void); void Update(ewol::Resource* object); // Specific to load or update the data in the openGl context ==> system use only diff --git a/Sources/libewol/ewol/oObject/2DColored.cpp b/Sources/libewol/ewol/oObject/2DColored.cpp index f78cbb46..096a99d8 100644 --- a/Sources/libewol/ewol/oObject/2DColored.cpp +++ b/Sources/libewol/ewol/oObject/2DColored.cpp @@ -35,14 +35,16 @@ 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 : - 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_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"); + } + #endif } @@ -63,53 +65,50 @@ void ewol::OObject2DColored::Draw(void) EWOL_ERROR("No shader ..."); return; } - #if 1 - glPushMatrix(); - glScalef(m_scaling.x, m_scaling.y, 1.0); - m_GLprogram->Use(); - // 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); - // 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); - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); - glPopMatrix(); - + #ifdef __VIDEO__OPENGL_ES_2 + glPushMatrix(); + glScalef(m_scaling.x, m_scaling.y, 1.0); + m_GLprogram->Use(); + // 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); + // 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); + // Request the draw od the elements : + glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); + m_GLprogram->UnUse(); + glPopMatrix(); #else - - glPushMatrix(); - // Enable Pointers - glEnableClientState( GL_VERTEX_ARRAY ); - glEnableClientState( GL_COLOR_ARRAY ); - - glScalef(m_scaling.x, m_scaling.y, 1.0); - - // 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] ); - // Render : draw all of the triangles at once - glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); - //glDrawElements( GL_TRIANGLES, 0, m_coord.Size()); - //EWOL_DEBUG("Draw ..." << m_coord.Size()/3 << " triangle(s)"); - - // Disable Pointers - glDisableClientState( GL_COLOR_ARRAY ); - glDisableClientState( GL_VERTEX_ARRAY ); - glPopMatrix(); + glPushMatrix(); + // Enable Pointers + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glScalef(m_scaling.x, m_scaling.y, 1.0); + + // 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] ); + // Render : draw all of the triangles at once + glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); + //glDrawElements( GL_TRIANGLES, 0, m_coord.Size()); + //EWOL_DEBUG("Draw ..." << m_coord.Size()/3 << " triangle(s)"); + // Disable Pointers + glDisableClientState( GL_COLOR_ARRAY ); + glDisableClientState( GL_VERTEX_ARRAY ); + glPopMatrix(); #endif } @@ -341,15 +340,14 @@ void ewol::OObject2DColored::GenerateTriangle(void) void ewol::OObject2DColored::SetColor(draw::Color color) { - draw::Colorf colorf = color; if (m_triElement < 1) { - m_color[0] = colorf; + m_color[0] = color; } if (m_triElement < 2) { - m_color[1] = colorf; + m_color[1] = color; } if (m_triElement < 3) { - m_color[2] = colorf; + m_color[2] = color; } } diff --git a/Sources/libewol/ewol/oObject/2DColored.h b/Sources/libewol/ewol/oObject/2DColored.h index 222429f6..333852cd 100644 --- a/Sources/libewol/ewol/oObject/2DColored.h +++ b/Sources/libewol/ewol/oObject/2DColored.h @@ -37,15 +37,21 @@ namespace ewol { public: virtual void Draw(void); protected: - ewol::Program* m_GLprogram; - GLint m_GLPosition; - GLint m_GLMatrix; - GLint m_GLColor; + #ifdef __VIDEO__OPENGL_ES_2 + ewol::Program* m_GLprogram; + GLint m_GLPosition; + GLint m_GLMatrix; + GLint m_GLColor; + #endif etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordColor; //!< internal color of the different point - //etk::Vector m_linkCoord; //!< internal link between point to generate triangle + #ifdef __VIDEO__OPENGL_ES_2 + etk::Vector m_coordColor; //!< internal color of the different point + draw::Colorf m_color[3]; + #else + etk::Vector m_coordColor; //!< internal color of the different point + draw::Color m_color[3]; + #endif int32_t m_triElement; - draw::Colorf m_color[3]; Vector2D m_triangle[3]; void GenerateTriangle(void); void ResetCount(void); diff --git a/Sources/libewol/ewol/oObject/2DTextColored.cpp b/Sources/libewol/ewol/oObject/2DTextColored.cpp index 15341f8f..560b5c0d 100644 --- a/Sources/libewol/ewol/oObject/2DTextColored.cpp +++ b/Sources/libewol/ewol/oObject/2DTextColored.cpp @@ -43,7 +43,7 @@ void ewol::OObject2DTextColored::SetFontProperty(etk::UString fontName, int32_t tmpName += fontSize; // link to new One if (false == ewol::resource::Keep(tmpName, m_font)) { - + EWOL_ERROR("Can not get font resource"); } } @@ -72,6 +72,18 @@ ewol::OObject2DTextColored::OObject2DTextColored(etk::UString fontName, int32_t { m_color = draw::color::black; SetFontProperty(fontName, size); + #ifdef __VIDEO__OPENGL_ES_2 + etk::UString tmpString("textured.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_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); + //m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); + m_GLtexID = m_GLprogram->GetUniform("EW_texID"); + } + #endif } @@ -81,6 +93,18 @@ ewol::OObject2DTextColored::OObject2DTextColored(void) : { m_color = draw::color::black; SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize()); + etk::UString tmpString("textured.prog"); + #ifdef __VIDEO__OPENGL_ES_2 + // 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_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); + //m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); + m_GLtexID = m_GLprogram->GetUniform("EW_texID"); + } + #endif } @@ -90,6 +114,9 @@ ewol::OObject2DTextColored::~OObject2DTextColored(void) ewol::resource::Release(m_font); m_font = NULL; } + #ifdef __VIDEO__OPENGL_ES_2 + ewol::resource::Release(m_GLprogram); + #endif } void ewol::OObject2DTextColored::Draw(void) @@ -103,20 +130,63 @@ void ewol::OObject2DTextColored::Draw(void) EWOL_WARNING("no font..."); return; } - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_font->GetId()); - glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays - glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays - glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] ); - glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); - glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); - //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); - glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays - glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays - glDisable(GL_TEXTURE_2D); + #ifdef __VIDEO__OPENGL_ES_2 + if (m_GLprogram==NULL) { + EWOL_ERROR("No shader ..."); + return; + } + 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()); + // TextureID + glUniform1i(m_GLtexID, /*GL_TEXTURE*/0); + // 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); + // 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); + // 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); + + // 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); + glBindTexture(GL_TEXTURE_2D, m_font->GetId()); + glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays + glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays + glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] ); + glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); + glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); + //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); + glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays + glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays + glDisable(GL_TEXTURE_2D); + #endif } void ewol::OObject2DTextColored::Clear(void) diff --git a/Sources/libewol/ewol/oObject/2DTextColored.h b/Sources/libewol/ewol/oObject/2DTextColored.h index 1be63a14..60f843aa 100644 --- a/Sources/libewol/ewol/oObject/2DTextColored.h +++ b/Sources/libewol/ewol/oObject/2DTextColored.h @@ -27,6 +27,7 @@ #include #include +#include namespace ewol { class OObject2DTextColored :public ewol::OObject @@ -44,11 +45,23 @@ namespace ewol { int32_t Text(Vector2D textPos, const etk::UString& unicodeString); int32_t Text(Vector2D textPos, const uniChar_t unicodeChar); 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; + #endif ewol::TexturedFont* m_font; //!< ewol font system draw::Color m_color; //!< tmp text color ... etk::Vector > m_coord; //!< internal coord of the object etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point + #ifdef __VIDEO__OPENGL_ES_2 + etk::Vector m_coordColor; //!< internal color of the different point + #else + etk::Vector m_coordColor; //!< internal color of the different point + #endif public: void SetFont(etk::UString fontName); void SetSize(int32_t fontSize); diff --git a/Sources/libewol/ewol/oObject/2DTextured.cpp b/Sources/libewol/ewol/oObject/2DTextured.cpp index 4537d019..951ca65a 100644 --- a/Sources/libewol/ewol/oObject/2DTextured.cpp +++ b/Sources/libewol/ewol/oObject/2DTextured.cpp @@ -36,16 +36,18 @@ ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX if (false == ewol::resource::Keep(textureName, m_resource, Vector2D(sizeX,sizeY)) ) { EWOL_CRITICAL("can not get a resource Texture"); } - etk::UString tmpString("textured.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_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - //m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } + #ifdef __VIDEO__OPENGL_ES_2 + etk::UString tmpString("textured.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_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); + //m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); + m_GLtexID = m_GLprogram->GetUniform("EW_texID"); + } + #endif } @@ -54,7 +56,9 @@ ewol::OObject2DTextured::~OObject2DTextured(void) if (NULL != m_resource) { ewol::resource::Release(m_resource); } - ewol::resource::Release(m_GLprogram); + #ifdef __VIDEO__OPENGL_ES_2 + ewol::resource::Release(m_GLprogram); + #endif } void ewol::OObject2DTextured::Draw(void) @@ -66,68 +70,64 @@ void ewol::OObject2DTextured::Draw(void) EWOL_WARNING("Texture does not exist ..."); return; } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - - #if 1 - 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()); - // TextureID - glUniform1i(m_GLtexID, /*GL_TEXTURE*/0); - // 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); - // 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); - // 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); - - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - glDisable(GL_TEXTURE_2D); - m_GLprogram->UnUse(); - - + #ifdef __VIDEO__OPENGL_ES_2 + if (m_GLprogram==NULL) { + EWOL_ERROR("No shader ..."); + return; + } + 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()); + // TextureID + glUniform1i(m_GLtexID, /*GL_TEXTURE*/0); + // 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); + // 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); + // 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); + + // 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); - glEnable(GL_TEXTURE_2D); - //EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId)); - glBindTexture(GL_TEXTURE_2D, m_resource->GetId() ); - glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays - glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays - glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] ); - glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); - glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); - //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); - glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays - glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays - glDisable(GL_TEXTURE_2D); + glColor4f(1.0, 1.0, 1.0, 1.0); + glEnable(GL_TEXTURE_2D); + //EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId)); + glBindTexture(GL_TEXTURE_2D, m_resource->GetId() ); + glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays + glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays + glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] ); + glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); + glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); + //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); + glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays + glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays + glDisable(GL_TEXTURE_2D); #endif } diff --git a/Sources/libewol/ewol/oObject/2DTextured.h b/Sources/libewol/ewol/oObject/2DTextured.h index f5195223..b529a2c6 100644 --- a/Sources/libewol/ewol/oObject/2DTextured.h +++ b/Sources/libewol/ewol/oObject/2DTextured.h @@ -40,16 +40,22 @@ namespace ewol { void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white); void Rectangle(float x, float y, float w, float h, draw::Color tmpColor); protected: - ewol::Program* m_GLprogram; - GLint m_GLPosition; - GLint m_GLMatrix; - GLint m_GLColor; - GLint m_GLtexture; - GLint m_GLtexID; + #ifdef __VIDEO__OPENGL_ES_2 + ewol::Program* m_GLprogram; + GLint m_GLPosition; + GLint m_GLMatrix; + GLint m_GLColor; + GLint m_GLtexture; + GLint m_GLtexID; + #endif ewol::TextureFile* m_resource; //!< texture resources etk::Vector > m_coord; //!< internal coord of the object etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point + #ifdef __VIDEO__OPENGL_ES_2 + etk::Vector m_coordColor; //!< internal color of the different point + #else + etk::Vector m_coordColor; //!< internal color of the different point + #endif }; }; diff --git a/Sources/libewol/ewol/oObject/3DTextured.cpp b/Sources/libewol/ewol/oObject/3DTextured.cpp new file mode 100644 index 00000000..8d3da04d --- /dev/null +++ b/Sources/libewol/ewol/oObject/3DTextured.cpp @@ -0,0 +1,204 @@ +/** + ******************************************************************************* + * @file ewol/oObject/2DTextured.cpp + * @brief ewol OpenGl Object system (Sources) + * @author Edouard DUPIN + * @date 09/11/2011 + * @par Project + * ewol + * + * @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 +#include +#include + +#undef __class__ +#define __class__ "ewol::OObject3DTextured" + + +ewol::OObject3DTextured::OObject3DTextured(etk::UString textureName, float sizeX, float sizeY) +{ + EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\""); + if (false == ewol::resource::Keep(textureName, m_resource, Vector2D(sizeX,sizeY)) ) { + EWOL_CRITICAL("can not get a resource Texture"); + } + #ifdef __VIDEO__OPENGL_ES_2 + etk::UString tmpString("textured3D.prog"); + // get the shader resource : + m_GLPosition = 0; + if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { + 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_GLtexID = m_GLprogram->GetUniform("EW_texID"); + } + #endif +} + + +ewol::OObject3DTextured::~OObject3DTextured(void) +{ + if (NULL != m_resource) { + ewol::resource::Release(m_resource); + } + #ifdef __VIDEO__OPENGL_ES_2 + ewol::resource::Release(m_GLprogram); + #endif +} + +void ewol::OObject3DTextured::Draw(void) +{ + if (m_coord.Size()<=0) { + return; + } + if (NULL == m_resource) { + EWOL_WARNING("Texture does not exist ..."); + return; + } + #ifdef __VIDEO__OPENGL_ES_2 + if (m_GLprogram==NULL) { + EWOL_ERROR("No shader ..."); + return; + } + 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()); + // TextureID + glUniform1i(m_GLtexID, /*GL_TEXTURE*/0); + // 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); + // 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); + // 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); + + // 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); + glEnable(GL_TEXTURE_2D); + //EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId)); + glBindTexture(GL_TEXTURE_2D, m_resource->GetId() ); + glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays + glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays + glVertexPointer( 3, GL_FLOAT, 0, &m_coord[0] ); + glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); + glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); + //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); + glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays + glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays + glDisable(GL_TEXTURE_2D); + #endif +} + +void ewol::OObject2DTextured::Clear(void) +{ + m_coord.Clear(); + m_coordTex.Clear(); + m_coordColor.Clear(); +} + +void ewol::OObject3DTextured::Rectangle(float x, float y, float w, float h, draw::Color tmpColor) +{ + Rectangle(x, y, w, h, 0.0, 0.0, 1.0, 1.0, tmpColor); +} + +void ewol::OObject3DTextured::Rectangle(float x, float y, float w, float h, float texX, float texY, float texSX, float texSY, draw::Color tmpColor) +{ + /* + x += 3; + y += 3; + w -= 6; + h -= 6; + */ + //EWOL_DEBUG("Add rectangle : ..."); + Vector3D point; + texCoord_ts tex; + point.z = 0; + + tex.u = texX; + tex.v = texSY; + point.x = x; + point.y = y; + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); + + + tex.u = texSX; + tex.v = texSY; + point.x = x + w; + point.y = y; + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); + + + tex.u = texSX; + tex.v = texY; + point.x = x + w; + point.y = y + h; + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); + + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); + + tex.u = texX; + tex.v = texY; + point.x = x; + point.y = y + h; + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); + + tex.u = texX; + tex.v = texSY; + point.x = x; + point.y = y; + m_coord.PushBack(point); + m_coordTex.PushBack(tex); + m_coordColor.PushBack(tmpColor); +} diff --git a/Sources/libewol/ewol/oObject/3DTextured.h b/Sources/libewol/ewol/oObject/3DTextured.h new file mode 100644 index 00000000..572d45ef --- /dev/null +++ b/Sources/libewol/ewol/oObject/3DTextured.h @@ -0,0 +1,63 @@ +/** + ******************************************************************************* + * @file ewol/oObject/3DTextured.h + * @brief ewol OpenGl Object system (header) + * @author Edouard DUPIN + * @date 29/08/2012 + * @par Project + * ewol + * + * @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 __EWOL_O_OBJECT_3D_TEXTURED_H__ +#define __EWOL_O_OBJECT_3D_TEXTURED_H__ + +#include +#include + +namespace ewol { + class OObject3DTextured :public ewol::OObject + { + public: + OObject3DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1); + virtual ~OObject3DTextured(void); + public: + virtual void Draw(void); + void Clear(void); + void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white); + void Rectangle(float x, float y, float w, float h, draw::Color tmpColor); + 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; + #endif + ewol::TextureFile* m_resource; //!< texture resources + etk::Vector > m_coord; //!< internal coord of the object + etk::Vector m_coordTex; //!< internal texture coordinate for every point + #ifdef __VIDEO__OPENGL_ES_2 + etk::Vector m_coordColor; //!< internal color of the different point + #else + etk::Vector m_coordColor; //!< internal color of the different point + #endif + }; +}; + +#endif + diff --git a/Sources/libewol/ewol/oObject/Sprite.cpp b/Sources/libewol/ewol/oObject/Sprite.cpp index adc28444..704686d8 100644 --- a/Sources/libewol/ewol/oObject/Sprite.cpp +++ b/Sources/libewol/ewol/oObject/Sprite.cpp @@ -31,55 +31,16 @@ #define __class__ "Sprite" -ewol::Sprite::Sprite(etk::UString spriteName, float sizeX, float sizeY) +ewol::Sprite::Sprite(etk::UString spriteName, float sizeX, float sizeY) : + ewol::OObject3DTextured(spriteName, sizeX, sizeY) { m_name = spriteName; - EWOL_VERBOSE("Create Sprite : \"" << m_name << "\""); - if (false == ewol::resource::Keep(m_name, m_resource, Vector2D(sizeX,sizeY)) ) { - EWOL_CRITICAL("can not get a resource Texture"); - } } ewol::Sprite::~Sprite(void) { - if (NULL != m_resource) { - ewol::resource::Release(m_resource); - } -} - -void ewol::Sprite::Draw(void) -{ - if (m_coord.Size()<=0) { - //EWOL_WARNING("Nothink to draw..."); - return; - } - if (NULL == m_resource) { - EWOL_WARNING("Texture does not exist ..."); - return; - } - glEnable(GL_TEXTURE_2D); - //EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId)); - glBindTexture(GL_TEXTURE_2D, m_resource->GetId()); - glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays - glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays - glVertexPointer( 3, GL_FLOAT, 0, &m_coord[0] ); - glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] ); - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_coordColor[0] ); - glDrawArrays( GL_TRIANGLES, 0, m_coord.Size()); - //EWOL_DEBUG("request draw of " << m_coord.Size() << " elements"); - glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays - glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays - glDisable(GL_TEXTURE_2D); -} - -void ewol::Sprite::Clear(void) -{ - m_coord.Clear(); - m_coordTex.Clear(); - m_coordColor.Clear(); + } void ewol::Sprite::Element(Vector2D pos, float size, float angle) @@ -122,6 +83,11 @@ void ewol::Sprite::Element(Vector3D pos, float size, float angle, draw::C texD.u = 1.0; texD.v = 0.0; + #ifdef __VIDEO__OPENGL_ES_2 + draw::Colorf localColor = tmpColor; + #else + draw::Color localColor = tmpColor; + #endif Vector3D point = pos; float yyySin = sin(angle) * size; float xxxCos = cos(angle) * size; @@ -130,34 +96,34 @@ void ewol::Sprite::Element(Vector3D pos, float size, float angle, draw::C point.y = yyySin + pos.y; m_coord.PushBack(point); m_coordTex.PushBack(texB); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); point.x = yyySin + pos.x; point.y = -xxxCos + pos.y; m_coord.PushBack(point); m_coordTex.PushBack(texC); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); point.x = -xxxCos + pos.x; point.y = -yyySin + pos.y; m_coord.PushBack(point); m_coordTex.PushBack(texD); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); m_coord.PushBack(point); m_coordTex.PushBack(texD); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); point.x = -yyySin + pos.x; point.y = xxxCos + pos.y; m_coord.PushBack(point); m_coordTex.PushBack(texA); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); point.x = xxxCos + pos.x; point.y = yyySin + pos.y; m_coord.PushBack(point); m_coordTex.PushBack(texB); - m_coordColor.PushBack(tmpColor); + m_coordColor.PushBack(localColor); } diff --git a/Sources/libewol/ewol/oObject/Sprite.h b/Sources/libewol/ewol/oObject/Sprite.h index 98fa0f24..0b99c371 100644 --- a/Sources/libewol/ewol/oObject/Sprite.h +++ b/Sources/libewol/ewol/oObject/Sprite.h @@ -25,29 +25,22 @@ #ifndef __EWOL_O_OBJECT_SPRITE_H__ #define __EWOL_O_OBJECT_SPRITE_H__ -#include +#include #include namespace ewol { - class Sprite :public ewol::OObject + class Sprite :public ewol::OObject3DTextured { private: etk::UString m_name; public: Sprite(etk::UString spriteName, float sizeX=-1, float sizeY=-1); virtual ~Sprite(void); - virtual void Draw(void); - void Clear(void); void Element(Vector2D pos, float size, float angle); void Element(Vector3D pos, float size, float angle); void Element(Vector2D pos, float size, float angle, draw::Color tmpColor); void Element(Vector3D pos, float size, float angle, draw::Color tmpColor); bool HasName(etk::UString& name) { return name == m_name; }; - protected: - ewol::TextureFile* m_resource; //!< texture resources - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point }; }; diff --git a/Sources/libewol/ewol/openGL/openGL.cpp b/Sources/libewol/ewol/openGL/openGL.cpp index 67e90f3d..e0462ee7 100644 --- a/Sources/libewol/ewol/openGL/openGL.cpp +++ b/Sources/libewol/ewol/openGL/openGL.cpp @@ -171,72 +171,3 @@ void ewol::OglMatrix::rotate(float x, float y, float z, float angle) MultiplyMatrix(m_Matrix, matrix); } - - -static void printGLString(const char *name, GLenum s) -{ - const char *v = (const char *) glGetString(s); - EWOL_INFO("GL " << name << " = " << v); -} - -static void checkGlError(const char* op) -{ - for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_INFO("after " << op << "() glError (" << error << ")"); - } -} - -#include -#include - -ewol::Program* l_program = NULL; -GLuint gvPositionHandle; - -bool TESTsetupGraphics(int w, int h) -{ - printGLString("Version", GL_VERSION); - printGLString("Vendor", GL_VENDOR); - printGLString("Renderer", GL_RENDERER); - printGLString("Extensions", GL_EXTENSIONS); - - EWOL_INFO("setupGraphics("<< w << "," << h); - glViewport(0, 0, w, h); - checkGlError("glViewport"); - - return true; -} - -bool isLoaded = false; -void basicLoad(void) -{ - if (isLoaded==false) { - etk::UString tmpString("basicShader.prog"); - if (true == ewol::resource::Keep(tmpString, l_program) ) { - gvPositionHandle = glGetAttribLocation(l_program->GetGL_ID(), "vPosition"); - checkGlError("glGetAttribLocation"); - EWOL_INFO("glGetAttribLocation(\"vPosition\") = " << gvPositionHandle); - } - isLoaded = true; - } -} - - -const GLfloat gTriangleVertices[] = { 0.0f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f }; -//const GLfloat gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f }; - -void TEST_renderFrame(void) -{ - static float grey = 0.5; - basicLoad(); - grey += 0.01f; - if (grey > 1.0f) { - grey = 0.0f; - } - glClearColor(grey, grey, grey, 1.0f); - glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - l_program->Use(); - glVertexAttribPointer( gvPositionHandle, 2, GL_FLOAT, GL_FALSE, 0, gTriangleVertices); - glEnableVertexAttribArray(gvPositionHandle); - glDrawArrays(GL_TRIANGLES, 0, 3); - l_program->UnUse(); -} \ No newline at end of file diff --git a/Sources/libewol/ewol/openGL/openGL.h b/Sources/libewol/ewol/openGL/openGL.h index 46b0814f..27e25210 100644 --- a/Sources/libewol/ewol/openGL/openGL.h +++ b/Sources/libewol/ewol/openGL/openGL.h @@ -30,17 +30,23 @@ extern "C" { #endif #if defined(__TARGET_OS__Linux) - // TO ENABLE THE SHADER api ... - #define GL_GLEXT_PROTOTYPES + #ifdef __VIDEO__OPENGL_ES_2 + // TO ENABLE THE SHADER api ... + #define GL_GLEXT_PROTOTYPES + #endif #include - /* - #include - #include - */ #elif defined(__TARGET_OS__Android) - #include - #include + #ifdef __VIDEO__OPENGL_ES_2 + #include + #include + #else + + #endif #elif defined(__TARGET_OS__Windows) + #ifdef __VIDEO__OPENGL_ES_2 + // TO ENABLE THE SHADER api ... + #define GL_GLEXT_PROTOTYPES + #endif #include #elif defined(__TARGET_OS__MacOs) @@ -65,9 +71,6 @@ namespace ewol { }; }; -bool TESTsetupGraphics(int w, int h); -void TEST_renderFrame(void); - #ifdef __cplusplus } #endif diff --git a/Sources/libewol/ewol/os/eSystem.cpp b/Sources/libewol/ewol/os/eSystem.cpp index 523b0f67..0ea30f73 100644 --- a/Sources/libewol/ewol/os/eSystem.cpp +++ b/Sources/libewol/ewol/os/eSystem.cpp @@ -526,7 +526,6 @@ bool eSystem::Draw(bool displayEveryTime) // FPS display system l_FpsSystem.Tic(); if (true == isGlobalSystemInit) { - #if 1 // process the events ewolProcessEvents(); // call all the widget that neded to do something periodicly @@ -549,9 +548,6 @@ bool eSystem::Draw(bool displayEveryTime) tmpWindows->SysDraw(); } } - #else - TEST_renderFrame(); - #endif glFlush(); } // FPS display system diff --git a/Sources/libewol/ewol/os/gui.X11.cpp b/Sources/libewol/ewol/os/gui.X11.cpp index 29dd2c58..7d387253 100644 --- a/Sources/libewol/ewol/os/gui.X11.cpp +++ b/Sources/libewol/ewol/os/gui.X11.cpp @@ -394,8 +394,6 @@ bool CreateOGlContext(void) } else { EWOL_INFO("XF86 DRI NOT available\n"); } - // start openGL shader mode ... - TESTsetupGraphics(400, 300); return true; } diff --git a/Sources/libewol/ewol/texture/Texture.h b/Sources/libewol/ewol/texture/Texture.h index 25dc39b7..4f186120 100644 --- a/Sources/libewol/ewol/texture/Texture.h +++ b/Sources/libewol/ewol/texture/Texture.h @@ -55,6 +55,7 @@ namespace ewol { public: Texture(etk::UString tmpName); ~Texture(void); + virtual const char* GetType(void) { return "ewol::Texture"; }; // you must set the size here, because it will be set in multiple of pow(2) void SetImageSize(Vector2D newSize); // get the reference on this image to draw nomething on it ... diff --git a/Sources/libewol/ewol/texture/TextureFile.h b/Sources/libewol/ewol/texture/TextureFile.h index 169503ff..6084d580 100644 --- a/Sources/libewol/ewol/texture/TextureFile.h +++ b/Sources/libewol/ewol/texture/TextureFile.h @@ -37,6 +37,7 @@ namespace ewol public: TextureFile(etk::UString genName, etk::UString fileName, Vector2D size); ~TextureFile(void) { }; + virtual const char* GetType(void) { return "ewol::TextureFile"; }; }; }; diff --git a/Sources/libewol/file.mk b/Sources/libewol/file.mk index 3725655b..6f3914f9 100644 --- a/Sources/libewol/file.mk +++ b/Sources/libewol/file.mk @@ -29,6 +29,7 @@ FILE_LIST+= ewol/oObject/OObject.cpp \ ewol/oObject/2DTextColored.cpp \ ewol/oObject/2DColored.cpp \ ewol/oObject/2DTextured.cpp \ + ewol/oObject/3DTextured.cpp \ ewol/oObject/Sprite.cpp # texture management diff --git a/share/textured.frag b/share/textured.frag index 85277be0..d6c7c14c 100644 --- a/share/textured.frag +++ b/share/textured.frag @@ -5,5 +5,5 @@ varying vec2 f_texcoord; varying vec4 f_color; void main(void) { - gl_FragColor = texture2D(EW_texID, f_texcoord);// * f_color; + gl_FragColor = texture2D(EW_texID, f_texcoord) * f_color; } diff --git a/share/textured3D.frag b/share/textured3D.frag new file mode 100644 index 00000000..d6c7c14c --- /dev/null +++ b/share/textured3D.frag @@ -0,0 +1,9 @@ +// Input : +uniform sampler2D EW_texID; + +varying vec2 f_texcoord; +varying vec4 f_color; + +void main(void) { + gl_FragColor = texture2D(EW_texID, f_texcoord) * f_color; +} diff --git a/share/textured3D.prog b/share/textured3D.prog new file mode 100644 index 00000000..35578b66 --- /dev/null +++ b/share/textured3D.prog @@ -0,0 +1,2 @@ +textured3D.vert +textured3D.frag \ No newline at end of file diff --git a/share/textured3D.vert b/share/textured3D.vert new file mode 100644 index 00000000..d4bcb61d --- /dev/null +++ b/share/textured3D.vert @@ -0,0 +1,18 @@ +// Input : +attribute vec2 EW_coord3d; +attribute vec2 EW_texture2d; +attribute vec4 EW_color; +uniform mat4 EW_MatrixTransformation; + +// output : +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); + // set texture output coord + f_texcoord = EW_texture2d; + // set output color : + f_color = EW_color; +}