[DEV] start OpenGl abstraction ==> for faster display

This commit is contained in:
Edouard DUPIN 2013-03-12 21:51:02 +01:00
parent 09103e3073
commit 75df3e4b8b
19 changed files with 313 additions and 80 deletions

2
build

@ -1 +1 @@
Subproject commit 50b04244084ced7421ed260866612fcbb547e1c8 Subproject commit 7674fedbe9379979ed6ac2de0f035690b3071fe8

View File

@ -22,6 +22,6 @@ void main(void) {
MatrixPosition[3][0] = 0.0; MatrixPosition[3][0] = 0.0;
MatrixPosition[3][1] = 0.0; MatrixPosition[3][1] = 0.0;
MatrixPosition[3][2] = 0.0; MatrixPosition[3][2] = 0.0;
//v_ecNormal = vec3(MatrixPosition * vec4(EW_normal, 1.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_faceNormal, 1.0) );
} }

2
external/etk vendored

@ -1 +1 @@
Subproject commit f5f7c72ad695876cf63056424f93e863884034dd Subproject commit 03e91578914d2c5c1d6ec60fe28411bf037f6fa9

View File

@ -82,7 +82,7 @@ void ewol::Area::Draw(void)
// color : // color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements : // 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(); m_GLprogram->UnUse();
} }

View File

@ -328,7 +328,7 @@ void ewol::Drawing::Draw(void)
// color : // color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements : // 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(); m_GLprogram->UnUse();
} }

View File

@ -85,7 +85,7 @@ void ewol::Image::Draw(void)
// color : // color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements : // 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(); m_GLprogram->UnUse();
} }

View File

@ -147,7 +147,7 @@ void ewol::Shaper::Draw(void)
m_GLprogram->SetTexture0(m_GLtexID, m_resourceTexture->GetId()); m_GLprogram->SetTexture0(m_GLtexID, m_resourceTexture->GetId());
} }
// Request the draw of the elements : // Request the draw of the elements :
glDrawArrays(GL_TRIANGLES, 0, 6); ewol::openGL::DrawArrays(GL_TRIANGLES, 0, 6);
m_GLprogram->UnUse(); m_GLprogram->UnUse();
} }

View File

@ -129,7 +129,7 @@ void ewol::Text::Draw(void)
// color : // color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements : // 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(); m_GLprogram->UnUse();
} }

View File

@ -12,6 +12,9 @@
etk::Vector<mat4> l_matrixList; etk::Vector<mat4> l_matrixList;
mat4 l_matrixCamera; 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) void ewol::openGL::Init(void)
{ {
@ -20,6 +23,9 @@ void ewol::openGL::Init(void)
mat4 tmpMat; mat4 tmpMat;
l_matrixList.PushBack(tmpMat); l_matrixList.PushBack(tmpMat);
l_matrixCamera.Identity(); 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; 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);
}
}

View File

@ -93,6 +93,50 @@ namespace ewol {
* @param[in] newOne The requested matrix. * @param[in] newOne The requested matrix.
*/ */
void SetCameraMatrix(mat4& newOne); 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);
}; };
}; };

View File

@ -87,13 +87,16 @@ namespace ewol
} }
/** /**
* @brief this might be call every time a diplay stop, it do the display every second * @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 --- * @return ---
*/ */
void Toc(void) void Toc(bool displayTime=false)
{ {
int64_t currentTime = ewol::GetTime(); int64_t currentTime = ewol::GetTime();
int64_t processTimeLocal = (currentTime - ticTime); int64_t processTimeLocal = (currentTime - ticTime);
if (displayTime==true) {
EWOL_DEBUG(m_displayName << " : processTime : " << (float)((float)processTimeLocal / 1000.0) << "ms ");
}
if (drwingDone) { if (drwingDone) {
min = etk_min(min, processTimeLocal); min = etk_min(min, processTimeLocal);
max = etk_max(max, processTimeLocal); max = etk_max(max, processTimeLocal);
@ -104,6 +107,20 @@ namespace ewol
max_idle = etk_max(max_idle, processTimeLocal); max_idle = etk_max(max_idle, processTimeLocal);
avg_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 (true == display) {
if (nbDisplayTime>0) { if (nbDisplayTime>0) {
EWOL_DEBUG(m_displayName << " : Active : " EWOL_DEBUG(m_displayName << " : Active : "
@ -132,16 +149,6 @@ namespace ewol
display = false; display = false;
} }
} }
/**
* @brief this might be call when a display is really done
* @param ---
* @return ---
*/
void IncrementCounter(void)
{
nbDisplayTime++;
drwingDone = true;
}
}; };
}; };

View File

@ -38,6 +38,7 @@ static ewol::eSystemInput l_managementInput;
static ewol::Fps l_FpsSystemEvent( "Event ", false); static ewol::Fps l_FpsSystemEvent( "Event ", false);
static ewol::Fps l_FpsSystemContext( "Context ", false); static ewol::Fps l_FpsSystemContext( "Context ", false);
static ewol::Fps l_FpsSystem( "Draw ", true); 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) { if (true == isGlobalSystemInit) {
// process the events // process the events
l_FpsSystemEvent.Tic(); l_FpsSystemEvent.Tic();
ewolProcessEvents(); ewolProcessEvents();
// call all the widget that neded to do something periodicly // call all the widget that neded to do something periodicly
ewol::widgetManager::PeriodicCall(currentTime); ewol::widgetManager::PeriodicCall(currentTime);
@ -486,31 +487,39 @@ bool eSystem::Draw(bool displayEveryTime)
// Redraw all needed elements // Redraw all needed elements
tmpWindows->OnRegenerateDisplay(); tmpWindows->OnRegenerateDisplay();
} }
l_FpsSystemEvent.IncrementCounter(); l_FpsSystemEvent.IncrementCounter();
l_FpsSystemEvent.Toc(); l_FpsSystemEvent.Toc();
bool needRedraw = ewol::widgetManager::IsDrawingNeeded(); bool needRedraw = ewol::widgetManager::IsDrawingNeeded();
l_FpsSystemContext.Tic(); l_FpsSystemContext.Tic();
if (NULL != tmpWindows) { if (NULL != tmpWindows) {
if( true == needRedraw if( true == needRedraw
|| true == displayEveryTime) { || true == displayEveryTime) {
ewol::resource::UpdateContext(); ewol::resource::UpdateContext();
l_FpsSystemContext.IncrementCounter(); l_FpsSystemContext.IncrementCounter();
} }
} }
l_FpsSystemContext.Toc(); l_FpsSystemContext.Toc();
bool hasDisplayDone = false; bool hasDisplayDone = false;
l_FpsSystem.Tic(); l_FpsSystem.Tic();
if (NULL != tmpWindows) { if (NULL != tmpWindows) {
if( true == needRedraw if( true == needRedraw
|| true == displayEveryTime) { || true == displayEveryTime) {
l_FpsSystem.IncrementCounter(); l_FpsSystem.IncrementCounter();
tmpWindows->SysDraw(); tmpWindows->SysDraw();
hasDisplayDone = true; hasDisplayDone = true;
} }
} }
l_FpsSystem.Toc(); l_FpsSystem.Toc();
l_FpsFlush.Tic();
l_FpsFlush.IncrementCounter();
glFlush(); glFlush();
l_FpsFlush.Toc();
l_FpsSystemEvent.Draw();
l_FpsSystemContext.Draw();
l_FpsSystem.Draw();
l_FpsFlush.Draw();
return hasDisplayDone; return hasDisplayDone;
} }
return false; return false;

View File

@ -38,7 +38,7 @@
#define GUI_LOCK() XLockDisplay(m_display) #define GUI_LOCK() XLockDisplay(m_display)
#define GUI_UNLOCK() XUnlockDisplay(m_display) #define GUI_UNLOCK() XUnlockDisplay(m_display)
*/ */
bool hasDisplay = false;
//#define DEBUG_X11_EVENT //#define DEBUG_X11_EVENT
#ifdef DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT
#define X11_DEBUG EWOL_DEBUG #define X11_DEBUG EWOL_DEBUG
@ -1068,11 +1068,12 @@ void X11_Run(void)
} }
} }
if(true == m_run) { if(true == m_run) {
bool hasDisplay = eSystem::Draw(false);
if (m_doubleBuffered && hasDisplay) { if (m_doubleBuffered && hasDisplay) {
glXSwapBuffers(m_display, WindowHandle); glXSwapBuffers(m_display, WindowHandle);
XSync(m_display,0); XSync(m_display,0);
} }
// draw after switch the previous windows ...
hasDisplay = eSystem::Draw(false);
} }
} }
}; };

View File

@ -43,7 +43,7 @@ void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
} }
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
if (false==updateDepthBuffer) { if (false==updateDepthBuffer) {
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
} }
@ -59,15 +59,15 @@ void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
// color : // color :
m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color);
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, vertices.Size()); ewol::openGL::DrawArrays(GL_TRIANGLES, 0, vertices.Size());
m_GLprogram->UnUse(); m_GLprogram->UnUse();
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_LINES, 0, vertices.Size()); //glDrawArrays(GL_LINES, 0, vertices.Size());
m_GLprogram->UnUse(); //m_GLprogram->UnUse();
if (false==updateDepthBuffer) { if (false==updateDepthBuffer) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
} }
glDisable(GL_DEPTH_TEST); ewol::openGL::Disable(GL_DEPTH_TEST);
} }
void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices, void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
@ -81,7 +81,7 @@ void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
} }
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
m_GLprogram->Use(); m_GLprogram->Use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
@ -94,9 +94,9 @@ void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
// color : // color :
m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color);
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, vertices.Size()); ewol::openGL::DrawArrays(GL_TRIANGLES, 0, vertices.Size());
m_GLprogram->UnUse(); m_GLprogram->UnUse();
glDisable(GL_DEPTH_TEST); ewol::openGL::Disable(GL_DEPTH_TEST);
} }
void ewol::Colored3DObject::DrawLine(etk::Vector<vec3>& vertices, void ewol::Colored3DObject::DrawLine(etk::Vector<vec3>& vertices,
@ -110,7 +110,7 @@ void ewol::Colored3DObject::DrawLine(etk::Vector<vec3>& vertices,
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
} }
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
m_GLprogram->Use(); m_GLprogram->Use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
@ -123,7 +123,7 @@ void ewol::Colored3DObject::DrawLine(etk::Vector<vec3>& vertices,
// color : // color :
m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color); m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color);
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_LINES, 0, vertices.Size()); ewol::openGL::DrawArrays(GL_LINES, 0, vertices.Size());
m_GLprogram->UnUse(); m_GLprogram->UnUse();
glDisable(GL_DEPTH_TEST); ewol::openGL::Disable(GL_DEPTH_TEST);
} }

View File

@ -69,7 +69,7 @@ ewol::Mesh::Mesh(etk::UString genName, etk::UString shaderName) :
m_GLPosition = 0; m_GLPosition = 0;
// set the element material properties : // 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.SetDiffuseFactor(vec4(0.640000, 0.640000, 0.640000, 1.0));
m_material.SetSpecularFactor(vec4(0.500000, 0.500000, 0.500000, 1.0)); m_material.SetSpecularFactor(vec4(0.500000, 0.500000, 0.500000, 1.0));
m_material.SetShininess(0.96078431); m_material.SetShininess(0.96078431);
@ -121,7 +121,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
} }
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
m_GLprogram->Use(); m_GLprogram->Use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
@ -145,10 +145,10 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
m_light.Draw(m_GLprogram); m_light.Draw(m_GLprogram);
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, m_numberOfElments); ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_numberOfElments);
m_GLprogram->UnUse(); m_GLprogram->UnUse();
glDisable(GL_DEPTH_TEST); ewol::openGL::Disable(GL_DEPTH_TEST);
glBindBuffer(GL_ARRAY_BUFFER,0); //glBindBuffer(GL_ARRAY_BUFFER,0);
} }
// normal calculation of the normal face is really easy : // 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) 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<m_listVertex.Size(); iii++) {
vec3 position = m_listVertex[iii].normalized();
vec3 positionBase = vec3(position.x(), position.y(), 0).normalized();
vec3 positionBase2 = vec3(0, position.y(), position.z()).normalized();
float modifx = 0.5f;
float modify = 0.5f;
if (position.x()!=0.0 || position.y()!=0.0) {
modifx = (acos(positionBase.x())/M_PI)/2.0f;
if (positionBase.y()>=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;
}
} }

View File

@ -48,12 +48,45 @@ namespace ewol
float Get(int32_t x, int32_t y) const float Get(int32_t x, int32_t y) const
{ {
// We increment of the size to prevent the <0 result due to the "%" methode ... // 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(); x %= m_size.x();
y %= m_size.y(); 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()]; 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) void Set(int32_t x, int32_t y, float val)
{ {
// We increment of the size to prevent the <0 result due to the "%" methode ... // We increment of the size to prevent the <0 result due to the "%" methode ...
@ -63,6 +96,7 @@ namespace ewol
y %= m_size.y(); y %= m_size.y();
m_data[x + y*m_size.x()] = val; m_data[x + y*m_size.x()] = val;
} }
const ivec2& GetSize(void) const { return m_size; };
}; };
class Face class Face
{ {

View File

@ -11,6 +11,7 @@
#include <ewol/renderer/resources/Program.h> #include <ewol/renderer/resources/Program.h>
#include <ewol/renderer/ResourceManager.h> #include <ewol/renderer/ResourceManager.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#include <ewol/ewol.h>
//#define LOCAL_DEBUG EWOL_VERBOSE //#define LOCAL_DEBUG EWOL_VERBOSE
#define LOCAL_DEBUG EWOL_DEBUG #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) void ewol::Program::Use(void)
@ -675,7 +679,10 @@ void ewol::Program::Use(void)
if (0==m_program) { if (0==m_program) {
return; return;
} }
glUseProgram(m_program); #ifdef PROGRAM_DISPLAY_SPEED
g_startTime = ewol::GetTime();
#endif
ewol::openGL::UseProgram(m_program);
//checkGlError("glUseProgram", __LINE__); //checkGlError("glUseProgram", __LINE__);
} }
@ -692,10 +699,10 @@ void ewol::Program::SetTexture0(int32_t idElem, GLint textureOpenGlID)
return; return;
} }
#if 0 #if 0
glEnable(GL_TEXTURE_2D); ewol::openGL::Enable(GL_TEXTURE_2D);
checkGlError("glEnable", __LINE__); checkGlError("glEnable", __LINE__);
#endif #endif
glActiveTexture(GL_TEXTURE0); ewol::openGL::ActiveTexture(GL_TEXTURE0);
//checkGlError("glActiveTexture", __LINE__); //checkGlError("glActiveTexture", __LINE__);
// set the textureID // set the textureID
glBindTexture(GL_TEXTURE_2D, textureOpenGlID); glBindTexture(GL_TEXTURE_2D, textureOpenGlID);
@ -718,10 +725,10 @@ void ewol::Program::SetTexture1(int32_t idElem, GLint textureOpenGlID)
return; return;
} }
#if 0 #if 0
glEnable(GL_TEXTURE_2D); ewol::openGL::Enable(GL_TEXTURE_2D);
checkGlError("glEnable", __LINE__); checkGlError("glEnable", __LINE__);
#endif #endif
glActiveTexture(GL_TEXTURE1); ewol::openGL::ActiveTexture(GL_TEXTURE1);
//checkGlError("glActiveTexture", __LINE__); //checkGlError("glActiveTexture", __LINE__);
// set the textureID // set the textureID
glBindTexture(GL_TEXTURE_2D, textureOpenGlID); glBindTexture(GL_TEXTURE_2D, textureOpenGlID);
@ -740,13 +747,22 @@ void ewol::Program::UnUse(void)
} }
#if 0 #if 0
if (true == m_hasTexture) { if (true == m_hasTexture) {
glDisable(GL_TEXTURE_2D); ewol::openGL::Disable(GL_TEXTURE_2D);
checkGlError("glDisable", __LINE__); //checkGlError("glDisable", __LINE__);
m_hasTexture = false; m_hasTexture = false;
} }
#endif #endif
glUseProgram(0); // no need to disable program ==> this only generate perturbation on speed ...
checkGlError("glUseProgram", __LINE__); 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__);
} }

View File

@ -435,7 +435,7 @@ void widget::Scene::DrawOpenGL(btScalar* mmm,
dy *= halfExtent[1]; dy *= halfExtent[1];
/* /*
glColor3f(1,1,1); glColor3f(1,1,1);
glDisable(GL_LIGHTING); ewol::openGL::Disable(GL_LIGHTING);
glLineWidth(2); glLineWidth(2);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glDrawVector(org - dx - dy); 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_SPECULAR, light_specular);
glLightfv(GL_LIGHT1, GL_POSITION, light_position1); glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
glEnable(GL_LIGHTING); ewol::openGL::Enable(GL_LIGHTING);
glEnable(GL_LIGHT0); ewol::openGL::Enable(GL_LIGHT0);
glEnable(GL_LIGHT1); ewol::openGL::Enable(GL_LIGHT1);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
*/ */
//updateCamera(); //updateCamera();
if(false/*m_enableshadows*/) { if(false/*m_enableshadows*/) {
/* /*
glClear(GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_CULL_FACE); ewol::openGL::Enable(GL_CULL_FACE);
renderscene(0); renderscene(0);
glDisable(GL_LIGHTING); ewol::openGL::Disable(GL_LIGHTING);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glEnable(GL_STENCIL_TEST); ewol::openGL::Enable(GL_STENCIL_TEST);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL); glStencilFunc(GL_ALWAYS,1,0xFFFFFFFFL);
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
@ -939,34 +939,34 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp)
glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_FRONT,GL_FILL);
glPolygonMode(GL_BACK,GL_FILL); glPolygonMode(GL_BACK,GL_FILL);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST); ewol::openGL::Enable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
glEnable(GL_LIGHTING); ewol::openGL::Enable(GL_LIGHTING);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE); ewol::openGL::Enable(GL_CULL_FACE);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL ); glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFFL );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
glDisable(GL_LIGHTING); ewol::openGL::Disable(GL_LIGHTING);
renderscene(2); renderscene(2);
glEnable(GL_LIGHTING); ewol::openGL::Enable(GL_LIGHTING);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
glDisable(GL_STENCIL_TEST); ewol::openGL::Disable(GL_STENCIL_TEST);
glDisable(GL_CULL_FACE); ewol::openGL::Disable(GL_CULL_FACE);
*/ */
} else { } else {
//glDisable(GL_CULL_FACE); //ewol::openGL::Disable(GL_CULL_FACE);
renderscene(0); renderscene(0);
} }
/* /*
int32_t xOffset = 10; int32_t xOffset = 10;
int32_t yStart = 20; int32_t yStart = 20;
int32_t yIncr = 20; int32_t yIncr = 20;
glDisable(GL_LIGHTING); ewol::openGL::Disable(GL_LIGHTING);
glColor3f(0, 0, 0); glColor3f(0, 0, 0);
if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) { if ((m_debugMode & btIDebugDraw::DBG_NoHelpText)==0) {
@ -974,7 +974,7 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp)
showProfileInfo(xOffset,yStart,yIncr); showProfileInfo(xOffset,yStart,yIncr);
resetPerspectiveProjection(); resetPerspectiveProjection();
} }
glDisable(GL_LIGHTING); ewol::openGL::Disable(GL_LIGHTING);
*/ */
//updateCamera(); //updateCamera();

View File

@ -96,7 +96,19 @@ void ewol::Windows::SysDraw(void)
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")"); //EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
// set the size of the open GL system // set the size of the open GL system
glViewport(0,0,m_size.x(),m_size.y()); 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); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// clear the matrix system : // clear the matrix system :
@ -110,7 +122,7 @@ void ewol::Windows::SysDraw(void)
GenDraw(displayProp); GenDraw(displayProp);
glDisable(GL_BLEND); ewol::openGL::Disable(GL_BLEND);
return; return;
} }