[DOC] add the comment on the OpenGL access
This commit is contained in:
parent
d1615e3a77
commit
1a4e18c7c5
@ -53,6 +53,9 @@ ewol::Program::Program(etk::UString& filename) :
|
||||
if (len == 0) {
|
||||
continue;
|
||||
}
|
||||
if (tmpData[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
// get it with relative position :
|
||||
etk::UString tmpFilename = file.GetRelativeFolder() + tmpData;
|
||||
ewol::Shader* tmpShader = NULL;
|
||||
@ -95,16 +98,16 @@ static void checkGlError(const char* op, int32_t localLine)
|
||||
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
|
||||
|
||||
|
||||
int32_t ewol::Program::GetAttribute(etk::UString tmpElement)
|
||||
int32_t ewol::Program::GetAttribute(etk::UString elementName)
|
||||
{
|
||||
// check if it exist previously :
|
||||
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
|
||||
if (m_elementList[iii].m_name == tmpElement) {
|
||||
if (m_elementList[iii].m_name == elementName) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
progAttributeElement tmp;
|
||||
tmp.m_name = tmpElement;
|
||||
tmp.m_name = elementName;
|
||||
tmp.m_isAttribute = true;
|
||||
tmp.m_elementId = glGetAttribLocation(m_program, tmp.m_name.c_str());
|
||||
tmp.m_isLinked = true;
|
||||
@ -119,16 +122,16 @@ int32_t ewol::Program::GetAttribute(etk::UString tmpElement)
|
||||
|
||||
|
||||
|
||||
int32_t ewol::Program::GetUniform(etk::UString tmpElement)
|
||||
int32_t ewol::Program::GetUniform(etk::UString elementName)
|
||||
{
|
||||
// check if it exist previously :
|
||||
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
|
||||
if (m_elementList[iii].m_name == tmpElement) {
|
||||
if (m_elementList[iii].m_name == elementName) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
progAttributeElement tmp;
|
||||
tmp.m_name = tmpElement;
|
||||
tmp.m_name = elementName;
|
||||
tmp.m_isAttribute = false;
|
||||
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
|
||||
tmp.m_isLinked = true;
|
||||
@ -258,20 +261,7 @@ void ewol::Program::Reload(void)
|
||||
UpdateContext();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample)
|
||||
{
|
||||
@ -293,6 +283,7 @@ void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* point
|
||||
checkGlError("glEnableVertexAttribArray", __LINE__);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::UniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Matrix4 _matrix, bool transpose)
|
||||
{
|
||||
@ -311,7 +302,7 @@ void ewol::Program::UniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Mat
|
||||
checkGlError("glUniformMatrix4fv", __LINE__);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1f(int32_t idElem, float value1)
|
||||
{
|
||||
@ -362,8 +353,7 @@ void ewol::Program::Uniform4f(int32_t idElem, float value1, float value2, float
|
||||
checkGlError("glUniform4f", __LINE__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1i(int32_t idElem, int32_t value1)
|
||||
{
|
||||
@ -414,8 +404,58 @@ void ewol::Program::Uniform4i(int32_t idElem, int32_t value1, int32_t value2, in
|
||||
checkGlError("glUniform4i", __LINE__);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1ui(int32_t idElem, uint32_t value1)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform1ui(m_elementList[idElem].m_elementId, value1);
|
||||
checkGlError("glUniform1ui", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform2ui(int32_t idElem, uint32_t value1, uint32_t value2)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform2ui(m_elementList[idElem].m_elementId, value1, value2);
|
||||
checkGlError("glUniform2ui", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform3ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform3ui(m_elementList[idElem].m_elementId, value1, value2, value3);
|
||||
checkGlError("glUniform3ui", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform4ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3, uint32_t value4)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
glUniform4ui(m_elementList[idElem].m_elementId, value1, value2, value3, value4);
|
||||
checkGlError("glUniform4ui", __LINE__);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
{
|
||||
@ -498,7 +538,7 @@ void ewol::Program::Uniform4fv(int32_t idElem, int32_t nbElement, float *value)
|
||||
checkGlError("glUniform4fv", __LINE__);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value)
|
||||
{
|
||||
@ -518,7 +558,7 @@ void ewol::Program::Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
return;
|
||||
}
|
||||
glUniform1iv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform1fi", __LINE__);
|
||||
checkGlError("glUniform1iv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value)
|
||||
{
|
||||
@ -538,7 +578,7 @@ void ewol::Program::Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
return;
|
||||
}
|
||||
glUniform2iv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform2fi", __LINE__);
|
||||
checkGlError("glUniform2iv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value)
|
||||
{
|
||||
@ -558,7 +598,7 @@ void ewol::Program::Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
return;
|
||||
}
|
||||
glUniform3iv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform3fi", __LINE__);
|
||||
checkGlError("glUniform3iv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value)
|
||||
{
|
||||
@ -578,9 +618,93 @@ void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value
|
||||
return;
|
||||
}
|
||||
glUniform4iv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform4fi", __LINE__);
|
||||
checkGlError("glUniform4iv", __LINE__);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ewol::Program::Uniform1uiv(int32_t idElem, int32_t nbElement, uint32_t *value)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
if (NULL==value) {
|
||||
EWOL_ERROR("NULL Input pointer to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
glUniform1uiv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform1uiv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform2uiv(int32_t idElem, int32_t nbElement, uint32_t *value)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
if (NULL==value) {
|
||||
EWOL_ERROR("NULL Input pointer to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
glUniform2uiv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform2uiv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform3uiv(int32_t idElem, int32_t nbElement, uint32_t *value)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
if (NULL==value) {
|
||||
EWOL_ERROR("NULL Input pointer to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
glUniform3uiv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform3uiv", __LINE__);
|
||||
}
|
||||
void ewol::Program::Uniform4uiv(int32_t idElem, int32_t nbElement, uint32_t *value)
|
||||
{
|
||||
if (idElem<0 || idElem>m_elementList.Size()) {
|
||||
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
|
||||
return;
|
||||
}
|
||||
if (false == m_elementList[idElem].m_isLinked) {
|
||||
return;
|
||||
}
|
||||
if (0==nbElement) {
|
||||
EWOL_ERROR("No element to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
if (NULL==value) {
|
||||
EWOL_ERROR("NULL Input pointer to send at open GL ...");
|
||||
return;
|
||||
}
|
||||
glUniform4uiv(m_elementList[idElem].m_elementId, nbElement, value);
|
||||
checkGlError("glUniform4uiv", __LINE__);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void ewol::Program::Use(void)
|
||||
|
@ -16,59 +16,295 @@
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
/**
|
||||
* @brief In a openGL program we need some data to communicate with them, we register all the name requested by the user in this structure:
|
||||
* @note Register all requested element permit to abstract the fact that some element does not exist and remove control of existance from upper code.
|
||||
* This is important to note when the Program is reloaded the elements availlable can change.
|
||||
*/
|
||||
class progAttributeElement
|
||||
{
|
||||
public :
|
||||
etk::UString m_name;
|
||||
GLint m_elementId;
|
||||
bool m_isAttribute;
|
||||
bool m_isLinked;
|
||||
etk::UString m_name; //!< Name of the element
|
||||
GLint m_elementId; //!< OpenGl Id if this element ==> can not exist ==> @ref m_isLinked
|
||||
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
|
||||
};
|
||||
|
||||
/**
|
||||
* @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"
|
||||
* The data is simple :
|
||||
* <pre>
|
||||
* # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ...
|
||||
* # The folder is automaticly get from the program file basic folder
|
||||
* filename1.vert
|
||||
* filename2.frag
|
||||
* filename3.vert
|
||||
* filename4.frag
|
||||
* </pre>
|
||||
*/
|
||||
class Program : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
bool m_exist;
|
||||
GLuint m_program;
|
||||
etk::Vector<ewol::Shader*> m_shaderList;
|
||||
etk::Vector<ewol::progAttributeElement> m_elementList;
|
||||
bool m_hasTexture;
|
||||
bool m_exist; //!< the file existed
|
||||
GLuint m_program; //!< openGL id of the current program
|
||||
etk::Vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded
|
||||
etk::Vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
|
||||
bool m_hasTexture; //!< A texture has been set to the current shader
|
||||
public:
|
||||
/**
|
||||
* @brief Contructor of an opengl Program.
|
||||
* @param[in] filename Standard file name format. see @ref etk::FSNode
|
||||
*/
|
||||
Program(etk::UString& filename);
|
||||
/**
|
||||
* @brief Destructor, remove the current Program.
|
||||
*/
|
||||
virtual ~Program(void);
|
||||
/**
|
||||
* @brief Generic function that get the resouces name of his type.
|
||||
* @return The define char of his name.
|
||||
*/
|
||||
const char* GetType(void) { return "ewol::Program"; };
|
||||
int32_t GetAttribute(etk::UString tmpElement);
|
||||
/**
|
||||
* @brief User request an attribute on this program.
|
||||
* @note The attribute is send to the fragment shaders
|
||||
* @param[in] elementName Name of the requested attribute.
|
||||
* @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded)
|
||||
*/
|
||||
int32_t GetAttribute(etk::UString elementName);
|
||||
/**
|
||||
* @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the OpenGL program).
|
||||
* @param[in] idElem Id of the Attribute that might be sended.
|
||||
* @param[in] nbElement Specifies the number of elements that are to be modified.
|
||||
* @param[in] pointer Pointer on the data that might be sended.
|
||||
* @param[in] jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations)
|
||||
*/
|
||||
void SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample=0);
|
||||
int32_t GetUniform(etk::UString tmpElement);
|
||||
|
||||
/**
|
||||
* @brief User request an Uniform on this program.
|
||||
* @note uniform value is availlable for all the fragment shader in the program (only one value for all)
|
||||
* @param[in] elementName Name of the requested uniform.
|
||||
* @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded)
|
||||
*/
|
||||
int32_t GetUniform(etk::UString elementName);
|
||||
/**
|
||||
* @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] 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, etk::Matrix4 pointer, bool transpose=true);
|
||||
|
||||
/**
|
||||
* @brief Send 1 float 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] value1 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform1f(int32_t idElem, float value1);
|
||||
/**
|
||||
* @brief Send 2 float 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform2f(int32_t idElem, float value1, float value2);
|
||||
/**
|
||||
* @brief Send 3 float 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform3f(int32_t idElem, float value1, float value2, float value3);
|
||||
/**
|
||||
* @brief Send 4 float 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
* @param[in] value4 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform4f(int32_t idElem, float value1, float value2, float value3, float value4);
|
||||
|
||||
/**
|
||||
* @brief Send 1 signed integer 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] value1 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform1i(int32_t idElem, int32_t value1);
|
||||
/**
|
||||
* @brief Send 2 signed integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform2i(int32_t idElem, int32_t value1, int32_t value2);
|
||||
/**
|
||||
* @brief Send 3 signed integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform3i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3);
|
||||
/**
|
||||
* @brief Send 4 signed integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
* @param[in] value4 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4);
|
||||
|
||||
/**
|
||||
* @brief Send 1 unsigned integer 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] value1 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform1ui(int32_t idElem, uint32_t value1);
|
||||
/**
|
||||
* @brief Send 2 unsigned integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform2ui(int32_t idElem, uint32_t value1, uint32_t value2);
|
||||
/**
|
||||
* @brief Send 3 unsigned integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform3ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3);
|
||||
/**
|
||||
* @brief Send 4 unsigned integer 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] value1 Value to send at the Uniform
|
||||
* @param[in] value2 Value to send at the Uniform
|
||||
* @param[in] value3 Value to send at the Uniform
|
||||
* @param[in] value4 Value to send at the Uniform
|
||||
*/
|
||||
void Uniform4ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3, uint32_t value4);
|
||||
|
||||
/**
|
||||
* @brief Send "vec1" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform1fv(int32_t idElem, int32_t nbElement, float *value);
|
||||
/**
|
||||
* @brief Send "vec2" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform2fv(int32_t idElem, int32_t nbElement, float *value);
|
||||
/**
|
||||
* @brief Send "vec3" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform3fv(int32_t idElem, int32_t nbElement, float *value);
|
||||
/**
|
||||
* @brief Send "vec4" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform4fv(int32_t idElem, int32_t nbElement, float *value);
|
||||
|
||||
/**
|
||||
* @brief Send "ivec1" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value);
|
||||
/**
|
||||
* @brief Send "ivec2" uniform element to the spefified ID (not send if does not really exist in the OpenGL program)
|
||||
* @param[in] idElem Id of the Attribute that might be sended.
|
||||
* @param[in] nbElement Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value);
|
||||
/**
|
||||
* @brief Send "ivec3" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value);
|
||||
/**
|
||||
* @brief Send "ivec4" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value);
|
||||
|
||||
/**
|
||||
* @brief Send "uvec1" uniform element to the spefified ID (not send if does not really exist in the OpenGL program)
|
||||
* @param[in] idElem Id of the Attribute that might be sended.
|
||||
* @param[in] nbElement Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform1uiv(int32_t idElem, int32_t nbElement, uint32_t *value);
|
||||
/**
|
||||
* @brief Send "uvec2" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform2uiv(int32_t idElem, int32_t nbElement, uint32_t *value);
|
||||
/**
|
||||
* @brief Send "uvec3" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform3uiv(int32_t idElem, int32_t nbElement, uint32_t *value);
|
||||
/**
|
||||
* @brief Send "uvec4" 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 Number of element sended
|
||||
* @param[in] value Pointer on the data
|
||||
*/
|
||||
void Uniform4uiv(int32_t idElem, int32_t nbElement, uint32_t *value);
|
||||
|
||||
/**
|
||||
* @brief Request the processing of this program
|
||||
*/
|
||||
void Use(void);
|
||||
/**
|
||||
* @brief Set the testure Id on the specify uniform element.
|
||||
* @param[in] idElem Id of the uniform that might be sended.
|
||||
* @param[in] textureOpenGlID Real openGL texture ID
|
||||
*/
|
||||
void SetTexture0(int32_t idElem, GLint textureOpenGlID);
|
||||
/**
|
||||
* @brief Stop the processing of this program
|
||||
*/
|
||||
void UnUse(void);
|
||||
/**
|
||||
* @brief This load/reload the data in the opengl context, needed when removed previously.
|
||||
*/
|
||||
void UpdateContext(void);
|
||||
/**
|
||||
* @brief Remove the data from the opengl context.
|
||||
*/
|
||||
void RemoveContext(void);
|
||||
/**
|
||||
* @brief Special android spec! It inform us that all context is removed and after notify us...
|
||||
*/
|
||||
void RemoveContextToLate(void);
|
||||
/**
|
||||
* @brief Relode the shader from the file. used when a request of resouces reload is done.
|
||||
* @note this is really usefull when we tested the new themes or shader developpements.
|
||||
*/
|
||||
void Reload(void);
|
||||
};
|
||||
};
|
||||
|
@ -15,22 +15,57 @@
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
/**
|
||||
* @brief Shader is a specific resources for opengl, used only in @ref Program. This are components of the renderer pipe-line
|
||||
*/
|
||||
class Shader : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
bool m_exist;
|
||||
char* m_fileData;
|
||||
GLuint m_shader;
|
||||
GLenum m_type;
|
||||
bool m_exist; //!< The shader file existed and has been loaded
|
||||
char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
|
||||
GLuint m_shader; //!< Opengl id of this element
|
||||
GLenum m_type; //!< Type of the current shader(vertex/fragment)
|
||||
public:
|
||||
/**
|
||||
* @brief Contructor of an opengl Shader
|
||||
* @param[in] filename Standard file name format. see @ref etk::FSNode
|
||||
*/
|
||||
Shader(etk::UString& filename);
|
||||
/**
|
||||
* @brief Destructor, remove the current Shader
|
||||
*/
|
||||
virtual ~Shader(void);
|
||||
/**
|
||||
* @brief Generic function that get the resouces name of his type.
|
||||
* @return The define char of his name.
|
||||
*/
|
||||
const char* GetType(void) { return "ewol::Shader"; };
|
||||
/**
|
||||
* @brief Get the opengl reference id of this shader.
|
||||
* @return The opengl id.
|
||||
*/
|
||||
GLuint GetGL_ID(void) { return m_shader; };
|
||||
/**
|
||||
* @brief Get the opengl type of this shader.
|
||||
* @return The type of this loaded shader.
|
||||
*/
|
||||
GLenum GetShaderType(void) { return m_type; };
|
||||
/**
|
||||
* @brief This load/reload the data in the opengl context, needed when removed previously.
|
||||
*/
|
||||
void UpdateContext(void);
|
||||
/**
|
||||
* @brief Remove the data from the opengl context.
|
||||
*/
|
||||
void RemoveContext(void);
|
||||
/**
|
||||
* @brief Special android spec! It inform us that all context is removed and after notify us...
|
||||
*/
|
||||
void RemoveContextToLate(void);
|
||||
/**
|
||||
* @brief Relode the shader from the file. used when a request of resouces reload is done.
|
||||
* @note this is really usefull when we tested the new themes or shader developpements.
|
||||
*/
|
||||
void Reload(void);
|
||||
};
|
||||
};
|
||||
|
@ -8,33 +8,74 @@
|
||||
|
||||
#ifndef __OPEN_GL__VIRTUAL_BUFFER_OBJECT_H__
|
||||
#define __OPEN_GL__VIRTUAL_BUFFER_OBJECT_H__
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
|
||||
namespace ewol
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
/**
|
||||
* @brief VirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside
|
||||
*/
|
||||
// TODO : use and test it
|
||||
class VirtualBufferObject : public ewol::Resource
|
||||
{
|
||||
class VirtualBufferObject : public ewol::Resource
|
||||
{
|
||||
private :
|
||||
bool m_exist;
|
||||
GLuint m_vbo;
|
||||
public:
|
||||
// data that is availlable in the VBO system ...
|
||||
etk::Vector<float> m_buffer;
|
||||
public:
|
||||
VirtualBufferObject(etk::UString& accesMode);
|
||||
virtual ~VirtualBufferObject(void);
|
||||
const char* GetType(void) { return "ewol::VirtualBufferObject"; };
|
||||
GLuint GetGL_ID(void) { return m_vbo; };
|
||||
etk::Vector<float>& GetRefByffer(void) { return m_buffer; };
|
||||
void RetreiveData(void);
|
||||
void UpdateContext(void);
|
||||
void RemoveContext(void);
|
||||
void RemoveContextToLate(void);
|
||||
void Reload(void);
|
||||
};
|
||||
private :
|
||||
bool m_exist; //!< This data is availlable in the Graphic card
|
||||
GLuint m_vbo; //!< OpenGl ID of this VBO
|
||||
etk::Vector<float> m_buffer; //!< data that is availlable in the VBO system ...
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor of this VBO.
|
||||
* @param[in] accesMode Acces mode : ???
|
||||
*/
|
||||
VirtualBufferObject(etk::UString& accesMode);
|
||||
/**
|
||||
* @brief Destructor of this VBO.
|
||||
*/
|
||||
virtual ~VirtualBufferObject(void);
|
||||
/**
|
||||
* @brief Generic function that get the resouces name of his type.
|
||||
* @return The define char of his name.
|
||||
*/
|
||||
const char* GetType(void) { return "ewol::VirtualBufferObject"; };
|
||||
/**
|
||||
* @brief Get the real OpenGL ID.
|
||||
* @return the Ogl id reference of this VBO.
|
||||
*/
|
||||
GLuint GetGL_ID(void) { return m_vbo; };
|
||||
/**
|
||||
* @brief Get a reference on hte buffer data for this VBO.
|
||||
* @return A reference on the data.
|
||||
*/
|
||||
etk::Vector<float>& GetRefBuffer(void) { return m_buffer; };
|
||||
/**
|
||||
* @brief Get the data from the graphic card.
|
||||
*/
|
||||
void RetreiveData(void);
|
||||
/**
|
||||
* @brief Send the data to the graphic card.
|
||||
*/
|
||||
void Flush(void) {};
|
||||
/**
|
||||
* @brief This load/reload the data in the opengl context, needed when removed previously.
|
||||
*/
|
||||
void UpdateContext(void);
|
||||
/**
|
||||
* @brief Remove the data from the opengl context.
|
||||
*/
|
||||
void RemoveContext(void);
|
||||
/**
|
||||
* @brief Special android spec! It inform us that all context is removed and after notify us...
|
||||
*/
|
||||
void RemoveContextToLate(void);
|
||||
/**
|
||||
* @brief Relode the shader from the file. used when a request of resouces reload is done.
|
||||
* @note this is really usefull when we tested the new themes or shader developpements.
|
||||
*/
|
||||
void Reload(void);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -48,14 +48,38 @@ extern "C" {
|
||||
|
||||
namespace ewol {
|
||||
namespace openGL {
|
||||
/**
|
||||
* @brief Initialize the open gl system (all the data register in the graphic card is all time duplicate in the memory)
|
||||
* this is due to the fact of some operating system destroy sometime the opengl context
|
||||
*/
|
||||
void Init(void);
|
||||
/**
|
||||
* @brief un-init the opengl element from the graphic card
|
||||
*/
|
||||
void UnInit(void);
|
||||
// reset the basic element at this one ... remove all previous
|
||||
/**
|
||||
* @brief When you will done an opengl rendering, you might call this reset matrix first. It remove all the stach of the matrix pushed.
|
||||
* @param[in] newOne the default matrix that might be set for the graphic card for renderer. if too more pop will be done, this is the last that mmight survived
|
||||
*/
|
||||
void SetBasicMatrix(etk::Matrix4& newOne);
|
||||
// this is the same system as openGL-ES-1 but in openGL-ES-2 (here is the abstraction)
|
||||
/**
|
||||
* @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed).
|
||||
* @param[in] newOne The new current matrix use for the render.
|
||||
* @note We did not use opengl standard system, due to the fact that is not supported in opengl ES-2
|
||||
*/
|
||||
void SetMatrix(etk::Matrix4& newOne);
|
||||
/**
|
||||
* @brief Store current matrix in the matrix stack.
|
||||
*/
|
||||
void Push(void);
|
||||
/**
|
||||
* @brief Remove the current matrix and get the last one from the matrix stack.
|
||||
*/
|
||||
void Pop(void);
|
||||
/**
|
||||
* @brief Get a reference on the current matrix destinate to opengl renderer.
|
||||
* @return The requested matrix.
|
||||
*/
|
||||
etk::Matrix4& GetMatrix(void);
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user