PDA

View Full Version : how to bring a drawn image in background by shaders.



Jeevan
07-29-2016, 01:37 AM
Hi,

I am new to the opengl and shaders concept i am using vertex array objects and vertex buffer objects memory of GPU by using shaders and drawing an arc using triangles and made an arc,after drawing an arc i am trying to load some image on it.but the drawing arc is appearing first and the image is going background, how to bring an image foreground and send the arc background,i am using drawgreenarc function given below for display.how to use translate function in it.Can any one help me out for solving this issue.


CreateModelGreen()
{
//Green
GLuint uiVaoGreen;

glGenVertexArrays(1, &uiVaoGreen);
glBindVertexArray(uiVaoGreen);

glGenBuffers(1, &uiVboGreen);
glBindBuffer(GL_ARRAY_BUFFER, uiVboGreen);
glBufferData(GL_ARRAY_BUFFER, sizeof(m_verticesGreen) *VS_RING_MAX_VERTICIES* VTD_COLUMN_LENGHT, NULL, GL_DYNAMIC_DRAW);

glGenBuffers(1, &uiIboGreen);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uiIboGreen);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_objIndicesGreen)* VS_RING_MAX_INDICIES, NULL, GL_DYNAMIC_DRAW);

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, VTD_COLUMN_LENGHT * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, VTD_COLUMN_LENGHT * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
glBindVertexArray(0);

m_uiVaoGreen = uiVaoGreen;

return SUCCESS;
}


DrawGreenArc()
{
ulgrnData = m_objGrnAnglePkt[ANG_CLI];
UpdateAdvisoryGreen(ANG_CLI);
CalculateIndiciesGrn();


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0, 0.0, 0.0, 1.0);

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);

glEnable(GL_BLEND); // added for multitexturing tutorial
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glPushMatrix();
glTranslatef(0.0f,0.0f,0.98f);
// glRotatef(270.0f, 0.0f, 0.0f, 1.0f);
glUseProgram(m_uiProgram);
glBindVertexArray(m_uiVaoGreen);

glBindBuffer(GL_ARRAY_BUFFER, uiVboGreen);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_verticesGreen)* VS_RING_MAX_VERTICIES * VTD_COLUMN_LENGHT, m_verticesGreen);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uiIboGreen);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(m_objIndicesGreen) * VS_RING_MAX_INDICIES, m_objIndicesGreen);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uiIboGreen);
glDrawElements(GL_TRIANGLES, VS_RING_MAX_INDICIES, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glPopMatrix();
}