From 6ac6bc50d02fda61d87325612f1153f18ce87b4f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 24 Aug 2012 18:05:11 +0200 Subject: [PATCH] first new api of openGl working and create a resourceManager => this one will be used --- Sources/libewol/Android.mk | 8 +- Sources/libewol/ewol/Resource.h | 51 +++++ Sources/libewol/ewol/ResourceManager.cpp | 177 +++++++++++++++ Sources/libewol/ewol/ResourceManager.h | 54 +++++ Sources/libewol/ewol/font/Font.h | 16 +- Sources/libewol/ewol/font/TexturedFont.h | 1 + Sources/libewol/ewol/openGL/Program.cpp | 41 ++++ Sources/libewol/ewol/openGL/Program.h | 48 +++++ Sources/libewol/ewol/openGL/Shader.cpp | 44 ++++ Sources/libewol/ewol/openGL/Shader.h | 49 +++++ Sources/libewol/ewol/openGL/openGL.cpp | 203 ++++++++++++++++++ .../ewol/{openGl.h => openGL/openGL.h} | 8 +- Sources/libewol/ewol/openGl.cpp | 58 ----- Sources/libewol/ewol/os/eSystem.cpp | 3 + Sources/libewol/ewol/os/gui.X11.cpp | 2 + 15 files changed, 686 insertions(+), 77 deletions(-) create mode 100644 Sources/libewol/ewol/Resource.h create mode 100644 Sources/libewol/ewol/ResourceManager.cpp create mode 100644 Sources/libewol/ewol/ResourceManager.h create mode 100644 Sources/libewol/ewol/openGL/Program.cpp create mode 100644 Sources/libewol/ewol/openGL/Program.h create mode 100644 Sources/libewol/ewol/openGL/Shader.cpp create mode 100644 Sources/libewol/ewol/openGL/Shader.h create mode 100644 Sources/libewol/ewol/openGL/openGL.cpp rename Sources/libewol/ewol/{openGl.h => openGL/openGL.h} (89%) delete mode 100644 Sources/libewol/ewol/openGl.cpp diff --git a/Sources/libewol/Android.mk b/Sources/libewol/Android.mk index 51dac5d9..0e0d1874 100644 --- a/Sources/libewol/Android.mk +++ b/Sources/libewol/Android.mk @@ -16,12 +16,12 @@ LOCAL_LIBRARIES := etk freetype tinyxml libzip libpng parsersvg lua LOCAL_C_INCLUDES := LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -ldl -llog + +LOCAL_EXPORT_LDLIBS := -lGLESv2 -ldl -llog LOCAL_CFLAGS := -Wno-write-strings \ -DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \ - -DDATA_IN_APK \ - -DLUA_COMPAT_ALL + -DDATA_IN_APK # load the common sources file of the platform include $(LOCAL_PATH)/file.mk @@ -29,7 +29,7 @@ include $(LOCAL_PATH)/file.mk LOCAL_SRC_FILES := ewol/os/gui.Android.cpp $(FILE_LIST) # Ewol Test Software : -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz +LOCAL_LDLIBS := -lGLESv2 -ldl -llog -lz include $(BUILD_STATIC_LIBRARY) diff --git a/Sources/libewol/ewol/Resource.h b/Sources/libewol/ewol/Resource.h new file mode 100644 index 00000000..8d883315 --- /dev/null +++ b/Sources/libewol/ewol/Resource.h @@ -0,0 +1,51 @@ +/** + ******************************************************************************* + * @file ewol/Resources.h + * @brief ewol resources template (header) + * @author Edouard DUPIN + * @date 24/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 __RESOURCES_H__ +#define __RESOURCES_H__ + +#include +#include + +namespace ewol +{ + // class resources is pure virtual + class Resource { + etk::UString m_name; + uint32_t m_counter; + public: + Resource(etk::UString& filename) : m_name(filename), m_counter(1) { }; + virtual ~Resource(void) { }; + bool HasName(etk::UString& fileName) { return fileName==m_name; }; + etk::UString GetName(void) { return m_name; }; + void Increment(void) { m_counter++; }; + bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; }; + virtual const char* GetType(void)=0; + }; +}; + + + +#endif + diff --git a/Sources/libewol/ewol/ResourceManager.cpp b/Sources/libewol/ewol/ResourceManager.cpp new file mode 100644 index 00000000..cbee6b4a --- /dev/null +++ b/Sources/libewol/ewol/ResourceManager.cpp @@ -0,0 +1,177 @@ +/** + ******************************************************************************* + * @file ewol/ResourcesManager.h + * @brief ewol resources manager template (header) + * @author Edouard DUPIN + * @date 24/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. + * + ******************************************************************************* + */ + + +#include +#include +#include + +static etk::Vector l_resourceList; + + +void ewol::resource::Init(void) +{ + // nothing to do in theory then, we clean the buffers : + // NOTE : If we do domething here, then the system does not work corectly + if (l_resourceList.Size() != 0) { + EWOL_CRITICAL("Start with a resource manager Not empty, number of resources loaded : " << l_resourceList.Size()); + } + l_resourceList.Clear(); +} + +void ewol::resource::UnInit(void) +{ + // remove textured font ... + for (int32_t iii=0; iii=0; iii--) { + if (l_resourceList[iii] != NULL) { + if(l_resourceList[iii]->HasName(name)) { + l_resourceList[iii]->Increment(); + return l_resourceList[iii]; + } + } + } + // we did not find it ... + return NULL; +} + + +// return the type of the resource ... +bool ewol::resource::Keep(etk::UString& filename, ewol::TexturedFont*& object, int32_t size) +{ + object = NULL; + for (int32_t iii=l_resourceList.Size()-1; iii>=0; iii--) { + if (l_resourceList[iii] != NULL) { + if(l_resourceList[iii]->HasName(name)) { + ewol::TexturedFont* tmpObject = static_cast(l_resourceList[iii]); + if (NULL!=tmpObject) { + if (tmpObject->getFontSize() == size) { + l_resourceList[iii]->Increment(); + object = static_castl_resourceList[iii] + return false; + } + } + // good name but not good Size + } + } + } + // need to crate a new one ... + object = new ewol::TexturedFont(filename, size); + if (NULL == object) { + EWOL_ERROR("allocation error of a resource : " << filename); + return false; + } + l_resourceList.PushBack(object); + return true; +} + + +bool ewol::resource::Keep(etk::UString& filename, ewol::Font*& object) +{ + object = static_cast(Keep(filename)); + if (NULL != object) { + return true; + } + // need to crate a new one ... + object = new ewol::Font(filename, size); + if (NULL == object) { + EWOL_ERROR("allocation error of a resource : " << filename); + return false; + } + l_resourceList.PushBack(object); + return true; +} + + +bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object) +{ + object = static_cast(Keep(filename)); + if (NULL != object) { + return true; + } + // need to crate a new one ... + object = new ewol::Program(filename, size); + if (NULL == object) { + EWOL_ERROR("allocation error of a resource : " << filename); + return false; + } + l_resourceList.PushBack(object); + return true; +} + + +bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object) +{ + object = static_cast(Keep(filename)); + if (NULL != object) { + return true; + } + // need to crate a new one ... + object = new ewol::Shader(filename, size); + if (NULL == object) { + EWOL_ERROR("allocation error of a resource : " << filename); + return false; + } + l_resourceList.PushBack(object); + return true; +} + + +void ewol::resource::Release(ewol::Resource*& object) +{ + if (NUUL == object) { + EWOL_ERROR("Try to remove a resource that have null pointer ..."); + return; + } + for (int32_t iii=l_resourceList.Size()-1; iii>=0; iii--) { + if (l_resourceList[iii] != NULL) { + if(l_resourceList[iii] == object) { + if (true == l_resourceList[iii]->Decrement()) { + // delete element + delete(l_resourceList[iii]); + // remove element from the list : + l_resourceList.Erase(iii); + } + // insidiously remove the pointer for the caller ... + object = NULL; + return; + } + } + } + EWOL_ERROR("Can not find the resources in the list : " << (int64_t)object); + // insidiously remove the pointer for the caller ... + object = NULL; +} + diff --git a/Sources/libewol/ewol/ResourceManager.h b/Sources/libewol/ewol/ResourceManager.h new file mode 100644 index 00000000..c5b41d6d --- /dev/null +++ b/Sources/libewol/ewol/ResourceManager.h @@ -0,0 +1,54 @@ +/** + ******************************************************************************* + * @file ewol/ResourcesManager.h + * @brief ewol resources manager template (header) + * @author Edouard DUPIN + * @date 24/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 __RESOURCES_MANAGER_H__ +#define __RESOURCES_MANAGER_H__ + +#include +#include +#include +#include +#include +#include +#include + +namespace ewol +{ + namespace resource { + void Init(void); + void UnInit(void); + + // return the type of the resource ... + bool Keep(etk::UString& filename, ewol::TexturedFont*& object, int32_t size); + bool Keep(etk::UString& filename, ewol::Font*& object); + bool Keep(etk::UString& filename, ewol::Program*& object); + bool Keep(etk::UString& filename, ewol::Shader*& object); + + void Release(ewol::resource*& object); + } +}; + + +#endif + diff --git a/Sources/libewol/ewol/font/Font.h b/Sources/libewol/ewol/font/Font.h index 9886c3e3..e7ce33b1 100644 --- a/Sources/libewol/ewol/font/Font.h +++ b/Sources/libewol/ewol/font/Font.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace ewol @@ -76,21 +77,10 @@ namespace ewol Vector2D m_advance; // space use in the display for this specific char } GlyphProperty; - class Font { - private: - etk::UString m_name; - uint32_t m_counter; + class Font : public ewol::Resource public: - Font(etk::UString fontFolder, etk::UString fontName) : - m_counter(1) - { - m_name = fontName; - }; + Font(etk::UString fontFolder, etk::UString fontName) : ewol::Resource(fontName) {}; virtual ~Font(void) {}; - bool HasName(etk::UString& fileName) { return fileName==m_name; }; - etk::UString GetName(void) { return m_name; }; - void Increment(void) { m_counter++; }; - bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; }; virtual int32_t Draw(draw::Image& imageOut, int32_t fontSize, Vector2D textPos, diff --git a/Sources/libewol/ewol/font/TexturedFont.h b/Sources/libewol/ewol/font/TexturedFont.h index 5cb6f557..e59d918c 100644 --- a/Sources/libewol/ewol/font/TexturedFont.h +++ b/Sources/libewol/ewol/font/TexturedFont.h @@ -52,6 +52,7 @@ namespace ewol public: TexturedFont(etk::UString fontName, int32_t size); ~TexturedFont(void); + int32_t getFontSize(void) { return m_size; }; bool HasName(etk::UString& fileName, int32_t size) { return (m_size!=size)?false:((m_font==NULL)?false:m_font->HasName(fileName)); }; void Increment(void) { m_counter++; }; bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; }; diff --git a/Sources/libewol/ewol/openGL/Program.cpp b/Sources/libewol/ewol/openGL/Program.cpp new file mode 100644 index 00000000..6c62fad3 --- /dev/null +++ b/Sources/libewol/ewol/openGL/Program.cpp @@ -0,0 +1,41 @@ +/** + ******************************************************************************* + * @file ewol/openGL/Program.cpp + * @brief ewol openGl Program shader system (Sources) + * @author Edouard DUPIN + * @date 24/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. + * + ******************************************************************************* + */ + +#include +#include +#include + +ewol::Program::Program(etk::UString& filename) : ewol::Resource(filename) + m_program(0), + m_needToReleaseShader(false) +{ + +} + +ewol::Program::~Program(void) +{ + +} + + diff --git a/Sources/libewol/ewol/openGL/Program.h b/Sources/libewol/ewol/openGL/Program.h new file mode 100644 index 00000000..1563dd68 --- /dev/null +++ b/Sources/libewol/ewol/openGL/Program.h @@ -0,0 +1,48 @@ +/** + ******************************************************************************* + * @file ewol/openGL/Program.h + * @brief ewol openGl Program shader system (header) + * @author Edouard DUPIN + * @date 24/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 __OPEN_GL__PROGRAM_H__ +#define __OPEN_GL__PROGRAM_H__ + +#include +#include +#include + +namespace ewol +{ + Class Program : public ewol::Resource + { + private : + GLuint m_program; + bool m_needToReleaseShader; + public: + Program(etk::UString& filename); + virtual ~Program(void); + GLuint GetGL_ID(void) { return m_program; }; + }; +}; + + +#endif + diff --git a/Sources/libewol/ewol/openGL/Shader.cpp b/Sources/libewol/ewol/openGL/Shader.cpp new file mode 100644 index 00000000..4c62cdb9 --- /dev/null +++ b/Sources/libewol/ewol/openGL/Shader.cpp @@ -0,0 +1,44 @@ +/** + ******************************************************************************* + * @file ewol/openGL/Shader.cpp + * @brief ewol openGl Shader system (Sources) + * @author Edouard DUPIN + * @date 24/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. + * + ******************************************************************************* + */ + +#include +#include +#include + + + +ewol::Shader::Shader(etk::UString& filename): + ewol::Resource(filename), + m_shader(0), + m_type(0) +{ + +} + +ewol::Shader::~Shader(void) +{ + +} + + diff --git a/Sources/libewol/ewol/openGL/Shader.h b/Sources/libewol/ewol/openGL/Shader.h new file mode 100644 index 00000000..4c994d03 --- /dev/null +++ b/Sources/libewol/ewol/openGL/Shader.h @@ -0,0 +1,49 @@ +/** + ******************************************************************************* + * @file ewol/openGL/Shader.h + * @brief ewol openGl Shader system (header) + * @author Edouard DUPIN + * @date 24/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 __OPEN_GL__SHADER_H__ +#define __OPEN_GL__SHADER_H__ + +#include +#include +#include + +namespace ewol +{ + Class Shader : public ewol::Resource + { + private : + GLuint m_shader; + GLenum m_type; + public: + Shader(etk::UString& filename); + virtual ~Shader(void); + GLuint GetGL_ID(void) { return m_shader; }; + GLenum GetShaderType(void) { return m_type; }; + }; +}; + + +#endif + diff --git a/Sources/libewol/ewol/openGL/openGL.cpp b/Sources/libewol/ewol/openGL/openGL.cpp new file mode 100644 index 00000000..28c84122 --- /dev/null +++ b/Sources/libewol/ewol/openGL/openGL.cpp @@ -0,0 +1,203 @@ +/** + ******************************************************************************* + * @file ewol/openGL/openGL.cpp + * @brief ewol openGl abstarction (sources) + * @author Edouard DUPIN + * @date 19/09/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. + * + ******************************************************************************* + */ + +#include +#include + + +void glOrthoEwol(GLfloat left, + GLfloat right, + GLfloat bottom, + GLfloat top, + GLfloat nearVal, + GLfloat farVal) +{ + GLfloat myMatrix[4*4]; + int iii; + for(iii=0; iii<4*4 ; iii++) { + myMatrix[iii] = 0; + } + myMatrix[0] = 2.0 / (right - left); + myMatrix[5] = 2.0 / (top - bottom); + myMatrix[10] = -2.0 / (farVal - nearVal); +#if 1 + myMatrix[3] = -1*(right + left) / (right - left); + myMatrix[7] = -1*(top + bottom) / (top - bottom); + myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal); +#else + // test if matrix is not corectly instanciate ... + myMatrix[12] = -1*(right + left) / (right - left); + myMatrix[13] = -1*(top + bottom) / (top - bottom); + myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal); +#endif + myMatrix[15] = 1; + + glLoadMatrixf(myMatrix); + + +} + +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 << ")"); + } +} + +static const char gVertexShader[] = + "attribute vec4 vPosition;\n" + "void main() {\n" + " gl_Position = vPosition;\n" + "}\n"; + +static const char gFragmentShader[] = + /*"precision mediump float;\n"*/ + "void main() {\n" + " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n" + "}\n"; + +#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) +static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; + +GLuint loadShader(GLenum shaderType, const char* pSource) +{ + GLuint shader = glCreateShader(shaderType); + if (!shader) { + EWOL_ERROR("glCreateShader return error ..."); + checkGlError("glCreateShader"); + } else { + glShaderSource(shader, 1, &pSource, NULL); + glCompileShader(shader); + GLint compiled = 0; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if (!compiled) { + GLint infoLen = 0; + l_bufferDisplayError[0] = '\0'; + glGetShaderInfoLog(shader, LOG_OGL_INTERNAL_BUFFER_LEN, &infoLen, l_bufferDisplayError); + const char * tmpShaderType = "GL_FRAGMENT_SHADER"; + if (shaderType == GL_VERTEX_SHADER){ + tmpShaderType = "GL_VERTEX_SHADER"; + } + EWOL_ERROR("Could not compile \"" << tmpShaderType << "\": " << l_bufferDisplayError); + } + } + return shader; +} + +GLuint createProgram(const char* pVertexSource, const char* pFragmentSource) +{ + EWOL_INFO("Create the VERTEX shader ..."); + GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource); + if (!vertexShader) { + EWOL_ERROR("VERTEX shader return error ..."); + return 0; + } + EWOL_INFO("Create the FRAGMENT shader ..."); + GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource); + if (!pixelShader) { + EWOL_ERROR("FRAGMENT shader return error ..."); + return 0; + } + + EWOL_INFO("Create the Program ..."); + GLuint program = glCreateProgram(); + if (!program) { + EWOL_ERROR("program creation return error ..."); + + } else { + glAttachShader(program, vertexShader); + checkGlError("glAttachShader"); + glAttachShader(program, pixelShader); + checkGlError("glAttachShader"); + glLinkProgram(program); + GLint linkStatus = GL_FALSE; + glGetProgramiv(program, GL_LINK_STATUS, &linkStatus); + if (linkStatus != GL_TRUE) { + GLint bufLength = 0; + l_bufferDisplayError[0] = '\0'; + glGetProgramInfoLog(program, LOG_OGL_INTERNAL_BUFFER_LEN, &bufLength, l_bufferDisplayError); + EWOL_ERROR("Could not compile \"PROGRAM\": " << l_bufferDisplayError); + glDeleteProgram(program); + program = 0; + } + } + return program; +} + +GLuint gProgram; +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); + gProgram = createProgram(gVertexShader, gFragmentShader); + if (!gProgram) { + EWOL_ERROR("Could not create program."); + return false; + } + gvPositionHandle = glGetAttribLocation(gProgram, "vPosition"); + checkGlError("glGetAttribLocation"); + EWOL_INFO("glGetAttribLocation(\"vPosition\") = " << gvPositionHandle); + + glViewport(0, 0, w, h); + checkGlError("glViewport"); + + return 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; + + grey += 0.01f; + if (grey > 1.0f) { + grey = 0.0f; + } + glClearColor(grey, grey, grey, 1.0f); + checkGlError("glClearColor"); + glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + checkGlError("glClear"); + + glUseProgram(gProgram); + checkGlError("glUseProgram"); + + glVertexAttribPointer(gvPositionHandle, 2, GL_FLOAT, GL_FALSE, 0, gTriangleVertices); + checkGlError("glVertexAttribPointer"); + glEnableVertexAttribArray(gvPositionHandle); + checkGlError("glEnableVertexAttribArray"); + glDrawArrays(GL_TRIANGLES, 0, 3); + checkGlError("glDrawArrays"); +} \ No newline at end of file diff --git a/Sources/libewol/ewol/openGl.h b/Sources/libewol/ewol/openGL/openGL.h similarity index 89% rename from Sources/libewol/ewol/openGl.h rename to Sources/libewol/ewol/openGL/openGL.h index 31581db1..5575aae7 100644 --- a/Sources/libewol/ewol/openGl.h +++ b/Sources/libewol/ewol/openGL/openGL.h @@ -1,6 +1,6 @@ /** ******************************************************************************* - * @file ewol/openGl.h + * @file ewol/openGL/openGL.h * @brief ewol openGl abstarction (header) * @author Edouard DUPIN * @date 19/09/2012 @@ -38,7 +38,8 @@ extern "C" { #include */ #elif defined(__TARGET_OS__Android) - #include + #include + #include #elif defined(__TARGET_OS__Windows) #include #elif defined(__TARGET_OS__MacOs) @@ -51,6 +52,9 @@ extern "C" { void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal); +bool TESTsetupGraphics(int w, int h); +void TEST_renderFrame(void); + #ifdef __cplusplus } #endif diff --git a/Sources/libewol/ewol/openGl.cpp b/Sources/libewol/ewol/openGl.cpp deleted file mode 100644 index 8fcd5046..00000000 --- a/Sources/libewol/ewol/openGl.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - ******************************************************************************* - * @file ewol/openGl.cpp - * @brief ewol openGl abstarction (sources) - * @author Edouard DUPIN - * @date 19/09/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. - * - ******************************************************************************* - */ - -#include - - -void glOrthoEwol(GLfloat left, - GLfloat right, - GLfloat bottom, - GLfloat top, - GLfloat nearVal, - GLfloat farVal) -{ - GLfloat myMatrix[4*4]; - int iii; - for(iii=0; iii<4*4 ; iii++) { - myMatrix[iii] = 0; - } - myMatrix[0] = 2.0 / (right - left); - myMatrix[5] = 2.0 / (top - bottom); - myMatrix[10] = -2.0 / (farVal - nearVal); -#if 1 - myMatrix[3] = -1*(right + left) / (right - left); - myMatrix[7] = -1*(top + bottom) / (top - bottom); - myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal); -#else - // test if matrix is not corectly instanciate ... - myMatrix[12] = -1*(right + left) / (right - left); - myMatrix[13] = -1*(top + bottom) / (top - bottom); - myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal); -#endif - myMatrix[15] = 1; - - glLoadMatrixf(myMatrix); - - -} diff --git a/Sources/libewol/ewol/os/eSystem.cpp b/Sources/libewol/ewol/os/eSystem.cpp index 5c2f6205..a6fc8ff8 100644 --- a/Sources/libewol/ewol/os/eSystem.cpp +++ b/Sources/libewol/ewol/os/eSystem.cpp @@ -526,6 +526,7 @@ bool eSystem::Draw(bool displayEveryTime) // FPS display system l_FpsSystem.Tic(); if (true == isGlobalSystemInit) { + /* // process the events ewolProcessEvents(); // call all the widget that neded to do something periodicly @@ -548,6 +549,8 @@ bool eSystem::Draw(bool displayEveryTime) tmpWindows->SysDraw(); } } + */ + TEST_renderFrame(); glFlush(); } // FPS display system diff --git a/Sources/libewol/ewol/os/gui.X11.cpp b/Sources/libewol/ewol/os/gui.X11.cpp index 494b53be..7a89513b 100644 --- a/Sources/libewol/ewol/os/gui.X11.cpp +++ b/Sources/libewol/ewol/os/gui.X11.cpp @@ -394,6 +394,8 @@ bool CreateOGlContext(void) } else { EWOL_INFO("XF86 DRI NOT available\n"); } + // start openGL shader mode ... + TESTsetupGraphics(400, 300); return true; }