Drawing to multiple buffers simultaneously and rendering each buffer Individually to display











up vote
0
down vote

favorite












My idea and requirement are to allow creating atmost 'n' buffers (where is n<7) during the program execution.
So, ideally, I am looking for a way, where I can draw different things to different buffers and render each buffer as and when needed.



Like:



Buffer1 - Draw a rectangle



Buffer2 - Draw some texture (font/text) "Welcome"



Buffer3 - Draw some polygon



Buffer4 - Draw some texture (font/text) "Supporter of Stack overflow"



... and so on.



Here simultaneously, I want to write different things to different buffers.
And then I may only want to render say contents of Buffer2, then after some time flush the display and render Buffer4.



My not working code:



GLuint VB1;
glGenBuffers(1, &VB1);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
DrawRect(VB1);

GLuint VB2;
glGenBuffers(1, &VB2);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
TextDraw(VB1, "Welcome");

eglSwapBuffers(egldisplay, eglsurface);


This renders everything of VB1 and VB2 both, when I say eglSwapBuffer. How can I only render one buffer.



I am doing



glBindBuffer(GL_ARRAY_BUFFER, VB)


in DrawRect() and TextDraw() definitions, which I believe should not be done.



Need help to determine how to write to each buffers separately and how to bind the required buffer contents on the display. (when needed).



DrawRect Implementation



void DrawRect(GLint VB)
{
int position_loc = glGetAttribLocation(ProgramObject, "vertex");
GLfloat Vertices[4][4] = {
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f
};
GLfloat red[4] = {1, 0, 1, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, red);
glEnableVertexAttribArray(position_loc);
printf("nAfter Enable Vertex Attrib Array");
glBindBuffer(GL_ARRAY_BUFFER, VB);
glVertexAttribPointer(position_loc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBufferData(GL_ARRAY_BUFFER, sizeof Vertices, Vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}



void TextDraw(GLuint VB, std::string message, GLfloat x, GLfloat y, GLfloat sx, GLfloat sy)

{
int vPosition = glGetAttribLocation(ProgramObject, "vertex");
std::string::const_iterator ch;
for (ch = message.begin(); ch != message.end(); ch++)
{
const char c = *ch;
if (FT_Load_Char(face, c, FT_LOAD_RENDER | FT_LOAD_COLOR))
{
std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
continue;
}

GLfloat xpos = x + (face->glyph->bitmap_left) * sx;
GLfloat ypos = -y - (face->glyph->bitmap_top) * sy;
GLfloat w = (face->glyph->bitmap.width) * sx;
GLfloat h = (face->glyph->bitmap.rows) * sy;

GLfloat vertices[4][4] = {
{xpos, -ypos , 0, 0},
{xpos + w, -ypos , 1, 0},
{xpos, -ypos - h, 0, 1},
{xpos + w, -ypos - h, 1, 1},
};

glActiveTexture(GL_TEXTURE0);
GLuint text;
glGenTextures(1, &text);
glBindTexture(GL_TEXTURE_2D, text);
glUniform1i(glGetUniformLocation(ProgramObject, "text"), 0);
PrintGlError();
GLfloat black[4] = {0, 0, 0, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, black);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_ALPHA,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
x += (face->glyph->advance.x/64) * sx;
y += (face->glyph->advance.y/64) * sy;
glDeleteTextures(1, &text);
glDisableVertexAttribArray(vPosition);
}

}









share|improve this question
























  • This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
    – Botje
    Nov 22 at 8:55










  • So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
    – VTT
    Nov 22 at 9:22












  • @Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
    – moizh
    Nov 22 at 9:31










  • @VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
    – moizh
    Nov 22 at 9:35










  • I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
    – Botje
    Nov 22 at 9:38















up vote
0
down vote

favorite












My idea and requirement are to allow creating atmost 'n' buffers (where is n<7) during the program execution.
So, ideally, I am looking for a way, where I can draw different things to different buffers and render each buffer as and when needed.



Like:



Buffer1 - Draw a rectangle



Buffer2 - Draw some texture (font/text) "Welcome"



Buffer3 - Draw some polygon



Buffer4 - Draw some texture (font/text) "Supporter of Stack overflow"



... and so on.



Here simultaneously, I want to write different things to different buffers.
And then I may only want to render say contents of Buffer2, then after some time flush the display and render Buffer4.



My not working code:



GLuint VB1;
glGenBuffers(1, &VB1);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
DrawRect(VB1);

GLuint VB2;
glGenBuffers(1, &VB2);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
TextDraw(VB1, "Welcome");

eglSwapBuffers(egldisplay, eglsurface);


This renders everything of VB1 and VB2 both, when I say eglSwapBuffer. How can I only render one buffer.



I am doing



glBindBuffer(GL_ARRAY_BUFFER, VB)


in DrawRect() and TextDraw() definitions, which I believe should not be done.



Need help to determine how to write to each buffers separately and how to bind the required buffer contents on the display. (when needed).



DrawRect Implementation



void DrawRect(GLint VB)
{
int position_loc = glGetAttribLocation(ProgramObject, "vertex");
GLfloat Vertices[4][4] = {
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f
};
GLfloat red[4] = {1, 0, 1, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, red);
glEnableVertexAttribArray(position_loc);
printf("nAfter Enable Vertex Attrib Array");
glBindBuffer(GL_ARRAY_BUFFER, VB);
glVertexAttribPointer(position_loc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBufferData(GL_ARRAY_BUFFER, sizeof Vertices, Vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}



void TextDraw(GLuint VB, std::string message, GLfloat x, GLfloat y, GLfloat sx, GLfloat sy)

{
int vPosition = glGetAttribLocation(ProgramObject, "vertex");
std::string::const_iterator ch;
for (ch = message.begin(); ch != message.end(); ch++)
{
const char c = *ch;
if (FT_Load_Char(face, c, FT_LOAD_RENDER | FT_LOAD_COLOR))
{
std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
continue;
}

GLfloat xpos = x + (face->glyph->bitmap_left) * sx;
GLfloat ypos = -y - (face->glyph->bitmap_top) * sy;
GLfloat w = (face->glyph->bitmap.width) * sx;
GLfloat h = (face->glyph->bitmap.rows) * sy;

GLfloat vertices[4][4] = {
{xpos, -ypos , 0, 0},
{xpos + w, -ypos , 1, 0},
{xpos, -ypos - h, 0, 1},
{xpos + w, -ypos - h, 1, 1},
};

glActiveTexture(GL_TEXTURE0);
GLuint text;
glGenTextures(1, &text);
glBindTexture(GL_TEXTURE_2D, text);
glUniform1i(glGetUniformLocation(ProgramObject, "text"), 0);
PrintGlError();
GLfloat black[4] = {0, 0, 0, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, black);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_ALPHA,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
x += (face->glyph->advance.x/64) * sx;
y += (face->glyph->advance.y/64) * sy;
glDeleteTextures(1, &text);
glDisableVertexAttribArray(vPosition);
}

}









share|improve this question
























  • This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
    – Botje
    Nov 22 at 8:55










  • So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
    – VTT
    Nov 22 at 9:22












  • @Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
    – moizh
    Nov 22 at 9:31










  • @VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
    – moizh
    Nov 22 at 9:35










  • I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
    – Botje
    Nov 22 at 9:38













up vote
0
down vote

favorite









up vote
0
down vote

favorite











My idea and requirement are to allow creating atmost 'n' buffers (where is n<7) during the program execution.
So, ideally, I am looking for a way, where I can draw different things to different buffers and render each buffer as and when needed.



Like:



Buffer1 - Draw a rectangle



Buffer2 - Draw some texture (font/text) "Welcome"



Buffer3 - Draw some polygon



Buffer4 - Draw some texture (font/text) "Supporter of Stack overflow"



... and so on.



Here simultaneously, I want to write different things to different buffers.
And then I may only want to render say contents of Buffer2, then after some time flush the display and render Buffer4.



My not working code:



GLuint VB1;
glGenBuffers(1, &VB1);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
DrawRect(VB1);

GLuint VB2;
glGenBuffers(1, &VB2);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
TextDraw(VB1, "Welcome");

eglSwapBuffers(egldisplay, eglsurface);


This renders everything of VB1 and VB2 both, when I say eglSwapBuffer. How can I only render one buffer.



I am doing



glBindBuffer(GL_ARRAY_BUFFER, VB)


in DrawRect() and TextDraw() definitions, which I believe should not be done.



Need help to determine how to write to each buffers separately and how to bind the required buffer contents on the display. (when needed).



DrawRect Implementation



void DrawRect(GLint VB)
{
int position_loc = glGetAttribLocation(ProgramObject, "vertex");
GLfloat Vertices[4][4] = {
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f
};
GLfloat red[4] = {1, 0, 1, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, red);
glEnableVertexAttribArray(position_loc);
printf("nAfter Enable Vertex Attrib Array");
glBindBuffer(GL_ARRAY_BUFFER, VB);
glVertexAttribPointer(position_loc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBufferData(GL_ARRAY_BUFFER, sizeof Vertices, Vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}



void TextDraw(GLuint VB, std::string message, GLfloat x, GLfloat y, GLfloat sx, GLfloat sy)

{
int vPosition = glGetAttribLocation(ProgramObject, "vertex");
std::string::const_iterator ch;
for (ch = message.begin(); ch != message.end(); ch++)
{
const char c = *ch;
if (FT_Load_Char(face, c, FT_LOAD_RENDER | FT_LOAD_COLOR))
{
std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
continue;
}

GLfloat xpos = x + (face->glyph->bitmap_left) * sx;
GLfloat ypos = -y - (face->glyph->bitmap_top) * sy;
GLfloat w = (face->glyph->bitmap.width) * sx;
GLfloat h = (face->glyph->bitmap.rows) * sy;

GLfloat vertices[4][4] = {
{xpos, -ypos , 0, 0},
{xpos + w, -ypos , 1, 0},
{xpos, -ypos - h, 0, 1},
{xpos + w, -ypos - h, 1, 1},
};

glActiveTexture(GL_TEXTURE0);
GLuint text;
glGenTextures(1, &text);
glBindTexture(GL_TEXTURE_2D, text);
glUniform1i(glGetUniformLocation(ProgramObject, "text"), 0);
PrintGlError();
GLfloat black[4] = {0, 0, 0, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, black);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_ALPHA,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
x += (face->glyph->advance.x/64) * sx;
y += (face->glyph->advance.y/64) * sy;
glDeleteTextures(1, &text);
glDisableVertexAttribArray(vPosition);
}

}









share|improve this question















My idea and requirement are to allow creating atmost 'n' buffers (where is n<7) during the program execution.
So, ideally, I am looking for a way, where I can draw different things to different buffers and render each buffer as and when needed.



Like:



Buffer1 - Draw a rectangle



Buffer2 - Draw some texture (font/text) "Welcome"



Buffer3 - Draw some polygon



Buffer4 - Draw some texture (font/text) "Supporter of Stack overflow"



... and so on.



Here simultaneously, I want to write different things to different buffers.
And then I may only want to render say contents of Buffer2, then after some time flush the display and render Buffer4.



My not working code:



GLuint VB1;
glGenBuffers(1, &VB1);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
DrawRect(VB1);

GLuint VB2;
glGenBuffers(1, &VB2);
glUseProgram(ProgramObject);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
TextDraw(VB1, "Welcome");

eglSwapBuffers(egldisplay, eglsurface);


This renders everything of VB1 and VB2 both, when I say eglSwapBuffer. How can I only render one buffer.



I am doing



glBindBuffer(GL_ARRAY_BUFFER, VB)


in DrawRect() and TextDraw() definitions, which I believe should not be done.



Need help to determine how to write to each buffers separately and how to bind the required buffer contents on the display. (when needed).



DrawRect Implementation



void DrawRect(GLint VB)
{
int position_loc = glGetAttribLocation(ProgramObject, "vertex");
GLfloat Vertices[4][4] = {
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f
};
GLfloat red[4] = {1, 0, 1, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, red);
glEnableVertexAttribArray(position_loc);
printf("nAfter Enable Vertex Attrib Array");
glBindBuffer(GL_ARRAY_BUFFER, VB);
glVertexAttribPointer(position_loc, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBufferData(GL_ARRAY_BUFFER, sizeof Vertices, Vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}



void TextDraw(GLuint VB, std::string message, GLfloat x, GLfloat y, GLfloat sx, GLfloat sy)

{
int vPosition = glGetAttribLocation(ProgramObject, "vertex");
std::string::const_iterator ch;
for (ch = message.begin(); ch != message.end(); ch++)
{
const char c = *ch;
if (FT_Load_Char(face, c, FT_LOAD_RENDER | FT_LOAD_COLOR))
{
std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
continue;
}

GLfloat xpos = x + (face->glyph->bitmap_left) * sx;
GLfloat ypos = -y - (face->glyph->bitmap_top) * sy;
GLfloat w = (face->glyph->bitmap.width) * sx;
GLfloat h = (face->glyph->bitmap.rows) * sy;

GLfloat vertices[4][4] = {
{xpos, -ypos , 0, 0},
{xpos + w, -ypos , 1, 0},
{xpos, -ypos - h, 0, 1},
{xpos + w, -ypos - h, 1, 1},
};

glActiveTexture(GL_TEXTURE0);
GLuint text;
glGenTextures(1, &text);
glBindTexture(GL_TEXTURE_2D, text);
glUniform1i(glGetUniformLocation(ProgramObject, "text"), 0);
PrintGlError();
GLfloat black[4] = {0, 0, 0, 1};
glUniform4fv(glGetUniformLocation(ProgramObject, "color"), 1, black);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_ALPHA,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_DYNAMIC_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
x += (face->glyph->advance.x/64) * sx;
y += (face->glyph->advance.y/64) * sy;
glDeleteTextures(1, &text);
glDisableVertexAttribArray(vPosition);
}

}






c++ opengl-es framebuffer egl opengl-2.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 10:03

























asked Nov 22 at 8:46









moizh

205




205












  • This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
    – Botje
    Nov 22 at 8:55










  • So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
    – VTT
    Nov 22 at 9:22












  • @Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
    – moizh
    Nov 22 at 9:31










  • @VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
    – moizh
    Nov 22 at 9:35










  • I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
    – Botje
    Nov 22 at 9:38


















  • This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
    – Botje
    Nov 22 at 8:55










  • So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
    – VTT
    Nov 22 at 9:22












  • @Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
    – moizh
    Nov 22 at 9:31










  • @VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
    – moizh
    Nov 22 at 9:35










  • I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
    – Botje
    Nov 22 at 9:38
















This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
– Botje
Nov 22 at 8:55




This smells like an XY problem. Why the requirement to have different 'buffers' and choose between them? What do your DrawRect and TextDraw functions do with the buffers? Can't you do conditional drawing? Do textures count as buffers?
– Botje
Nov 22 at 8:55












So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
– VTT
Nov 22 at 9:22






So what exactly prevents you from having n buffers, drawing to them and then drawing them to back buffer?
– VTT
Nov 22 at 9:22














@Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
– moizh
Nov 22 at 9:31




@Botje As per the LearnOpenGL tutorials I have followed, I thought we need buffers always, isn't it? What do you mean by conditional drawing? Can it be done without buffers?
– moizh
Nov 22 at 9:31












@VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
– moizh
Nov 22 at 9:35




@VTT Thats how exactly I want to do. But I did not find any tutorial or example of how in OpenGL should I draw to n buffers and copy one at a time to actual rendering surface to get it rendered. Can you point me to some example that shows how to do that?
– moizh
Nov 22 at 9:35












I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
– Botje
Nov 22 at 9:38




I think there is a confusion at play here: there are Frame buffers (which are a target that OpenGL can render to and from?), there are Vertex buffer objects (which contain data about vertices used in rendering operations), and there are Vertex array objects (which tell OpenGL how to interpret the VBOs when it is actually rendering)
– Botje
Nov 22 at 9:38

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426944%2fdrawing-to-multiple-buffers-simultaneously-and-rendering-each-buffer-individuall%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426944%2fdrawing-to-multiple-buffers-simultaneously-and-rendering-each-buffer-individuall%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Fiat S.p.A.

Type 'String' is not a subtype of type 'int' of 'index'