Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Blitting to displaybuffer?


Blitting to displaybuffer?

Postby sourcerer » Jul 5, 2009 @ 8:01am

Hi,
I read on 30daygame the following text:

"Edgelib does allow blitting to and from the display buffer which makes things a lot easier - if we are to do any sequel games it’s essential the engine is as perfect as it can be to avoid major issues later on."

This is something I've been looking for, could you provide more info, ie what functions I should look into, or is there a sample that does this?

Also what speeds could I expect on a 2G doing a full screen blit? (I know about dirty rectangles, but full screen is a good indicator for me)

Thanks,
Kaj
sourcerer
pm Member
 
Posts: 1
Joined: Jul 5, 2009 @ 7:55am


Postby edge » Jul 6, 2009 @ 1:56pm

Hi,

You can lock and blit to/from the backbuffer, but not using OpenGL ES isn't recommended (OpenGL ES is faster). Your FPS count will probably be in the 25-30fps range.

If you do use OpenGL ES, your game will be able to run at 60fps. If you want to capture certain parts you've already rendered in OpenGL ES, we recommend using render-to-texture.

An example on how to create and release a renderbuffer:
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
//Create framebuffer and renderbuffer
GLuint fbo, renderbuffer;
unsigned long width = 64, height = 64;
glGenFramebuffersOES(1, &fbo);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
glGenRenderbuffersOES(1, &renderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, renderbuffer);

//Restore rendering
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);


//Cleanup
glDeleteRenderbuffersOES(1, &renderbuffer);
glDeleteFramebuffersOES(1, &fbo);
17 lines; 2 keywds; 7 nums; 50 ops; 0 strs; 3 coms    Syntactic Coloring v0.4 - Dan East  


And an example on how to create a rendertexture, linked to the renderbuffer:
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
unsigned int texid = 0;
GLenum glformat = GL_RGB, gltype = GL_UNSIGNED_BYTE;
glGenTextures(1, &texid);
if (texid > 0)
{
    unsigned long width = 64, height = 64;
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
    glBindTexture(GL_TEXTURE_2D, texid);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, glformat, gltype, NULL);
    glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, texid, 0);
    GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);
    if (status != GL_FRAMEBUFFER_COMPLETE_OES)
        glDeleteTextures(1, &texid);
}
return(texid);
18 lines; 7 keywds; 10 nums; 76 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


And finally how to set/clear this texture as a rendertexture:
Code: Select all









//Set render texture
unsigned long rendertexwidth = 64, rendertexheight = 64;
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
glViewport(0, 0, rendertexwidth, rendertexheight);

//Clear render texture
unsigned long displaywidth = 320, displayheight = 480;
glViewport(0, 0, displaywidth, displayheight);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);
9 lines; 4 keywds; 9 nums; 28 ops; 0 strs; 2 coms    Syntactic Coloring v0.4 - Dan East  
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby jrhee » Oct 14, 2009 @ 3:34am

Hi, would it be possible to use an E2DSurface uploaded to OpenGL in the below example? For example would it be possible to retrieve the texture ID of an uploaded E2DSurface and supply it to the fbo?
jrhee
pm Member
 
Posts: 26
Joined: Apr 7, 2008 @ 4:28pm


Postby edge » Oct 15, 2009 @ 1:13pm

Hi,

You can't access the surface texture ID directly, however you could bind it manually and retrieve the texture ID from OpenGL using glGetIntegerv and GL_TEXTURE_BINDING_2D.

I'm not sure if it works the way you expect though.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron