|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| glDrawPixels |
|
![]() Flash3r Member since: 1/27/2005 From: London, Canada |
||||
|
|
||||
| Here is some background before my question. I am calculating and drawing a mandelbrot fractal in orthographic projection mode. My problem was that if I created a window and drew the fractal image at a ratio that was a multiple of 100 and ratio 1:1 (i.e. 600x600) the image would be fine, but if I drew it as other then that (i.e. 600x700 or 601x601) it would be completly corrupted. Also the fractal would be oriented wrong. It would be pointing down rather then to the left. I solved this by switching from using glDrawPixels() to just drawing each pixel one at a time: glBegin(GL_POINTS) for all points glColor3f glVertex2f glEnd Any reason why glDrawPixels was doing such weird things? |
||||
|
||||
![]() Enigma Member since: 8/17/2001 From: Horsham, United Kingdom |
||||
|
|
||||
| I would suspect that this problem is due to a DWORD alignment requirement on each row of pixels. That means that glDrawPixels probably requires each row of pixels to start at an address which is a multiple of 4 bytes. If you provide RGB byte data then a row of 100 pixels will result in each row taking up 300 bytes, which is a multiple of 4, so the next row will begin on a 4 byte boundary and everything will be OK. If however your rows are 101 pixels wide then each row will take up 303 bytes, which is not a multiple of 4. glDrawPixels will then skip a byte and source the next row beginning at the next 4 byte boundary, in this case ignoring the first red byte of the second row and treating the green byte as red, the blue byte and green and the red byte for the second pixel of the second row as the blue byte for the first pixel of the second row, etc. This results in the colours being corrupted on two out of three lines and the entire image being skewed slightly. Enigma |
||||
|
||||
![]() jaba Member since: 2/22/2003 From: Spain |
||||
|
|
||||
| I think this can be a good solution: You can create a 1024x1024 texture and then update a portion of this (600x700)with glTexSubImage2D. To visualize create a quad textured with it. Very easy and faster!! I use this to visualize the video from webcams |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| I have a lamer-level question with Borland Cpp 6.0 and glDrawPixel the result of executing this function is always "floating point operation error"... I don't get why... All other functions seems to work perfectly Code example: ghDC = GetDC(Form1->WindowHandle); if (!bSetupPixelFormat(ghDC)) Close(); ghRC = wglCreateContext(ghDC); wglMakeCurrent(ghDC, ghRC); glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_COLOR_MATERIAL); glClearDepth (1.0f); glDepthFunc (GL_LEQUAL); glEnable(GL_DEPTH_TEST); glShadeModel (GL_SMOOTH); glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); char * a="dsfsdfsdfsdgkndfbgjksdfgjkdfhgjkdfhgjksdfhgjksdfhgjkdsfhgjkdfgh";// :) glDrawPixels(4,4,GL_RGB,GL_UNSIGNED_BYTE,a);// crushes here :) glFlush(); SwapBuffers(ghDC); |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|