spirox
12-19-2011, 05:40 AM
Hello,
Iam using OpenGL in Borladn studio 2006 and I try to program spectrograph (waterfall). Its mean add one line where each pixel has different colors and scroll down the screen (one pixel down). These steps run forever.
I prepeare texture BitMap and associate one time with OpenGl rectangle constructed by GL_QUADS. New data modified this texture(its first line) and scroll down texture by glTranslatef(0,-(1./(float)actGraph->Height),0) and paint the GL_QUADS. Adding new line code:
i = 0;
actGraph = &Graphs[i];
glBindTexture( GL_TEXTURE_2D, actGraph->TexName ); //choose texture
if (Data !=NULL) {
if (Mov == 0) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, actGraph->Width , 1, GL_LUMINANCE , GL_UNSIGNED_BYTE, Data);
else glTexSubImage2D(GL_TEXTURE_2D, 0, 0, actGraph->Height-Mov, actGraph->Width , 1, GL_LUMINANCE , GL_UNSIGNED_BYTE,
Data);
}
glBegin(GL_QUADS);
glTexCoord2d(0.0,0.0); glVertex2d(actGraph->x1,actGraph->y1);
glTexCoord2d(1.0,0.0); glVertex2d(actGraph->x2,actGraph->y1);
glTexCoord2d(1.0,1.0); glVertex2d(actGraph->x2,actGraph->y2);
glTexCoord2d(0.0,1.0); glVertex2d(actGraph->x1,actGraph->y2);
glEnd();
}
glBindTexture( GL_TEXTURE_2D, 1);
glMatrixMode(GL_TEXTURE);
glTranslatef(0,-(1./(float)actGraph->Height),0);
glMatrixMode(GL_MODELVIEW);
Program works fine with smaller texture size (500x300). But if I enlarge waterfall to (500x900) there is significant slowdown (3times) of painting and increase cpu time.
I suppose that I modify only one line of texture by command glTexSubImage2D (only here goes data from cpu to graphic card) and painting
glBegin(GL_QUADS) statement must be done fast because its run from graphic card directly. Isn’t it?
Is there any way, how to improve repainting large texture?
Iam using OpenGL in Borladn studio 2006 and I try to program spectrograph (waterfall). Its mean add one line where each pixel has different colors and scroll down the screen (one pixel down). These steps run forever.
I prepeare texture BitMap and associate one time with OpenGl rectangle constructed by GL_QUADS. New data modified this texture(its first line) and scroll down texture by glTranslatef(0,-(1./(float)actGraph->Height),0) and paint the GL_QUADS. Adding new line code:
i = 0;
actGraph = &Graphs[i];
glBindTexture( GL_TEXTURE_2D, actGraph->TexName ); //choose texture
if (Data !=NULL) {
if (Mov == 0) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, actGraph->Width , 1, GL_LUMINANCE , GL_UNSIGNED_BYTE, Data);
else glTexSubImage2D(GL_TEXTURE_2D, 0, 0, actGraph->Height-Mov, actGraph->Width , 1, GL_LUMINANCE , GL_UNSIGNED_BYTE,
Data);
}
glBegin(GL_QUADS);
glTexCoord2d(0.0,0.0); glVertex2d(actGraph->x1,actGraph->y1);
glTexCoord2d(1.0,0.0); glVertex2d(actGraph->x2,actGraph->y1);
glTexCoord2d(1.0,1.0); glVertex2d(actGraph->x2,actGraph->y2);
glTexCoord2d(0.0,1.0); glVertex2d(actGraph->x1,actGraph->y2);
glEnd();
}
glBindTexture( GL_TEXTURE_2D, 1);
glMatrixMode(GL_TEXTURE);
glTranslatef(0,-(1./(float)actGraph->Height),0);
glMatrixMode(GL_MODELVIEW);
Program works fine with smaller texture size (500x300). But if I enlarge waterfall to (500x900) there is significant slowdown (3times) of painting and increase cpu time.
I suppose that I modify only one line of texture by command glTexSubImage2D (only here goes data from cpu to graphic card) and painting
glBegin(GL_QUADS) statement must be done fast because its run from graphic card directly. Isn’t it?
Is there any way, how to improve repainting large texture?