Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
170 user(s) are online (146 user(s) are browsing Forums)

Members: 0
Guests: 170

more...

Support us!

Headlines

 
  Register To Post  

MiniGL 2.3 and glReadPixels( .... )
Quite a regular
Quite a regular


See User information
Hi,

With MiniGL 2.2 when I want to create an image directly by grabbing pixels on openGL screen, I used :
Quote:

glReadBuffer( GL_BACK );
glReadPixels( X, Y, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, NewPicture->Pixels );


but now, with miniGL 2.3 ... I only get an image entirely grey.
I tried to change glReadBuffer with GL_FRONT or remove the command to see it MiniGL automatically use the correct buffer ... but nothing worked.
Hans, I've seen you've made changes concerning buffer in MiniGL 2.3 ... What can I do to fix this issue ?

More to this, do you plan to add glBlendEquation() functions in MiniGL ?

EDIT:
Here is my grab image function :
Quote:

...
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D( 0.0, (float)BasicSetup.DisplayWIDTH, 0.0, (float)BasicSetup.DisplayHEIGHT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
INTERNAL_PrepareImageMode( NewIndex, ImageMode );
// glReadBuffer( GL_BACK );
glReadPixels( iX1, iY1, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, NewPicture->Pixels );
...


It worked with MiniGL 2.2 ... now my screen flash to grey when I use my image grabbing ...

Thank you.

Kindest Regards,
AmiDARK.


Edited by freddix on 2010/11/1 12:37:37
Edited by freddix on 2010/11/1 12:39:35
Edited by ssolie on 2010/11/1 21:14:45
All we have to decide is what to do with the time that is given to us.
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Home away from home
Home away from home


See User information
@freddix

Have a look at the gears2 demo. Pushing 'c' takes a snapshot; pushing 'w' displays it. I just tested this on my machine, and it works.

If you still can't get it to work in your software, see if you can replicate the problem in gears2.c, and send me the modified source.

Quote:
More to this, do you plan to add glBlendEquation() functions in MiniGL ?


I have no plans to add anything to MiniGL. MESA + Gallium 3D is the future for OpenGL on AmigaOS 4.x.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Quite a regular
Quite a regular


See User information
@Hans
Ok

I'll check this. Thank your for your answer.

I have another question, when I use entergamemode with a string for 32 bits ( like : 640x480:32@60 ) textures are dithered like in 16 bits format.
I don't have this issue in windowed mode.
Is this normal ?

EDIT : Gear2.c is not a solution for my problem because I must have the capability to get an area from the last rendered scene. It's something we call in BASIC as " Get Image X1, Y1, X2, Y2".
Gears2.c render the entire scene in an alternate buffer. It will be useful for me to create commands like "Set Camera To Image" ... but not for the "Get Image" :'(

Why did you force the buffer to be GL_FRONT instead of leaving it like it should in standard OpenGL 2.x ... ???

Kindest Regards,
AmiDARK


Edited by freddix on 2010/11/1 22:30:27
All we have to decide is what to do with the time that is given to us.
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Home away from home
Home away from home


See User information
@freddix

Quote:

freddix wrote:
@Hans
Ok

I'll check this. Thank your for your answer.

I have another question, when I use entergamemode with a string for 32 bits ( like : 640x480:32@60 ) textures are dithered like in 16 bits format.
I don't have this issue in windowed mode.
Is this normal ?


If you requested a 32-bit screenmode, then you should get a 32-bit screenmode. If not, something isn't working as it should.


EDIT : Gear2.c is not a solution for my problem because I must have the capability to get an area from the last rendered scene. It's something we call in BASIC as " Get Image X1, Y1, X2, Y2".
Gears2.c render the entire scene in an alternate buffer. It will be useful for me to create commands like "Set Camera To Image" ... but not for the "Get Image" :'([/quote]

Uh, where do you get that idea from? Gears2 renders to the window as all GLUT apps do, and then uses glReadPixels() to copy the rendered image in the front buffer to a separate buffer. If you push 'w' to display the copied image, and then 'c' multiple times, you will see that the displayed sub-image also gets copied into the new screenshot buffer. That wouldn't work if it were rendering the entire scene to an alternate buffer.

Quote:

Why did you force the buffer to be GL_FRONT instead of leaving it like it should in standard OpenGL 2.x ... ???


I didn't write gears2.c. I'm guessing that GL_FRONT was chosen so that it captures the currently displayed image, and not the one that was currently rendered.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Quite a regular
Quite a regular


See User information
@Hans
no no no
get a look at file gears2.C :

Here is the part of gears2.c that get the image and export it :
Quote:
if (showPic && buffer)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, 0.0, 2.0);

glRasterPos2i(10, 10);
glPixelZoom(0.4, 0.4);
glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
glPixelZoom(1.0, 1.0);

glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}


It don't use glReadPixels !!! it directly use glDrawPixels to render the ENTIRE scene in an alternate buffer (called buffer here) . this method is good for commands such like " Set Camera To Image" and image will be an alternate buffer ... but it'll trace the entire 3D scene.

What I want it use glReadPixels and IT DOES NO MORE WORK on MiniGL 2.3 ...

glReadPixels allow me to get a not the entire scene but a part of the scene in an alternate buffer.

Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Not too shy to talk
Not too shy to talk


See User information
@freddix

I think you are looking at the wrong part of gears2.c
maybe you must look at the screenshot function

Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Home away from home
Home away from home


See User information
@freddix
Quote:

t don't use glReadPixels !!! it directly use glDrawPixels to render the ENTIRE scene in an alternate buffer (called buffer here) .


Name

glDrawPixels 
write a block of pixels to the frame buffer

C Specification

void glDrawPixels
(    GLsizei ?    width,
?    
GLsizei ?    height,
?    
GLenum ?    format,
?    
GLenum ?    type,
?    const 
GLvoid * ?    data);


The last term is not a destination but a source!

Here's the code in gears2.c that reads the data from the screen. As you see it does indeed use glReadPixels.

void screenshot(void)
{
    
glPixelStorei(GL_PACK_ALIGNMENT1);
    
glReadBuffer(GL_FRONT);

    if (
buffer)
    
free(buffer);

    
buffer malloc(width height 4);
    if (
buffer)
    
glReadPixels(00widthheightGL_RGBGL_UNSIGNED_BYTEbuffer);
}


Gears2 is working fine for me here too, as is blender which does a lot of readpixeling (sic). This suggest there may be some additional factor that stopping your case from working.

Maybe you could give more details of your setup? Double or single buffering? With or without glut etc...

Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Quite a regular
Quite a regular


See User information
@broadblues
It's what I use and it don't work ...


NewPicture = AllocPicture32( Width, Height );
if ( NewPicture != NULL ){
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
glReadBuffer( GL_FRONT );
glReadPixels( iX1, iY1, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, NewPicture->Pixels );
}

There are checking before to be sure position and sizes are inside the display sizes.

When I use this, My 3D scene is no more displayed and I get screen flash black2grey2black2grey ...

All we have to decide is what to do with the time that is given to us.
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Home away from home
Home away from home


See User information
@freddix

Could you provide a simple yet working (or rather non working :-0) example (as source) so that we can see the whole thing and work out what might be wrong?

Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Home away from home
Home away from home


See User information
@freddix

Quote:

freddix wrote:
@broadblues
It's what I use and it don't work ...


There are two ways that you could try to track down why this no longer works in your code, but does work in gears2 and Blender:
- Modify gears2.c to match the settings that you use in your AmiDARK code (e.g., change the display settings to your settings, add whatever viewport/clipping code you're using)
- Create a copy of your AmiDARK code, and modify that to match what gears2.c is doing. Start by trying to copy the entire framebuffer, instead of a sub-region

Once you've figured out what works and what doesn't, then we can decide if there's a new bug in MiniGL 2.3 or not. For all we know the reason why it doesn't work for you any more could be because something missing was added, or a bug fixed.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: MiniGL 2.3 and glReadPixels( .... ) Hans ?
Quite a regular
Quite a regular


See User information
@Hans
I'll make all test next week-end ...

Thank you all for your answer.

All we have to decide is what to do with the time that is given to us.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 3 ( 0 members and 3 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project