Re: Basic OpenGL question
Re: Basic OpenGL question
- Subject: Re: Basic OpenGL question
- From: Darrin Cardani <email@hidden>
- Date: Thu, 18 Aug 2011 14:57:55 -0700
I should clarify that if you do what I suggest below, you don't need any temporary buffers. Just texture your quads with the input texture and they're automatically drawn to the output texture when you do any normal drawing.
Darrin
On Aug 18, 2011, at 2:44 PM, Darrin Cardani wrote:
>
> On Aug 18, 2011, at 11:31 AM, Martin Baker wrote:
>
>> Having passed the first hurdle and successfully managed to draw lines and rectangles (DH_GridX and DH_WideSafeX released yesterday) we move on to other things. In converting one of our FxScript filters, the aim is to write a filter that takes a 2 different areas from the input texture, copy those pixels to a buffer, then write the buffer back to a selected area of the the output texture.
>>
>> What I'm confused about is whether we should be using
>>
>> a) a new texture for the temporary buffer
>> b) a PBO with a renderbuffer
>> c) a PBO with a colorbuffer
>
> One way to do it would be to draw quads in the output and texture them with parts of the input. So lets say you have an input image that's 640x480 and your output is also 640x480 and you want to copy the area of the input that is from (25,25) to (50,50) to the output at, say, (100,100) and (200,200). You could do this (from memory, not tested) :
>
> // ... Put the usual OpenGL setup here (see the FxFilter template for more info) ...
> // Copy from (25,25) in the input to (100,100) in the output
> glBegin (GL_QUADS);
> // Lower Left
> glTexCoord2f (25,25);
> glVertex2f (100,100);
>
> // Lower Right
> glTexCoord2f (50,25);
> glVertex2f (125, 100);
>
> // Upper Right
> glTexCoord2f (50, 50);
> glVertex2f (125, 125);
>
> // Upper Left
> glTexCoord2f (25, 50);
> glVertex2f (100, 125);
> glEnd ();
>
> // Copy from (25,25) in the input to (200, 200) in the output
> glBegin (GL_QUADS);
> // Lower Left
> glTexCoord2f (25,25);
> glVertex2f (200,200);
>
> // Lower Right
> glTexCoord2f (50,25);
> glVertex2f (225, 200);
>
> // Upper Right
> glTexCoord2f (50, 50);
> glVertex2f (225, 225);
>
> // Upper Left
> glTexCoord2f (25, 50);
> glVertex2f (200, 225);
>
> glEnd();
>
> Does that help?
>
> Darrin
> --
> Darrin Cardani
> email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Pro-apps-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
Darrin Cardani
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden