Set double compilation mode
This commit is contained in:
parent
68a53a7068
commit
ed0b62b13f
@ -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
|
||||
|
||||
|
@ -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) { };
|
||||
|
@ -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<l_resourceList.Size(); iii++) {
|
||||
for (int32_t iii=l_resourceList.Size()-1; 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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
|
||||
glPushMatrix();
|
||||
// Enable Pointers
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||
|
||||
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();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||
//etk::Vector<linkCoord_ts> m_linkCoord; //!< internal link between point to generate triangle
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||
draw::Colorf m_color[3];
|
||||
#else
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
draw::Color m_color[3];
|
||||
#endif
|
||||
int32_t m_triElement;
|
||||
draw::Colorf m_color[3];
|
||||
Vector2D<float> m_triangle[3];
|
||||
void GenerateTriangle(void);
|
||||
void ResetCount(void);
|
||||
|
@ -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)
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <ewol/oObject/OObject.h>
|
||||
#include <ewol/font/TexturedFont.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
|
||||
namespace ewol {
|
||||
class OObject2DTextColored :public ewol::OObject
|
||||
@ -44,11 +45,23 @@ namespace ewol {
|
||||
int32_t Text(Vector2D<float> textPos, const etk::UString& unicodeString);
|
||||
int32_t Text(Vector2D<float> 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<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||
#else
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
#endif
|
||||
public:
|
||||
void SetFont(etk::UString fontName);
|
||||
void SetSize(int32_t fontSize);
|
||||
|
@ -36,16 +36,18 @@ ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX
|
||||
if (false == ewol::resource::Keep(textureName, m_resource, Vector2D<int32_t>(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
|
||||
}
|
||||
|
||||
|
@ -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<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||
#else
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
204
Sources/libewol/ewol/oObject/3DTextured.cpp
Normal file
204
Sources/libewol/ewol/oObject/3DTextured.cpp
Normal file
@ -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 <ewol/oObject/3DTextured.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
|
||||
#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<int32_t>(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<float> 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);
|
||||
}
|
63
Sources/libewol/ewol/oObject/3DTextured.h
Normal file
63
Sources/libewol/ewol/oObject/3DTextured.h
Normal file
@ -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 <ewol/oObject/OObject.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
|
||||
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<Vector3D<float> > m_coord; //!< internal coord of the object
|
||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||
#else
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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<int32_t>(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<float> pos, float size, float angle)
|
||||
@ -122,6 +83,11 @@ void ewol::Sprite::Element(Vector3D<float> 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<float> point = pos;
|
||||
float yyySin = sin(angle) * size;
|
||||
float xxxCos = cos(angle) * size;
|
||||
@ -130,34 +96,34 @@ void ewol::Sprite::Element(Vector3D<float> 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);
|
||||
}
|
||||
|
||||
|
@ -25,29 +25,22 @@
|
||||
#ifndef __EWOL_O_OBJECT_SPRITE_H__
|
||||
#define __EWOL_O_OBJECT_SPRITE_H__
|
||||
|
||||
#include <ewol/oObject/OObject.h>
|
||||
#include <ewol/oObject/3DTextured.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
|
||||
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<float> pos, float size, float angle);
|
||||
void Element(Vector3D<float> pos, float size, float angle);
|
||||
void Element(Vector2D<float> pos, float size, float angle, draw::Color tmpColor);
|
||||
void Element(Vector3D<float> 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<Vector3D<float> > m_coord; //!< internal coord of the object
|
||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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 <ewol/openGL/Program.h>
|
||||
#include <ewol/ResourceManager.h>
|
||||
|
||||
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();
|
||||
}
|
@ -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 <GL/gl.h>
|
||||
/*
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glext.h>
|
||||
*/
|
||||
#elif defined(__TARGET_OS__Android)
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#ifdef __VIDEO__OPENGL_ES_2
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
|
||||
#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)
|
||||
|
||||
@ -65,9 +71,6 @@ namespace ewol {
|
||||
};
|
||||
};
|
||||
|
||||
bool TESTsetupGraphics(int w, int h);
|
||||
void TEST_renderFrame(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -394,8 +394,6 @@ bool CreateOGlContext(void)
|
||||
} else {
|
||||
EWOL_INFO("XF86 DRI NOT available\n");
|
||||
}
|
||||
// start openGL shader mode ...
|
||||
TESTsetupGraphics(400, 300);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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<int32_t> newSize);
|
||||
// get the reference on this image to draw nomething on it ...
|
||||
|
@ -37,6 +37,7 @@ namespace ewol
|
||||
public:
|
||||
TextureFile(etk::UString genName, etk::UString fileName, Vector2D<int32_t> size);
|
||||
~TextureFile(void) { };
|
||||
virtual const char* GetType(void) { return "ewol::TextureFile"; };
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
9
share/textured3D.frag
Normal file
9
share/textured3D.frag
Normal file
@ -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;
|
||||
}
|
2
share/textured3D.prog
Normal file
2
share/textured3D.prog
Normal file
@ -0,0 +1,2 @@
|
||||
textured3D.vert
|
||||
textured3D.frag
|
18
share/textured3D.vert
Normal file
18
share/textured3D.vert
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user