PDA

View Full Version : glRasterPos2f && glDrawPixels && Windows Points



TEWarehouse
12-26-2012, 08:43 AM
Does anyone have an idea on what im missing here?

Im rastering to the window center point to make sure to stay within my clipping range so my image doesn't disappear when zooming/panning , etc.

All that works. Image never disappears.

The problem i am having has something to do with the WindowOrg point. When i pan or zoom, the image slowly is offset from my screen points. Note: Im plotting points manually ontop of the image. When I pan around the points are slowly offset more and more drastically the further i pan around. Im assuming its a conversion issue? Everything else in the program works fine.

Also, if i Raster to my 0,0 point everything works just fine in terms of zooming and panning until that 0,0 point is outside the clip range then of course the image disappears.



glRasterPos2f(m_pWindowOrg.x,m_pWindowOrg.y);

GLfloat x = (-m_image->width / 2) - (m_pWindowOrg.x);
GLfloat y = (m_image->height / 2) - (m_pWindowOrg.y);

glBitmap(NULL,NULL,m_image->width,m_image->height,m_fZoomScale * x,m_fZoomScale * y,NULL);

//Inver the image (the data coming from OpenCV is inverted)
glPixelZoom(m_fZoomScale * 1.0f,m_fZoomScale * -1.0f);

glDrawPixels(m_image->width, m_image->height, GL_RGB, GL_UNSIGNED_BYTE,m_image->imageData);

V-man
12-29-2012, 06:35 AM
The raster position is transformed by the modelview matrix. If you are applying some matrix to your modelview while panning and zooming, then it will effect glRasterPos2f. You might want to load an identity matrix, then call glRasterPos2f.

arekkusu
12-29-2012, 09:54 AM
Or call glWindowPos, to avoid exactly this problem.

TEWarehouse
01-04-2013, 11:30 AM
Well when i do that the program crashes and i get an Access Expectation error but, i really don't see any debug info...

glRasterPos2f(m_pWindowOrg.x,m_pWindowOrg.y); //WORKS!!!!

glWindowPos2f(m_pWindowOrg.x,m_pWindowOrg.y); //CRASHES!!!

Likewise

glRasterPos2f(0,0); //WORKS!!!!

glWindowPos2f(0,0); //CRASHES!!!

NO i am NOT calling both.... I just used above as an example. I either comment out one or the other.

TEWarehouse
01-04-2013, 01:34 PM
I have more info on this....

The exact error/crash is 0xC0000005 Access Violation

Doing some Google work its possible its a hardware problem. Not sure yet.

So, i copied my Release EXE file to another PC and i am not receiving the error but, the glWindowPos does not create the same output as glRasterPos. It seems to move the image to a different part of the screen.....

So any suggestions on what to do? glRaster works just find short of the image not lining up perfectly with everything else. See my original problem in first post. When i raster to the center of the view screen my image and my drawing are off just a little bit and the more i pan around, the greater the difference. I assumed it was a pixel / screen point problem and i played around there but still could not get it 100%.