agg render buffer and opengl

View: New views
5 Messages — Rating Filter:   Alert me  

agg render buffer and opengl

by Jim Crafton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm contemplating making an image editor of sorts, something that's
based on another library of mine that roughly duplicates Apple's
CoreImage on Windows. It uses OpenGL to draw images and GLSL for
filters that can added to an image for processing the pixels. What I'd
like to do is also use AGG to draw on the opengl image, which is just
a texture map. Any advice on how best to approach this? Is it just a
matter of creating a texture and dumping the contents of AGG's
render_buffer onto the texture bits?

Thanks!

Jim

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg render buffer and opengl

by Balakumar-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Possible. U can use the memory provided to agg::rendering_buffer. Make
pixel format for the render buffer and texture are same.

    unsigned long *buffer = new unsigned long[width*height*4];
    memset(buffer, 0, width * height* 4);

    agg::rendering_buffer  r_buf_(buffer, width, height, width * 4);

    //Do ur rendreing
   
    //Copy buffer to texture

Jim Crafton wrote:

> I'm contemplating making an image editor of sorts, something that's
> based on another library of mine that roughly duplicates Apple's
> CoreImage on Windows. It uses OpenGL to draw images and GLSL for
> filters that can added to an image for processing the pixels. What I'd
> like to do is also use AGG to draw on the opengl image, which is just
> a texture map. Any advice on how best to approach this? Is it just a
> matter of creating a texture and dumping the contents of AGG's
> render_buffer onto the texture bits?
>
> Thanks!
>
> Jim
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>
>  



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg render buffer and opengl

by Stephan Assmus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-11-03 at 19:16:25 [+0100], Jim Crafton <jim.crafton@...>
wrote:
> I'm contemplating making an image editor of sorts, something that's based
> on another library of mine that roughly duplicates Apple's CoreImage on
> Windows. It uses OpenGL to draw images and GLSL for filters that can
> added to an image for processing the pixels. What I'd like to do is also
> use AGG to draw on the opengl image, which is just a texture map. Any
> advice on how best to approach this? Is it just a matter of creating a
> texture and dumping the contents of AGG's render_buffer onto the texture
> bits?

Depending on your setup, it may be faster to render in main memory and copy
the buffer into the textture. But it could also be possible to attach the
agg::render_buffer directly to the texture buffer. I assume you need to
lock the OpenGL context during rendering. And this will involve
read-operations, which could very well be slow if the texture lives in
graphics memory. Another option may be to declare the texture such that the
graphics chip pulls it itself from main memory. That could be faster than
manually copying the buffer into the texture allocated in graphics memory.
For how to do this exactly, you will need to look into OpenGL
documentation, I am just assuming this is possible and advise from my own
experience in similar situations, but not with OpenGL in particular. (My
experience is with using old-school video overlays, but those live in video
memory too, so the situation is similar with regard to what is fast and
what is slow if you attach AGG to it.)

Best regards,
-Stephan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg render buffer and opengl

by Jim Crafton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the info!


Cheers

Jim

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg render buffer and opengl

by Pete Bannister :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Its easy enough - render in memory and give it to GL.
I dont think you have direct access to the hadrware buffer anyway.


Rough example:

std::vector<GLUint> textures_;
...
textures_.resize(tex_count);
glGenTextures(tex_count, &textures_[0]);

for (size_t n = 0; n < tex_count; ++n) {

glBindTexture(GL_TEXTURE_2D, textures_[n]);

std::vector<unsigned char> image(width * height * 3);
RenderMyImage(image, width, height);

        glTexImage2D(
            GL_TEXTURE_2D,                // GLenum target,
            0,                            // GLint level,
            3,                            // GLint internalformat,
            width,        // GLsizei width,
            height,        // GLsizei height,
            0,                            // GLint border,
            GL_RGB,                        // GLenum format,
            GL_UNSIGNED_BYTE,            // GLenum type,
            image            // const GLvoid *pixels
        );

}

Stephan Assmus wrote:
On 2009-11-03 at 19:16:25 [+0100], Jim Crafton jim.crafton@... 
wrote:
  
I'm contemplating making an image editor of sorts, something that's based 
on another library of mine that roughly duplicates Apple's CoreImage on 
Windows. It uses OpenGL to draw images and GLSL for filters that can 
added to an image for processing the pixels. What I'd like to do is also 
use AGG to draw on the opengl image, which is just a texture map. Any 
advice on how best to approach this? Is it just a matter of creating a 
texture and dumping the contents of AGG's render_buffer onto the texture 
bits?
    

Depending on your setup, it may be faster to render in main memory and copy 
the buffer into the textture. But it could also be possible to attach the 
agg::render_buffer directly to the texture buffer. I assume you need to 
lock the OpenGL context during rendering. And this will involve 
read-operations, which could very well be slow if the texture lives in 
graphics memory. Another option may be to declare the texture such that the 
graphics chip pulls it itself from main memory. That could be faster than 
manually copying the buffer into the texture allocated in graphics memory. 
For how to do this exactly, you will need to look into OpenGL 
documentation, I am just assuming this is possible and advise from my own 
experience in similar situations, but not with OpenGL in particular. (My 
experience is with using old-school video overlays, but those live in video 
memory too, so the situation is similar with regard to what is fast and 
what is slow if you attach AGG to it.)

Best regards,
-Stephan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

  

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general