[DEV] normalize openGL interface for matrix
This commit is contained in:
parent
4e88d081d8
commit
86fa583a55
2
external/ege
vendored
2
external/ege
vendored
@ -1 +1 @@
|
||||
Subproject commit 59a2162deb1cf0e1cad78f11f2bc1ffe36619baf
|
||||
Subproject commit 714662d7a923c7c451b1a02a636c8c0e3fefce5c
|
@ -61,7 +61,7 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) {
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// TextureID
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_resource->getId());
|
||||
// position :
|
||||
|
@ -227,6 +227,7 @@ ewol::compositing::Drawing::Drawing() :
|
||||
m_GLprogram(nullptr),
|
||||
m_GLPosition(-1),
|
||||
m_GLMatrix(-1),
|
||||
m_GLMatrixPosition(-1),
|
||||
m_GLColor(-1),
|
||||
m_thickness(0.0),
|
||||
m_triElement(0) {
|
||||
@ -288,8 +289,9 @@ void ewol::compositing::Drawing::loadProgram() {
|
||||
// get the shader resource :
|
||||
if (nullptr != m_GLprogram ) {
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
|
||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
|
||||
m_GLMatrixPosition = m_GLprogram->getUniform("EW_MatrixPosition");
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +308,9 @@ void ewol::compositing::Drawing::draw(bool _disableDepthTest) {
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
mat4 tmpMatrix2;
|
||||
m_GLprogram->uniformMatrix(m_GLMatrixPosition, tmpMatrix2);
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, m_coord);
|
||||
// color :
|
||||
|
@ -30,8 +30,9 @@ namespace ewol {
|
||||
private:
|
||||
std::shared_ptr<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
|
||||
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
|
||||
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
|
||||
int32_t m_GLColor; //!< openGL id on the element (color buffer)
|
||||
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
|
||||
int32_t m_GLMatrixPosition; //!< position matrix
|
||||
int32_t m_GLColor; //!< openGL id on the element (color buffer)
|
||||
private: // Background Color (display only when needed)
|
||||
std::vector<vec3 > m_coord; //!< internal position for the text display
|
||||
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background
|
||||
|
@ -78,7 +78,7 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// TextureID
|
||||
if (m_resource != nullptr) {
|
||||
if (m_distanceFieldMode == true) {
|
||||
|
@ -184,7 +184,7 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
|
||||
m_GLprogram->use();
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 2/*x,y*/, m_coord);
|
||||
// property
|
||||
|
@ -51,7 +51,7 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// Texture :
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_font->getId());
|
||||
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x());
|
||||
@ -90,7 +90,7 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) {
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// Texture :
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_font->getId());
|
||||
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x());
|
||||
|
@ -62,7 +62,7 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// Texture :
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
|
||||
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
|
||||
@ -100,7 +100,7 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// Texture :
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
|
||||
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
|
||||
|
@ -59,7 +59,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix;
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z,unused*/, &_vertices[0], 4*sizeof(float));
|
||||
// color :
|
||||
@ -102,7 +102,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float));
|
||||
// color :
|
||||
@ -142,7 +142,7 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float));
|
||||
// color :
|
||||
|
@ -358,7 +358,7 @@ void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::resource::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _matrix, bool _transpose) {
|
||||
void ewol::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) {
|
||||
if (0 == m_program) {
|
||||
return;
|
||||
}
|
||||
@ -371,9 +371,12 @@ void ewol::resource::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbEleme
|
||||
}
|
||||
// note : Android des not supported the transposition of the matrix, then we will done it oursef:
|
||||
if (true == _transpose) {
|
||||
_matrix.transpose();
|
||||
mat4 tmp = _matrix;
|
||||
tmp.transpose();
|
||||
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);
|
||||
}
|
||||
glUniformMatrix4fv(m_elementList[_idElem].m_elementId, _nbElement, GL_FALSE, _matrix.m_mat);
|
||||
//checkGlError("glUniformMatrix4fv", __LINE__);
|
||||
}
|
||||
|
||||
|
@ -113,11 +113,10 @@ namespace ewol {
|
||||
/**
|
||||
* @brief Send a uniform element to the spefified ID (not send if does not really exist in the openGL program)
|
||||
* @param[in] _idElem Id of the uniform that might be sended.
|
||||
* @param[in] _nbElement Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array.
|
||||
* @param[in] _pointer Pointer on the data that might be sended
|
||||
* @param[in] _matrix Matrix that might be sended.
|
||||
* @param[in] _transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself)
|
||||
*/
|
||||
void uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _matrix, bool _transpose=true);
|
||||
void uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose=true);
|
||||
|
||||
inline void uniform(int32_t _idElem, const etk::Color<float>& _value) {
|
||||
uniform4f(_idElem, _value.r(), _value.g(), _value.b(), _value.a());
|
||||
|
Loading…
x
Reference in New Issue
Block a user