GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 5:36 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jul 18, 2012 9:58 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
I'm trying to save in memory the output of a rotated texture. I want this to make the collision masks of my game engine(I'm creating this separated topic because someone could find it useful). I just did it programmatically, but use OpenGL for sure would be faster!

This is what I want, a two-dimensional array with byte(boolean would be better) values:
Image
The left is the original, the right is the result of rotating. Also, the mask is not printed on the screen, this process should be all hidden.

Does anyone know which function of the OpenGL library I shoud use and how?

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 10:04 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3807
Location: Ferriday, LA, US
FelipeFS wrote:
I'm trying to save in memory the output of a rotated texture. I want this to make the collision masks of my game engine(I'm creating this separated topic because someone could find it useful). I just did it programmatically, but use OpenGL for sure would be faster!

This is what I want, a two-dimensional array with byte(boolean would be better) values:
Image
The left is the original, the right is the result of rotating. Also, the mask is not printed on the screen, this process should be all hidden.

Does anyone know which function of the OpenGL library I shoud use and how?

The legacy command would be glRotate(), but note that as of OpenGL 3.0 it has been deprecated in favor of doing it via shader programs.

I don't have much experience in that regard, so that's about all I can tell you. I think maybe you could do it as a fragment shader (which, unless I am mistaken, handles the pixel/color rendering), and simply port standard rotation code to GLSL.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
PostPosted: Thu Jul 19, 2012 4:26 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Code:
The legacy command would be glRotate(), but note that as of OpenGL 3.0 it has been deprecated in favor of doing it via shader programs.

Good to know, because I'm using this function.

What I need is to save the resulting rotation inside a temporary 2D-array...
Something like:
Code:
byte **FRotatedCollisionMask;
FRotatedCollisionMask = glGetRotatedTexture(ID, AngleOfRotation);

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Thu Jul 19, 2012 11:43 am 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6711
Location: Oxford, Englandshire
I did some off screen rendering and grabbing like this in Amber. I can't get to the code at the moment (away from home) but I'll post something when I'm back in front of my home PC.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Fri Jul 20, 2012 10:26 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6711
Location: Oxford, Englandshire
Can't find the code at the moment, but a bit of digging tells me that glReadPixels was the function that I used.

The basic process is:
  • Render your transformed object to an offscreen buffer.
  • Use glReadPixels to get a copy of the buffer image in memory
  • Use the memory copy of the image to create a new texture or save it as a bitmap (not sure what your plan is at this stage)

In my case I rendered a texture with transparent areas over a solid colour to create unique textures at run-time.
http://www.codehead.co.uk/amber/screen17.html
I used the back buffer and cleared it once I'd grabbed a copy of the image. It never got flipped to the screen.

I'm not sure of glReadPixels status in the OpenGL3.0 world. It's a useful function, so it's probably been depreciated. :\

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Mon Jul 30, 2012 9:51 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Thank you! I'm justing rewriting my game engine to work with GLX(because I'm using Linux now), and I will test it.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group