PDA

View Full Version : Texture in QGLWidget



showhand
25th October 2006, 11:40
Hi, all

In the scene, I make an image by using large size of data. And I need to do some other operations on the drawed image. Take drawing lines by move mouse for example. As anybody know, the image will be repainted when the mouse moving and this make the speed very slow!! I want to use texture to solve the proble. But the texture size is limited as 64,128 or 256. My image size can't be limited.

1. How can I use texture but not limit?
2. Or is there any other way to speed up?
3. I use gluBuild2DMipmaps(), but the color of my drawed lines won't be correctly display. And why?

Does anybody can help me, thanks in advance!!

wysota
25th October 2006, 18:14
1. How can I use texture but not limit?
Round your image up to the power of two - if you have a 1000x1000 image, use a 1024x1024 texture.

2. Or is there any other way to speed up?
It depends what causes the slowdown.


3. I use gluBuild2DMipmaps(), but the color of my drawed lines won't be correctly display. And why?
Could you elaborate on that? What do you mean by "correctly displayed"?

BTW. This doesn't seem to be a Qt related issue.

showhand
27th October 2006, 02:51
Thanks for your reply.

The reason of drawing slowly is that my data size is very large. After making the image using these data, I need to do some other drawing operation. I want to draw lines by mouse(mouseMoveEvent) on the image. But you know, the image of large size of data should be always repainted, is it right? Both the image and lines use OpenGL commands.

Is there any way to speed up? Thank you!!!

wysota
27th October 2006, 11:01
Is there any way to speed up? Thank you!!!

Hard to say without seeing the code. Maybe you could optimise your GL code.

showhand
28th October 2006, 03:33
The code are following:

glWidget::glWidget (QWidget* parent):QGLWidget (parent)
{
//initialize some parametres
}

glWidget::~glWidget ()
{
}

void makeImage ()
{
//draw the graphics according to given data, using OpenGL API
}

void initializeGL()
{
}

void resizeGL(int width, int height)
{
}

void paintGL()
{
this->makeImage();
}
void mousePressEvent (QMouseEvent *e)
{
//get the start point of the line
}
void mouseMoveEvent (QMouseEvent *e)
{
//get the end point of the line
updateGL(); //this will always call the func paintGL() and call makeImage(). Move event will make the paintGL() be called high frequency.
}
void drawLineTo (QPoint start, QPoint end )
{
//draw line to link the start point and the end point, using OpenGL API
}

I only want to draw lines on the image which I make by large size of data. Mouse move event will make the paintGL() be called high frequency.
Would you please give some advices (or code best) to solve my problem? Thanks for your reply!!!

wysota
28th October 2006, 09:47
What's inside "makeImage()"?