diff --git a/data/color3.frag b/data/color3.frag index cb8e54cd..0d439173 100644 --- a/data/color3.frag +++ b/data/color3.frag @@ -6,5 +6,5 @@ precision mediump int; varying vec4 f_color; void main(void) { - gl_FragColor = f_color; + gl_FragColor = f_color; } diff --git a/data/color3.vert b/data/color3.vert index 10c287e0..d12c73b9 100644 --- a/data/color3.vert +++ b/data/color3.vert @@ -14,6 +14,5 @@ varying vec4 f_color; void main(void) { gl_Position = EW_MatrixTransformation * EW_MatrixPosition * vec4(EW_coord3d, 1.0); - //gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0); f_color = EW_color; } diff --git a/external/ege b/external/ege index e0f0c1d6..c838fc6e 160000 --- a/external/ege +++ b/external/ege @@ -1 +1 @@ -Subproject commit e0f0c1d65b779382b3a3fd793fb074e377c9a5bc +Subproject commit c838fc6e3e6bb6e0419d7e45a8cd15a1794e617c diff --git a/sources/ewol/context/Context.cpp b/sources/ewol/context/Context.cpp index dbbd4d19..88dec9d3 100644 --- a/sources/ewol/context/Context.cpp +++ b/sources/ewol/context/Context.cpp @@ -641,7 +641,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) { m_FpsFlush.tic(); m_FpsFlush.incrementCounter(); } - glFlush(); + ewol::openGL::flush(); //glFinish(); if (m_displayFps == true) { m_FpsFlush.toc(); diff --git a/sources/ewol/openGL/openGL.cpp b/sources/ewol/openGL/openGL.cpp index 4bcc3a59..4637cda6 100644 --- a/sources/ewol/openGL/openGL.cpp +++ b/sources/ewol/openGL/openGL.cpp @@ -12,6 +12,22 @@ #include #include //#define DIRECT_MODE + + +static void checkGlError(const char* _op, int32_t _localLine) { + bool isPresent = false; + for (GLint error = glGetError(); error; error = glGetError()) { + EWOL_ERROR("after " << _op << "():" << _localLine << " glError(" << error << ")"); + isPresent = true; + } + if (isPresent == true) { + EWOL_CRITICAL("plop"); + } +} + + + + /** * @brief get the draw mutex (ewol render). * @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time. @@ -112,6 +128,10 @@ void ewol::openGL::finish() { void ewol::openGL::flush() { l_programId = -1; l_textureflags = 0; + glFlush(); + EWOL_ERROR("========================" ); + EWOL_ERROR("== FLUSH OPEN GL ==" ); + EWOL_ERROR("========================"); } void ewol::openGL::swap() { @@ -415,3 +435,54 @@ void ewol::openGL::useProgram(int32_t _id) { } + + +bool ewol::openGL::genBuffers(std::vector& _buffers) { + if (_buffers.size() == 0) { + EWOL_WARNING("try to generate vector buffer with size 0"); + return true; + } + EWOL_VERBOSE("Create N=" << _buffers.size() << " Buffer"); + glGenBuffers(_buffers.size(), &_buffers[0]); + checkGlError("glGenBuffers", __LINE__); + bool hasError = false; + for (size_t iii=0; iii<_buffers.size(); iii++) { + if (_buffers[iii] == 0) { + EWOL_ERROR("[" << iii << "] error to create a buffer id=" << _buffers[iii]); + hasError = true; + } + } + return hasError; +} + +bool ewol::openGL::deleteBuffers(std::vector& _buffers) { + if (_buffers.size() == 0) { + EWOL_WARNING("try to delete vector buffer with size 0"); + return true; + } + glDeleteBuffers(_buffers.size(), &_buffers[0]); + checkGlError("glDeleteBuffers", __LINE__); + for (auto &it : _buffers) { + it = 0; + } + return true; +} + +bool ewol::openGL::bindBuffer(GLuint _bufferId) { + glBindBuffer(GL_ARRAY_BUFFER, _bufferId); + checkGlError("glBindBuffer", __LINE__); + return true; +} + +bool ewol::openGL::bufferData(size_t _size, const void* _data, GLenum _usage) { + glBufferData(GL_ARRAY_BUFFER, _size, _data, _usage); + checkGlError("glBufferData", __LINE__); + return true; +} + +bool ewol::openGL::unbindBuffer() { + glBindBuffer(GL_ARRAY_BUFFER, 0); + checkGlError("glBindBuffer(0)", __LINE__); + return true; +} + diff --git a/sources/ewol/openGL/openGL.h b/sources/ewol/openGL/openGL.h index 6a0e2bc2..48e73ad2 100644 --- a/sources/ewol/openGL/openGL.h +++ b/sources/ewol/openGL/openGL.h @@ -191,6 +191,13 @@ namespace ewol { */ void useProgram(int32_t _id); void reset(); + + + bool genBuffers(std::vector& _buffers); + bool deleteBuffers(std::vector& _buffers); + bool bindBuffer(GLuint _bufferId); + bool bufferData(size_t _size, const void* _data, GLenum _usage); + bool unbindBuffer(); }; std::ostream& operator <<(std::ostream& _os, const enum openGL::openGlFlags& _obj); std::ostream& operator <<(std::ostream& _os, const enum openGL::renderMode& _obj); diff --git a/sources/ewol/resource/Program.cpp b/sources/ewol/resource/Program.cpp index 554c082e..8f70a27c 100644 --- a/sources/ewol/resource/Program.cpp +++ b/sources/ewol/resource/Program.cpp @@ -107,9 +107,32 @@ ewol::resource::Program::~Program() { m_hasTexture1 = false; } +std::ostream& ewol::resource::operator <<(std::ostream& _os, const ewol::resource::progAttributeElement& _obj) { + _os << "{"; + _os << "[" << _obj.m_name << "] "; + _os << _obj.m_elementId << " "; + _os << _obj.m_isLinked; + _os << "}"; + return _os; +} + +std::ostream& ewol::resource::operator <<(std::ostream& _os, const std::vector& _obj){ + _os << "{"; + for (auto &it : _obj) { + _os << it; + } + _os << "}"; + return _os; +} + static void checkGlError(const char* _op, int32_t _localLine) { + bool isPresent = false; for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_INFO("after " << _op << "():" << _localLine << " glError(" << error << ")"); + EWOL_ERROR("after " << _op << "():" << _localLine << " glError(" << error << ")"); + isPresent = true; + } + if (isPresent == true) { + EWOL_CRITICAL("plop"); } } @@ -138,8 +161,10 @@ int32_t ewol::resource::Program::getAttribute(std::string _elementName) { tmp.m_isLinked = true; if (tmp.m_elementId<0) { checkGlError("glGetAttribLocation", __LINE__); - EWOL_WARNING("glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); + EWOL_WARNING(" [" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); tmp.m_isLinked = false; + } else { + EWOL_INFO(" [" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); } m_elementList.push_back(tmp); return m_elementList.size()-1; @@ -159,8 +184,10 @@ int32_t ewol::resource::Program::getUniform(std::string _elementName) { tmp.m_isLinked = true; if (tmp.m_elementId<0) { checkGlError("glGetUniformLocation", __LINE__); - EWOL_WARNING("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); + EWOL_WARNING(" [" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); tmp.m_isLinked = false; + } else { + EWOL_INFO(" [" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); } m_elementList.push_back(tmp); return m_elementList.size()-1; @@ -326,6 +353,7 @@ void ewol::resource::Program::sendAttribute(int32_t _idElem, if (m_elementList[_idElem].m_isLinked == false) { return; } + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " element"); glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL _nbElement, // number of elements per vertex, here (r,g,b,a) GL_FLOAT, // the type of each element @@ -352,16 +380,23 @@ void ewol::resource::Program::sendAttributePointer(int32_t _idElem, if (false == m_elementList[_idElem].m_isLinked) { return; } + EWOL_INFO(m_elementList); + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _vbo->getElementSize(_index) << " element on oglID=" << _vbo->getGL_ID(_index) << " VBOindex=" << _index); glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index)); + checkGlError("glBindBuffer", __LINE__); + EWOL_ERROR(" id=" << m_elementList[_idElem].m_elementId); + EWOL_ERROR(" eleme size=" << _vbo->getElementSize(_index)); + EWOL_ERROR(" jump sample=" << _jumpBetweenSample); + EWOL_ERROR(" offset=" << _offset); glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL _vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a) GL_FLOAT, // the type of each element GL_FALSE, // take our values as-is _jumpBetweenSample, // no extra data between each position (GLvoid *)_offset); // Pointer on the buffer - //checkGlError("glVertexAttribPointer", __LINE__); + checkGlError("glVertexAttribPointer", __LINE__); glEnableVertexAttribArray(m_elementList[_idElem].m_elementId); - //checkGlError("glEnableVertexAttribArray", __LINE__); + checkGlError("glEnableVertexAttribArray", __LINE__); } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -377,10 +412,12 @@ void ewol::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix if (false == m_elementList[_idElem].m_isLinked) { return; } + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send 1 matrix"); // note : Android des not supported the transposition of the matrix, then we will done it oursef: if (true == _transpose) { mat4 tmp = _matrix; tmp.transpose(); + EWOL_ERROR("matrix:" << tmp); glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, tmp.m_mat); } else { glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, _matrix.m_mat); @@ -443,6 +480,7 @@ void ewol::resource::Program::uniform4f(int32_t _idElem, float _value1, float _v if (false == m_elementList[_idElem].m_isLinked) { return; } + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send 4 values"); glUniform4f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4); //checkGlError("glUniform4f", __LINE__); } @@ -572,6 +610,7 @@ void ewol::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, co EWOL_ERROR("nullptr Input pointer to send at open GL ..."); return; } + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec3"); glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value); //checkGlError("glUniform3fv", __LINE__); } @@ -594,6 +633,7 @@ void ewol::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, co EWOL_ERROR("nullptr Input pointer to send at open GL ..."); return; } + EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec4"); glUniform4fv(m_elementList[_idElem].m_elementId, _nbElement, _value); //checkGlError("glUniform4fv", __LINE__); } diff --git a/sources/ewol/resource/Program.h b/sources/ewol/resource/Program.h index c2262324..b25d1bc9 100644 --- a/sources/ewol/resource/Program.h +++ b/sources/ewol/resource/Program.h @@ -33,6 +33,10 @@ namespace ewol { bool m_isAttribute; //!< true if it was an attribute element, otherwite it was an uniform bool m_isLinked; //!< if this element does not exist this is false }; + //! @not-in-doc + std::ostream& operator <<(std::ostream& _os, const ewol::resource::progAttributeElement& _obj); + //! @not-in-doc + std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); /** * @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation * The input file must have the form : "myFile.prog" diff --git a/sources/ewol/resource/Shader.cpp b/sources/ewol/resource/Shader.cpp index a93a320e..b7378bda 100644 --- a/sources/ewol/resource/Shader.cpp +++ b/sources/ewol/resource/Shader.cpp @@ -55,7 +55,7 @@ ewol::resource::Shader::~Shader() { static void checkGlError(const char* _op) { for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_INFO("after " << _op << "() glError (" << error << ")"); + EWOL_ERROR("after " << _op << "() glError (" << error << ")"); } } #define LOG_OGL_INTERNAL_BUFFER_LEN (8192) @@ -70,13 +70,15 @@ void ewol::resource::Shader::updateContext() { m_shader = 0; return; } + EWOL_INFO("Create Shader : '" << m_name << "'"); m_shader = glCreateShader(m_type); if (!m_shader) { EWOL_ERROR("glCreateShader return error ..."); checkGlError("glCreateShader"); + EWOL_CRITICAL(" can not load shader"); return; } else { - //EWOL_INFO("Creater shader with GLID=" << m_shader); + EWOL_INFO("Compile shader with GLID=" << m_shader); glShaderSource(m_shader, 1, (const char**)&m_fileData, nullptr); glCompileShader(m_shader); GLint compiled = 0; @@ -95,6 +97,7 @@ void ewol::resource::Shader::updateContext() { for (size_t iii=0 ; iii #include -// TODO : Remove this ... -#define NB_VBO_MAX (20) - namespace ewol { namespace resource { /** @@ -26,12 +23,11 @@ namespace ewol { */ class VirtualBufferObject : public ewol::Resource { private : - size_t m_nbVBO; bool m_exist; //!< This data is availlable in the Graphic card - GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO - bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ... - std::vector m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ... - int8_t m_vboSizeDataOffset[NB_VBO_MAX]; //!< Internal size of the VBO (dynamicly set) + std::vector m_vbo; //!< openGl ID of this VBO + std::vector m_vboUsed; //!< true if the VBO is allocated or used ... + std::vector> m_buffer; //!< data that is availlable in the VBO system ... + std::vector m_vboSizeDataOffset; //!< Internal size of the VBO (dynamicly set) protected: /** * @brief Constructor of this VBO.