diff --git a/build b/build index 50b04244..7674fedb 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 50b04244084ced7421ed260866612fcbb547e1c8 +Subproject commit 7674fedbe9379979ed6ac2de0f035690b3071fe8 diff --git a/data/textured3D2.vert b/data/textured3D2.vert index 4cfb34f8..bf56ca53 100644 --- a/data/textured3D2.vert +++ b/data/textured3D2.vert @@ -22,6 +22,6 @@ void main(void) { MatrixPosition[3][0] = 0.0; MatrixPosition[3][1] = 0.0; MatrixPosition[3][2] = 0.0; - //v_ecNormal = vec3(MatrixPosition * vec4(EW_normal, 1.0) ); - v_ecNormal = vec3(MatrixPosition * vec4(EW_faceNormal, 1.0) ); + v_ecNormal = vec3(MatrixPosition * vec4(EW_normal, 1.0) ); + //v_ecNormal = vec3(MatrixPosition * vec4(EW_faceNormal, 1.0) ); } diff --git a/external/etk b/external/etk index f5f7c72a..03e91578 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit f5f7c72ad695876cf63056424f93e863884034dd +Subproject commit 03e91578914d2c5c1d6ec60fe28411bf037f6fa9 diff --git a/sources/ewol/compositing/Area.cpp b/sources/ewol/compositing/Area.cpp index cec4bd97..f7c5fcee 100644 --- a/sources/ewol/compositing/Area.cpp +++ b/sources/ewol/compositing/Area.cpp @@ -82,7 +82,7 @@ void ewol::Area::Draw(void) // color : m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_coord.Size()); m_GLprogram->UnUse(); } diff --git a/sources/ewol/compositing/Drawing.cpp b/sources/ewol/compositing/Drawing.cpp index a8b5c31b..228310d6 100644 --- a/sources/ewol/compositing/Drawing.cpp +++ b/sources/ewol/compositing/Drawing.cpp @@ -328,7 +328,7 @@ void ewol::Drawing::Draw(void) // color : m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_coord.Size()); m_GLprogram->UnUse(); } diff --git a/sources/ewol/compositing/Image.cpp b/sources/ewol/compositing/Image.cpp index 5cacb240..b65937a4 100644 --- a/sources/ewol/compositing/Image.cpp +++ b/sources/ewol/compositing/Image.cpp @@ -85,7 +85,7 @@ void ewol::Image::Draw(void) // color : m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_coord.Size()); m_GLprogram->UnUse(); } diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 952bbe4c..0c154370 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -147,7 +147,7 @@ void ewol::Shaper::Draw(void) m_GLprogram->SetTexture0(m_GLtexID, m_resourceTexture->GetId()); } // Request the draw of the elements : - glDrawArrays(GL_TRIANGLES, 0, 6); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, 6); m_GLprogram->UnUse(); } diff --git a/sources/ewol/compositing/Text.cpp b/sources/ewol/compositing/Text.cpp index 2d6e5407..880a5645 100644 --- a/sources/ewol/compositing/Text.cpp +++ b/sources/ewol/compositing/Text.cpp @@ -129,7 +129,7 @@ void ewol::Text::Draw(void) // color : m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_coord.Size()); m_GLprogram->UnUse(); } diff --git a/sources/ewol/renderer/openGL.cpp b/sources/ewol/renderer/openGL.cpp index 8f7f6499..902502c0 100644 --- a/sources/ewol/renderer/openGL.cpp +++ b/sources/ewol/renderer/openGL.cpp @@ -12,6 +12,9 @@ etk::Vector l_matrixList; mat4 l_matrixCamera; +static uint32_t l_flags = 0; +static uint32_t l_textureflags = 0; +static int32_t l_programId = 0; void ewol::openGL::Init(void) { @@ -20,6 +23,9 @@ void ewol::openGL::Init(void) mat4 tmpMat; l_matrixList.PushBack(tmpMat); l_matrixCamera.Identity(); + l_flags = 0; + l_textureflags = 0; + l_programId = -1; } @@ -93,3 +99,75 @@ void ewol::openGL::SetCameraMatrix(mat4& newOne) { l_matrixCamera = newOne; } + +void ewol::openGL::Finish(void) +{ + l_programId = -1; + l_textureflags = 0; +} + +void ewol::openGL::Flush(void) +{ + l_programId = -1; + l_textureflags = 0; + +} + +void ewol::openGL::Swap(void) +{ + +} + +void ewol::openGL::Enable(uint32_t flagID) +{ + glEnable(flagID); +} + +void ewol::openGL::Disable(uint32_t flagID) +{ + glDisable(flagID); +} + +void ewol::openGL::ActiveTexture(uint32_t flagID) +{ + glActiveTexture(flagID); +} + +void ewol::openGL::DesActiveTexture(uint32_t flagID) +{ + +} + +void ewol::openGL::DrawArrays(uint32_t mode, int32_t first, int32_t count) +{ + glDrawArrays(mode, first, count); +} + +void ewol::openGL::DrawArraysInstanced(uint32_t mode, int32_t first, int32_t count, int32_t primcount) +{ + glDrawArraysInstanced(mode, first, count, primcount); +} + +void ewol::openGL::DrawElements(uint32_t mode, int32_t count, uint32_t type, const void* indices) +{ + glDrawElements(mode, count, type, indices); +} + +void ewol::openGL::DrawRangeElements(uint32_t mode, int32_t start, int32_t end, int32_t count, uint32_t type, const void* indices) +{ + glDrawRangeElements(mode, start, end, count, type, indices); +} + +void ewol::openGL::UseProgram(int32_t id) +{ + if (0==id) { + // not used ==> because it is unneded + return; + } + if (l_programId != id) { + l_programId = id; + glUseProgram(l_programId); + } +} + + diff --git a/sources/ewol/renderer/openGL.h b/sources/ewol/renderer/openGL.h index 7a9db15d..f7b69019 100644 --- a/sources/ewol/renderer/openGL.h +++ b/sources/ewol/renderer/openGL.h @@ -93,6 +93,50 @@ namespace ewol { * @param[in] newOne The requested matrix. */ void SetCameraMatrix(mat4& newOne); + /** + * @brief + */ + void Finish(void); + /** + * @brief + */ + void Flush(void); + /** + * @brief + */ + void Swap(void); + /** + * @brief Enable a flag on the system + * @param[in] flagID The flag requested + */ + void Enable(uint32_t flagID); + /** + * @brief Disable a flag on the system + * @param[in] flagID The flag requested + */ + void Disable(uint32_t flagID); + /** + * @brief Enable Texture on the system + * @param[in] flagID The flag requested + */ + void ActiveTexture(uint32_t flagID); + /** + * @brief Disable Texture on the system + * @param[in] flagID The flag requested + */ + void DesActiveTexture(uint32_t flagID); + /** + * @brief draw a specific array ==> this enable mode difference ... + */ + void DrawArrays(uint32_t mode, int32_t first, int32_t count); + void DrawArraysInstanced(uint32_t mode, int32_t first, int32_t count, int32_t primcount); + void DrawElements(uint32_t mode, int32_t count, uint32_t type, const void* indices); + void DrawRangeElements(uint32_t mode, int32_t start, int32_t end, int32_t count, uint32_t type, const void* indices); + /** + * @brief Use openGL program + * @param[in] id Id of the program that might be used + */ + void UseProgram(int32_t id); }; }; diff --git a/sources/ewol/renderer/os/Fps.h b/sources/ewol/renderer/os/Fps.h index 06a4e01d..ef9f4fe3 100644 --- a/sources/ewol/renderer/os/Fps.h +++ b/sources/ewol/renderer/os/Fps.h @@ -87,13 +87,16 @@ namespace ewol } /** * @brief this might be call every time a diplay stop, it do the display every second - * @param --- + * @param[in] displayTime Display curent time of the frame. * @return --- */ - void Toc(void) + void Toc(bool displayTime=false) { int64_t currentTime = ewol::GetTime(); int64_t processTimeLocal = (currentTime - ticTime); + if (displayTime==true) { + EWOL_DEBUG(m_displayName << " : processTime : " << (float)((float)processTimeLocal / 1000.0) << "ms "); + } if (drwingDone) { min = etk_min(min, processTimeLocal); max = etk_max(max, processTimeLocal); @@ -104,6 +107,20 @@ namespace ewol max_idle = etk_max(max_idle, processTimeLocal); avg_idle += processTimeLocal; } + } + /** + * @brief this might be call when a display is really done + */ + void IncrementCounter(void) + { + nbDisplayTime++; + drwingDone = true; + } + /** + * @brief Draw debug display ... + */ + void Draw(void) + { if (true == display) { if (nbDisplayTime>0) { EWOL_DEBUG(m_displayName << " : Active : " @@ -132,16 +149,6 @@ namespace ewol display = false; } } - /** - * @brief this might be call when a display is really done - * @param --- - * @return --- - */ - void IncrementCounter(void) - { - nbDisplayTime++; - drwingDone = true; - } }; }; diff --git a/sources/ewol/renderer/os/eSystem.cpp b/sources/ewol/renderer/os/eSystem.cpp index acc978c6..cee5e326 100644 --- a/sources/ewol/renderer/os/eSystem.cpp +++ b/sources/ewol/renderer/os/eSystem.cpp @@ -38,6 +38,7 @@ static ewol::eSystemInput l_managementInput; static ewol::Fps l_FpsSystemEvent( "Event ", false); static ewol::Fps l_FpsSystemContext( "Context ", false); static ewol::Fps l_FpsSystem( "Draw ", true); +static ewol::Fps l_FpsFlush( "Flush ", false); @@ -474,7 +475,7 @@ bool eSystem::Draw(bool displayEveryTime) if (true == isGlobalSystemInit) { // process the events - l_FpsSystemEvent.Tic(); +l_FpsSystemEvent.Tic(); ewolProcessEvents(); // call all the widget that neded to do something periodicly ewol::widgetManager::PeriodicCall(currentTime); @@ -486,31 +487,39 @@ bool eSystem::Draw(bool displayEveryTime) // Redraw all needed elements tmpWindows->OnRegenerateDisplay(); } - l_FpsSystemEvent.IncrementCounter(); - l_FpsSystemEvent.Toc(); +l_FpsSystemEvent.IncrementCounter(); +l_FpsSystemEvent.Toc(); bool needRedraw = ewol::widgetManager::IsDrawingNeeded(); - l_FpsSystemContext.Tic(); +l_FpsSystemContext.Tic(); if (NULL != tmpWindows) { if( true == needRedraw || true == displayEveryTime) { ewol::resource::UpdateContext(); - l_FpsSystemContext.IncrementCounter(); +l_FpsSystemContext.IncrementCounter(); } } - l_FpsSystemContext.Toc(); +l_FpsSystemContext.Toc(); bool hasDisplayDone = false; - l_FpsSystem.Tic(); +l_FpsSystem.Tic(); if (NULL != tmpWindows) { if( true == needRedraw || true == displayEveryTime) { - l_FpsSystem.IncrementCounter(); +l_FpsSystem.IncrementCounter(); tmpWindows->SysDraw(); hasDisplayDone = true; } } - l_FpsSystem.Toc(); +l_FpsSystem.Toc(); +l_FpsFlush.Tic(); +l_FpsFlush.IncrementCounter(); glFlush(); +l_FpsFlush.Toc(); + +l_FpsSystemEvent.Draw(); +l_FpsSystemContext.Draw(); +l_FpsSystem.Draw(); +l_FpsFlush.Draw(); return hasDisplayDone; } return false; diff --git a/sources/ewol/renderer/os/gui.X11.cpp b/sources/ewol/renderer/os/gui.X11.cpp index 876d94b0..5d8df42c 100644 --- a/sources/ewol/renderer/os/gui.X11.cpp +++ b/sources/ewol/renderer/os/gui.X11.cpp @@ -38,7 +38,7 @@ #define GUI_LOCK() XLockDisplay(m_display) #define GUI_UNLOCK() XUnlockDisplay(m_display) */ - +bool hasDisplay = false; //#define DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT #define X11_DEBUG EWOL_DEBUG @@ -1068,11 +1068,12 @@ void X11_Run(void) } } if(true == m_run) { - bool hasDisplay = eSystem::Draw(false); if (m_doubleBuffered && hasDisplay) { glXSwapBuffers(m_display, WindowHandle); XSync(m_display,0); } + // draw after switch the previous windows ... + hasDisplay = eSystem::Draw(false); } } }; diff --git a/sources/ewol/renderer/resources/Colored3DObject.cpp b/sources/ewol/renderer/resources/Colored3DObject.cpp index aa883dfa..b3373fd3 100644 --- a/sources/ewol/renderer/resources/Colored3DObject.cpp +++ b/sources/ewol/renderer/resources/Colored3DObject.cpp @@ -43,7 +43,7 @@ void ewol::Colored3DObject::Draw(etk::Vector& vertices, EWOL_ERROR("No shader ..."); return; } - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); if (false==updateDepthBuffer) { glDepthMask(GL_FALSE); } @@ -59,15 +59,15 @@ void ewol::Colored3DObject::Draw(etk::Vector& vertices, // color : m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, vertices.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, vertices.Size()); m_GLprogram->UnUse(); // Request the draw od the elements : - glDrawArrays(GL_LINES, 0, vertices.Size()); - m_GLprogram->UnUse(); + //glDrawArrays(GL_LINES, 0, vertices.Size()); + //m_GLprogram->UnUse(); if (false==updateDepthBuffer) { glDepthMask(GL_TRUE); } - glDisable(GL_DEPTH_TEST); + ewol::openGL::Disable(GL_DEPTH_TEST); } void ewol::Colored3DObject::Draw(etk::Vector& vertices, @@ -81,7 +81,7 @@ void ewol::Colored3DObject::Draw(etk::Vector& vertices, EWOL_ERROR("No shader ..."); return; } - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); m_GLprogram->Use(); // set Matrix : translation/positionMatrix @@ -94,9 +94,9 @@ void ewol::Colored3DObject::Draw(etk::Vector& vertices, // color : m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, vertices.Size()); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, vertices.Size()); m_GLprogram->UnUse(); - glDisable(GL_DEPTH_TEST); + ewol::openGL::Disable(GL_DEPTH_TEST); } void ewol::Colored3DObject::DrawLine(etk::Vector& vertices, @@ -110,7 +110,7 @@ void ewol::Colored3DObject::DrawLine(etk::Vector& vertices, EWOL_ERROR("No shader ..."); return; } - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); m_GLprogram->Use(); // set Matrix : translation/positionMatrix @@ -123,7 +123,7 @@ void ewol::Colored3DObject::DrawLine(etk::Vector& vertices, // color : m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); // Request the draw od the elements : - glDrawArrays(GL_LINES, 0, vertices.Size()); + ewol::openGL::DrawArrays(GL_LINES, 0, vertices.Size()); m_GLprogram->UnUse(); - glDisable(GL_DEPTH_TEST); + ewol::openGL::Disable(GL_DEPTH_TEST); } diff --git a/sources/ewol/renderer/resources/Mesh.cpp b/sources/ewol/renderer/resources/Mesh.cpp index 26a24857..552105fb 100644 --- a/sources/ewol/renderer/resources/Mesh.cpp +++ b/sources/ewol/renderer/resources/Mesh.cpp @@ -69,7 +69,7 @@ ewol::Mesh::Mesh(etk::UString genName, etk::UString shaderName) : m_GLPosition = 0; // set the element material properties : - m_material.SetAmbientFactor(vec4(0.200000,0.200000,0.200000, 1.0)); + m_material.SetAmbientFactor(vec4(0.100000,0.100000,0.100000, 1.0)); m_material.SetDiffuseFactor(vec4(0.640000, 0.640000, 0.640000, 1.0)); m_material.SetSpecularFactor(vec4(0.500000, 0.500000, 0.500000, 1.0)); m_material.SetShininess(0.96078431); @@ -121,7 +121,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix) EWOL_ERROR("No shader ..."); return; } - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); m_GLprogram->Use(); // set Matrix : translation/positionMatrix @@ -145,10 +145,10 @@ void ewol::Mesh::Draw(mat4& positionMatrix) m_light.Draw(m_GLprogram); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_numberOfElments); + ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_numberOfElments); m_GLprogram->UnUse(); - glDisable(GL_DEPTH_TEST); - glBindBuffer(GL_ARRAY_BUFFER,0); + ewol::openGL::Disable(GL_DEPTH_TEST); + //glBindBuffer(GL_ARRAY_BUFFER,0); } // normal calculation of the normal face is really easy : @@ -702,7 +702,39 @@ void ewol::Mesh::LoadMaterial(const etk::UString& name) void ewol::Mesh::DisplaceElement(const ewol::DisplacementTable& displacement) { - + CalculateNormaleFace(); + CalculateNormaleEdge(); + // displacement is done from the center of the element: + for (int32_t iii=0; iii=0) { + modifx = 0.5f - modifx; + } else { + modifx = 0.5f + modifx; + } + } + if (position.y()!=0.0 || position.z()!=0.0) { + modify = (acos(positionBase2.z())/M_PI)/2.0f; + if (positionBase2.y()>=0) { + modify = 0.5f - modify; + } else { + modify = 0.5f + modify; + } + } + + float move = displacement.GetInterpolate(modifx,modify); + //EWOL_DEBUG("Get interpolate : from=" << position << " ==> (" << modifx << "," << modify << ") ==> " << move); + + vec3 translate = m_listVertexNormal[iii] * (move*4.0); + m_listVertex[iii] += translate; + } } diff --git a/sources/ewol/renderer/resources/Mesh.h b/sources/ewol/renderer/resources/Mesh.h index c44f9643..4f619e22 100644 --- a/sources/ewol/renderer/resources/Mesh.h +++ b/sources/ewol/renderer/resources/Mesh.h @@ -48,12 +48,45 @@ namespace ewol float Get(int32_t x, int32_t y) const { // We increment of the size to prevent the <0 result due to the "%" methode ... - x += m_size.x(); - y += m_size.y(); x %= m_size.x(); y %= m_size.y(); + while (x<0) { + x+= m_size.x(); + } + while (y<0) { + y+= m_size.y(); + } return m_data[x + y*m_size.x()]; } + float GetInterpolate(float x, float y) const + { + + while (x<0) { x+= 1.0; } + while (y<0) { y+= 1.0; } + while (x>=1.0) { x-= 1.0; } + while (y>=1.0) { y-= 1.0; } + x *= m_size.x(); + y *= m_size.y(); + //get fractional part of x and y + float fractX = x - (int32_t)x; + float fractY = y - (int32_t)y; + + //wrap around + int32_t x1 = (int32_t)x; + int32_t y1 = (int32_t)y; + + //neighbor values + int32_t x2 = x1 - 1; + int32_t y2 = y1 - 1; + + //smooth the noise with bilinear interpolation + float value = 0.0; + value += fractX * fractY * Get(x1, y1); + value += fractX * (1 - fractY) * Get(x1, y2); + value += (1 - fractX) * fractY * Get(x2, y1); + value += (1 - fractX) * (1 - fractY) * Get(x2, y2); + return value; + } void Set(int32_t x, int32_t y, float val) { // We increment of the size to prevent the <0 result due to the "%" methode ... @@ -63,6 +96,7 @@ namespace ewol y %= m_size.y(); m_data[x + y*m_size.x()] = val; } + const ivec2& GetSize(void) const { return m_size; }; }; class Face { diff --git a/sources/ewol/renderer/resources/Program.cpp b/sources/ewol/renderer/resources/Program.cpp index af339830..15c94a0f 100644 --- a/sources/ewol/renderer/resources/Program.cpp +++ b/sources/ewol/renderer/resources/Program.cpp @@ -11,6 +11,7 @@ #include #include #include +#include //#define LOCAL_DEBUG EWOL_VERBOSE #define LOCAL_DEBUG EWOL_DEBUG @@ -668,6 +669,9 @@ void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, const int32_t ////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef PROGRAM_DISPLAY_SPEED + int64_t g_startTime = 0; +#endif void ewol::Program::Use(void) @@ -675,7 +679,10 @@ void ewol::Program::Use(void) if (0==m_program) { return; } - glUseProgram(m_program); + #ifdef PROGRAM_DISPLAY_SPEED + g_startTime = ewol::GetTime(); + #endif + ewol::openGL::UseProgram(m_program); //checkGlError("glUseProgram", __LINE__); } @@ -692,10 +699,10 @@ void ewol::Program::SetTexture0(int32_t idElem, GLint textureOpenGlID) return; } #if 0 - glEnable(GL_TEXTURE_2D); + ewol::openGL::Enable(GL_TEXTURE_2D); checkGlError("glEnable", __LINE__); #endif - glActiveTexture(GL_TEXTURE0); + ewol::openGL::ActiveTexture(GL_TEXTURE0); //checkGlError("glActiveTexture", __LINE__); // set the textureID glBindTexture(GL_TEXTURE_2D, textureOpenGlID); @@ -718,10 +725,10 @@ void ewol::Program::SetTexture1(int32_t idElem, GLint textureOpenGlID) return; } #if 0 - glEnable(GL_TEXTURE_2D); + ewol::openGL::Enable(GL_TEXTURE_2D); checkGlError("glEnable", __LINE__); #endif - glActiveTexture(GL_TEXTURE1); + ewol::openGL::ActiveTexture(GL_TEXTURE1); //checkGlError("glActiveTexture", __LINE__); // set the textureID glBindTexture(GL_TEXTURE_2D, textureOpenGlID); @@ -740,13 +747,22 @@ void ewol::Program::UnUse(void) } #if 0 if (true == m_hasTexture) { - glDisable(GL_TEXTURE_2D); - checkGlError("glDisable", __LINE__); + ewol::openGL::Disable(GL_TEXTURE_2D); + //checkGlError("glDisable", __LINE__); m_hasTexture = false; } #endif - glUseProgram(0); - checkGlError("glUseProgram", __LINE__); + // no need to disable program ==> this only generate perturbation on speed ... + ewol::openGL::UseProgram(0); + #ifdef PROGRAM_DISPLAY_SPEED + float localTime = (float)(ewol::GetTime() - g_startTime) / 1000.0f; + if (localTime>1) { + EWOL_ERROR(" prog : " << localTime << "ms resource=\"" << m_name << "\""); + } else { + EWOL_DEBUG(" prog : " << localTime << "ms resource=\"" << m_name << "\""); + } + #endif + //checkGlError("glUseProgram", __LINE__); } diff --git a/sources/ewol/widget/Scene.cpp b/sources/ewol/widget/Scene.cpp index f1f37151..59fdd97d 100644 --- a/sources/ewol/widget/Scene.cpp +++ b/sources/ewol/widget/Scene.cpp @@ -435,7 +435,7 @@ void widget::Scene::DrawOpenGL(btScalar* mmm, dy *= halfExtent[1]; /* glColor3f(1,1,1); - glDisable(GL_LIGHTING); + ewol::openGL::Disable(GL_LIGHTING); glLineWidth(2); glBegin(GL_LINE_LOOP); glDrawVector(org - dx - dy); @@ -906,26 +906,26 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp) glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT1, GL_POSITION, light_position1); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); + ewol::openGL::Enable(GL_LIGHTING); + ewol::openGL::Enable(GL_LIGHT0); + ewol::openGL::Enable(GL_LIGHT1); glShadeModel(GL_SMOOTH); - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); */ //updateCamera(); if(false/*m_enableshadows*/) { /* glClear(GL_STENCIL_BUFFER_BIT); - glEnable(GL_CULL_FACE); + ewol::openGL::Enable(GL_CULL_FACE); renderscene(0); - glDisable(GL_LIGHTING); + ewol::openGL::Disable(GL_LIGHTING); glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); - glEnable(GL_STENCIL_TEST); + ewol::openGL::Enable(GL_STENCIL_TEST); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL); glFrontFace(GL_CCW); @@ -939,34 +939,34 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp) glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_BACK,GL_FILL); glShadeModel(GL_SMOOTH); - glEnable(GL_DEPTH_TEST); + ewol::openGL::Enable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); - glEnable(GL_LIGHTING); + ewol::openGL::Enable(GL_LIGHTING); glDepthMask(GL_TRUE); glCullFace(GL_BACK); glFrontFace(GL_CCW); - glEnable(GL_CULL_FACE); + ewol::openGL::Enable(GL_CULL_FACE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glDepthFunc(GL_LEQUAL); glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); - glDisable(GL_LIGHTING); + ewol::openGL::Disable(GL_LIGHTING); renderscene(2); - glEnable(GL_LIGHTING); + ewol::openGL::Enable(GL_LIGHTING); glDepthFunc(GL_LESS); - glDisable(GL_STENCIL_TEST); - glDisable(GL_CULL_FACE); + ewol::openGL::Disable(GL_STENCIL_TEST); + ewol::openGL::Disable(GL_CULL_FACE); */ } else { - //glDisable(GL_CULL_FACE); + //ewol::openGL::Disable(GL_CULL_FACE); renderscene(0); } /* int32_t xOffset = 10; int32_t yStart = 20; int32_t yIncr = 20; - glDisable(GL_LIGHTING); + ewol::openGL::Disable(GL_LIGHTING); glColor3f(0, 0, 0); if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { @@ -974,7 +974,7 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp) showProfileInfo(xOffset,yStart,yIncr); resetPerspectiveProjection(); } - glDisable(GL_LIGHTING); + ewol::openGL::Disable(GL_LIGHTING); */ //updateCamera(); diff --git a/sources/ewol/widget/Windows.cpp b/sources/ewol/widget/Windows.cpp index feaebe56..2b5bef22 100644 --- a/sources/ewol/widget/Windows.cpp +++ b/sources/ewol/widget/Windows.cpp @@ -96,7 +96,19 @@ void ewol::Windows::SysDraw(void) //EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")"); // set the size of the open GL system glViewport(0,0,m_size.x(),m_size.y()); - glEnable(GL_BLEND); + + ewol::openGL::Disable(GL_DITHER); + //ewol::openGL::Disable(GL_BLEND); + ewol::openGL::Disable(GL_STENCIL_TEST); + #ifndef __TARGET_OS__Android + ewol::openGL::Disable(GL_ALPHA_TEST); + ewol::openGL::Disable(GL_FOG); + glPixelZoom(1.0,1.0); + #endif + ewol::openGL::Disable(GL_TEXTURE_2D); + ewol::openGL::Disable(GL_DEPTH_TEST); + + ewol::openGL::Enable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // clear the matrix system : @@ -110,7 +122,7 @@ void ewol::Windows::SysDraw(void) GenDraw(displayProp); - glDisable(GL_BLEND); + ewol::openGL::Disable(GL_BLEND); return; }