Results 1 to 7 of 7

Thread: best way to store, blit, and render pixel data

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    best way to store, blit, and render pixel data

    ok so i finely got glew working so i have access to all these new(well new to me) features like FBO's PBO's and other stuff. i want to make a class in witch i can blit small images to a larger image and display that on the screen. i want to be able to have the class blit 1 things to another and then later have another class render this image quickly. how might i do that?

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: best way to store, blit, and render pixel data

    ok i think frame buffers will actually work well here, i didn't realize you could blit them like that. alright i have it working so that i can blit images to the screen but i can't get the alpha Chanel to blit.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: best way to store, blit, and render pixel data

    Are you sure both source FBO and on screen framebuffer have alpha channel ?

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: best way to store, blit, and render pixel data

    no, i know the on screen one dose but i don't know about the source frame buffer.

    here is how i set it up
    Code :
    glGenFramebuffers(1,&fbo);
    glBindFramebuffer(GL_FRAMEBUFFER,fbo);
    glGenRenderbuffers(1,&rbo);
    glBindRenderbuffer(GL_RENDERBUFFER,rbo);	glRenderbufferStorage(GL_RENDERBUFFER,GL_RGBA,zombie->getWidth(),zombie->getHeight());
    glBindRenderbuffer(GL_RENDERBUFFER,0);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER, rbo);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, zombie->tex, 0);
    glBindFramebuffer(GL_FRAMEBUFFER,0);

    and here is how i blit it to the screen

    Code :
    glBindFramebuffer(GL_READ_FRAMEBUFFER,fbo);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
    glBlitFramebuffer(0,0,zombie->getWidth(),zombie->getHeight(),0,0,+zombie->getHeight(),zombie->getHeight(),GL_COLOR_BUFFER_BIT,GL_LINEAR);

    edit: fbo is the frame buffer object and rbo is the render buffer object in case that wasn't clear.
    also i think the ortho is set up differently becuase when i blit it to (0,0) it blits it to (0,800) with the width going the wrong way. ill post a picture of what i mean if want

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: best way to store, blit, and render pixel data

    how do i check if my frame buffer supports an alpha channel?

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: best way to store, blit, and render pixel data

    When frame buffer is bound, you can glDrawPixels on it with specific alpha values, then glReadPixels that to check alpha values are the same.

    Do not forget to disable depth test, blending, stencil test etc.

  7. #7
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: best way to store, blit, and render pixel data

    ok so i used the following to try and display the data, did i do something wrong because it's not showing up anywhere?

    Code :
    glBindFramebuffer(GL_READ_FRAMEBUFFER,fbo);
            glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
            unsigned int* data = new unsigned int[(zombie->getWidth()+1)*(zombie->getHeight()+1)];
            glReadPixels(0,0,zombie->getWidth(),zombie->getHeight(),GL_RGBA,GL_UNSIGNED_INT_8_8_8_8,data);
    		glDrawPixels(zombie->getWidth(),zombie->getHeight(),GL_RGBA,GL_UNSIGNED_INT_8_8_8_8,data);
    		delete [] data;

Similar Threads

  1. Blit vs Render from texture
    By phil0stine in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 01-26-2018, 07:38 PM
  2. Replies: 2
    Last Post: 01-03-2018, 08:37 PM
  3. Extract and store opengl data?
    By HHHHG in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-10-2010, 05:45 AM
  4. store indices data in VBO
    By pango in forum OpenGL: Advanced Coding
    Replies: 24
    Last Post: 02-20-2008, 01:05 PM
  5. whats the best way to store animation data?
    By n3r0nix in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-06-2000, 05:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean