high-quality curve

i want to plot high-quality curve - simple chart but very huge size more than 200MB.
a problem exists when it is ploting on slower graphics card because chart manipulations take not aceptable time.
all operations i need are move, zoom, scale, cut.
please help me by provide link to example c++ program and teling me what should be done with this matter. im new in opengl but i understand it little, unfotunatelly havent any of experience with OGL.

heh ptobably any responce because of my bad english :frowning:

i know the simlilar problem with a texture can be resolved using Mipmaps. is there a way to resolve my ?

More probably no response because you ask people to “provide link to example c++ program”.

If card need less line to be interactive, do that. Create less detailed plots that will be used during interactive manipulation by the user.

You can skip 1 in 4 points of the plot for example, and even do that with several levels, like mipmaps. And whenever you measure a too long rendering time per frame, go to a simpler level, etc.

thx, yes i can do that but ir little complicate the code.
i think use some kind of buffers is that i want. but i still dont know ay more… i ve try to use vbo buffer but this g card hasnt cuda.

are there any way to simple draw this line in buffer once and then only use just ready buffer in paint routine ?

i try to ask again uding kuttke different questions.

is it possible (and how) to use some kind of opengl bufferes to render high quiality lines to avoid rendering at every redraw ?

im looking for some base solution because the code has to be very portable, so on.

Very Thanks for any help !

what is wrong woth that code ? is Qt part of paint body :
if (buffer1 == NULL)
{
buffer1 = new QGLBuffer(QGLBuffer::VertexBuffer);
buffer1->setUsagePattern(QGLBuffer::DynamicDraw);

if (!buffer1->create())
{
	qFatal("cant create buffer");
	delete buffer1;
	buffer1 = NULL;
	return;
}

buffer1->bind();
buffer1->allocate(sizeof(GLdouble) * 2 * samples.size());
if (!buffer1->map(QGLBuffer::WriteOnly))
{
	qFatal("cant map buffer");
	buffer1->unmap();
	buffer1->release();
	delete buffer1;
	buffer1 = NULL;
	return;
}
buffer1->unmap();
buffer1->release();

}

if (buffer1)
{
buffer1->bind();
void mapped = buffer1->map(QGLBuffer::WriteOnly);
QVector2D
posns = (QVector2D *)mapped;

for (int i=0; i<samples.size();i++)
	posns[i] = QVector2D(samples[i].sx, samples[i].sy);

buffer1->unmap();
buffer1->release();

// glEnableClientState(GL_VERTEX_ARRAY); need this ?
buffer1->bind();
glDrawArrays(curve->style(), 0, samples.size()); //i think here something is wrong
buffer1->release();
}

You’re not telling OpenGL where to retrieve the vertex data from. You need to have some glVertexPointer/ gl{***}Pointer calls in there. eg.


glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); // only if you want per-vertex color
buffer1->bind();
// tell OpenGL to grab vertex data from the start of buffer1 (the currently bound buffer object), with 2 double co-ordinates per vertex, tightly packed
glVertexPointer(2, GL_DOUBLE, 0 {or vertex size}, BUFFER_OFFSET(0));
glColorPointer(...); // only if you want per-vertex color
buffer1->release();

// note: buffer doesn't need to be bound at point of draw call
// OpenGL records which buffer was bound when you call gl***Pointer and stores it.
// this means you can tell OpenGL to retrieve data from different buffer objects for each attribute if you wish.
glDrawArrays(curve->style(), 0, samples.size());

is that means buffer must be mapped before glVertexPointer ?
if not then how can i get BUFFER_OFFSET ?

When a buffer object is bound, the “pointer” argument is an offset into that buffer. Since “pointer” is declared as

const GLvoid *  	pointer

then most languages will require a type-cast to convert the offset into this.

If you look at http://www.opengl.org/wiki/Vertex_Buffer_Object , for C++ they use:

#define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i))

please take a loook - still ctashed.

#define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i))
if (buffer1 == NULL)
{
buffer1 = new QGLBuffer(QGLBuffer::VertexBuffer);
buffer1->setUsagePattern(QGLBuffer::DynamicDraw);
//buffer1->setUsagePattern(QGLBuffer::StaticDraw);
if (!buffer1->create())
{
qFatal(“cant create buffer”);
delete buffer1;
buffer1 = NULL;
return;
}
buffer1->bind();
buffer1->allocate(sizeof(GLdouble) * 2 * samples.size());

if (!buffer1-&gt;map(QGLBuffer::WriteOnly))
{
	qFatal("cant map buffer");
	buffer1-&gt;unmap();
	buffer1-&gt;release();
	delete buffer1;
	buffer1 = NULL;
	return;
}
buffer1-&gt;unmap();
buffer1-&gt;release();

}

if (buffer1)
{
buffer1->bind();
void mapped = buffer1->map(QGLBuffer::WriteOnly);
QVector2D
posns = (QVector2D *)mapped;

for (int i=0; i&lt;samples.size();i++)
	posns[i] = QVector2D(samples[i].sx,		samples[i].sy);

	buffer1-&gt;unmap();
	buffer1-&gt;release();

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY); // only if you want per-vertex color
	buffer1-&gt;bind();

	glVertexPointer(2, GL_DOUBLE, sizeof(plotSample), BUFFER_OFFSET(0) );
	buffer1-&gt;release();

	glDrawArrays(curve-&gt;style(), 0, samples.size());

}

Please use code blocks when you post code on the forum. It makes it more readable and increase your chances of getting good help. It is the little icon with a # when you are on the full reply view.

ok i try …

#define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i))
        	if (buffer1 == NULL)
        	{
        		buffer1 = new QGLBuffer(QGLBuffer::VertexBuffer);
        		buffer1->setUsagePattern(QGLBuffer::DynamicDraw);
        		//buffer1->setUsagePattern(QGLBuffer::StaticDraw);
        		if (!buffer1->create())
        		{
        			qFatal("cant create buffer");
        			delete buffer1;
        		    buffer1 = NULL;
        		    return;
        		}
        		buffer1->bind();
        		buffer1->allocate(sizeof(GLdouble) * 2 * samples.size());

        		if (!buffer1->map(QGLBuffer::WriteOnly))
        		{
        			qFatal("cant map buffer");
        			buffer1->unmap();
        			buffer1->release();
        			delete buffer1;
        			buffer1 = NULL;
        			return;
        		}
        		buffer1->unmap();
        		buffer1->release();
        	}

        	if (buffer1)
        	{
        		buffer1->bind();
        	    void *mapped = buffer1->map(QGLBuffer::WriteOnly);
        	    QVector2D* posns = (QVector2D *)mapped;

        	    for (int i=0; i<samples.size();i++)
        	    	posns[i] = QVector2D(samples[i].sx,		samples[i].sy);

				buffer1->unmap();
				buffer1->release();

				glEnableClientState(GL_VERTEX_ARRAY);
//				glEnableClientState(GL_COLOR_ARRAY); // only if you want per-vertex color
				buffer1->bind();

				glVertexPointer(2, GL_DOUBLE, samples.size(), 0 );
				buffer1->release();

				glDrawArrays(curve->style(), 0, samples.size());
        	}

the code above doesnt work. no idea why. i need a bit help stil.

Since AFAICT samples.size() is the number of vertices, then you shouldn’t be using this as the stride argument (stride = how many bytes between consecutive vertices, or tightly packed if 0)

glVertexPointer(2, GL_DOUBLE, samples.size(), 0 );

should probably be

glVertexPointer(2, GL_DOUBLE, 0, 0 );

THX, now something is plotted from the buffer even it is not rxactly it should be - probably i need a bit work on that.

again thank You and i be back if it is work at last.