Jump to content
  • Advertisement
Sign in to follow this  
frog04

OpenGL Opengl-Buffer question?

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to visualize a "chess-board" but with more than 160.000 sqaures each colored according to some measurment-values. I'm usging wxWidgets with a wxGLCanvas-object. Now i set up a glOrtho (only 2D is needed) and paint the squares. I'm using multiple windows so more "measurement-objects" could be viewn. Now i had the problem with scroll, size, overlapping,..., everything that calls a PaintEvent. There are to many float-values to render it every-time. So i tried following trick:
[source==cpp]
OnPaint(..)
{
 if(first)
 {
   glDrawBuffer(GL_FRONT);
   Render(); 

   glDrawBuffer(GL_BACK);
   Render();
  first = false;
 }
 SwapBuffers();
}


But this code makes errors on some systems, picture is getting blurred and black, a total mass. Now i'm seraching for some kind of buffer-object or anything like this!? instead of rendering it everytime (it's not animated!). Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
As i said: "There are too many float-values to render it every-time."

If I render it every-PaintEvent it's bucking hard.

Share this post


Link to post
Share on other sites
Rendering 160000 texels every frame is not a significant problem if you're doing it efficiently. What method do you use to draw the chessboard?

Share this post


Link to post
Share on other sites
I tried it with a FBO-Object but have this problem:
http://www.gamedev.net/community/forums/topic.asp?topic_id=515600

My draw-Method for every cell looks like this:

void GLCanvas::drawCell(int *x_pos, int *y_pos, int bin_value)
{
right_x = x_offset * (*x_pos + 1);
left_x = x_offset * (*x_pos);
top_y = y_offset * (*y_pos + 1);
bottom_y = y_offset * (*y_pos);

glColor3f(0.5f, 0.5f, 0.2f);

glBegin(GL_LINE_LOOP);
glVertex2i(right_x, top_y);
glVertex2i(left_x, top_y);
glVertex2i(left_x, bottom_y );
glVertex2i(right_x, bottom_y);
glEnd();

// switch colour depending on the bin-value
wxColour *colour = mdi_parent_ptr->getColour(bin_value);
convertColourTo3f(colour);

//if((bin_value != REF_DIE) && (bin_value != REF_DIE2))
glRecti(right_x, top_y, left_x, bottom_y);

// draw a point in the middle of all none good-dies
if(bin_value != 0x01)
{
// set color black
glColor3f(0.0f, 0.0f, 0.0f);

// set point size according the scale
glPointSize(point_size);

glBegin(GL_POINTS);
glVertex2i(left_x + x_offset / 2, bottom_y + y_offset / 2);
glEnd();
}
}



I still reduced it to integer-values and also made tried it with a display-list.

Calling it @ a for-loop:

for(int index = 0; index < num_of_dies; index++)
{
x = wafer_ptr->getDie(index)->getXcoord();
y = wafer_ptr->getDie(index)->getYcoord();
b = wafer_ptr->getDie(index)->getBinValue();
drawCell(&x, &y, b);
}



Probably this could be made faster in a int-array?(think so)

Share this post


Link to post
Share on other sites
Yeah, that's going to be really, really slow. High-performance OpenGL requires that you NOT draw 640 thousand vertices with glVertex. Put all your square values in a texture and render that texture using a single quad.

Share this post


Link to post
Share on other sites
General question on Window-buffers.

Why is it necessary to render the whole scene again if e.g. scroll-event occurs.
Why do the window itself doesn't store the picture temporary and just call a buffer if it is overlapped or scrolled.

I can't imagine that this is made with repaintings?

Share this post


Link to post
Share on other sites
Quote:
Original post by frog04
General question on Window-buffers.

Why is it necessary to render the whole scene again if e.g. scroll-event occurs.
Why do the window itself doesn't store the picture temporary and just call a buffer if it is overlapped or scrolled.

I can't imagine that this is made with repaintings?

I don't know wx, but i imagine they do window stuff simply by drawing on top of the GL canvas ? Caching makes sense only in limited cases where the scene is static (not your usual GL app), meaning it's your job to do so. Simply render the scene to texture (or use glCopyTexImage* to copy the rendered scene from framebuffer to texture), then on repaint draw fullscreen quad with the texture. This will be fast everywhere.

Share this post


Link to post
Share on other sites
Quote:
Original post by frog04
General question on Window-buffers.

Why is it necessary to render the whole scene again if e.g. scroll-event occurs.
Why do the window itself doesn't store the picture temporary and just call a buffer if it is overlapped or scrolled.

I can't imagine that this is made with repaintings?


Because normally, the backbuffer is not preserved when you call SwapBuffers. The driver can just switch pointers so that the back buffer becomes the front buffer and the front becomes back.
The driver can do all sorts of crazy things.

You can try setting the PFD_SWAP_COPY but personally, I would recommend the RTT method I already mentioned.

Swapbuffers issue
http://www.opengl.org/wiki/index.php/Common_Mistakes#Swap_Buffers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!