Render to texture example
Hi All
I'm trying to get some render to texture code working, but having problems at the moment. I have version that works using glCopyTexSubImage2D, but this is really pretty slow when running on hardware, and I realize I need to use glFramebufferTexture2DOES to get this to work efficiently.
I tried to follow the code from example in this presentation here:
http://www.khronos.org/developers/librar...amming.ppt
But I'm not having much luck...
I'm basing my code on the simple OpenGLES example, and I'm making a new framebuffer object with the texture attached, and trying to render to it, then switching back to the framebuffer attached to the render buffer and attempt to render the texture again.
Does anyone have this working in a simplified example?
I'm trying to get some render to texture code working, but having problems at the moment. I have version that works using glCopyTexSubImage2D, but this is really pretty slow when running on hardware, and I realize I need to use glFramebufferTexture2DOES to get this to work efficiently.
I tried to follow the code from example in this presentation here:
http://www.khronos.org/developers/librar...amming.ppt
But I'm not having much luck...
I'm basing my code on the simple OpenGLES example, and I'm making a new framebuffer object with the texture attached, and trying to render to it, then switching back to the framebuffer attached to the render buffer and attempt to render the texture again.
Does anyone have this working in a simplified example?
It sounds like you're on the right track. I posted something on this in the Apple iPhone developer forums:
https://devforums.apple.com/message/23282#23282
I hope that helps (and no-one minds me linking to it from here?).
https://devforums.apple.com/message/23282#23282
I hope that helps (and no-one minds me linking to it from here?).
Flash!
hi
not everyone has the program.. can u copy your example somehow?
thanks
alex
not everyone has the program.. can u copy your example somehow?
thanks
alex
godexsoft Wrote:not everyone has the program
Everyone who's deploying their application to a device and/or submitting to the app store does. It's required if you want to do anything beyond the simulator.
ThemsAllTook Wrote:Everyone who's deploying their application to a device and/or submitting to the app store does. It's required if you want to do anything beyond the simulator.
No it's not. I don't have the program and still I do deploy my application using scp/ldid. I do it in the same way which is used by lots of people. Besides, I bet you heard something about Installer.app, Cydia and the toolchain for linux.
godexsoft Wrote:No it's not. I don't have the program and still I do deploy my application using scp/ldid. I do it in the same way which is used by lots of people. Besides, I bet you heard something about Installer.app, Cydia and the toolchain for linux.
Those aren't officially supported though and are at the best hacks, so any code or techniques modified to suit them is likely to be inaccurate for proper iPhone development and as such not suitable for this forum.
godexsoft Wrote:hi
not everyone has the program.. can u copy your example somehow?
thanks
alex
I didn't realise you had to have paid for the dev program to see the forum. I've copied my post for anyone who hasn't - it should still work on the simulator after all:
The procedure is basically to create a texture, create an FBO, bind the texture to this, bind the FBO, render to it as you would normally render to the screen, rebind the screen, bind the texture you attached to the FBO, then render your quad.
Create FBO and FBO texture before your rendering loop:
Code:
// generate texture
glGenTextures(1, &m_uFBOTexture);
glBindTexture(GL_TEXTURE_2D, m_uFBOTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FBODimension, FBODimension, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); // check if this is right
// generate FBO
glGenFramebuffersOES(1, &m_uFBO);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_uFBO);
// associate texture with FBO
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, m_uFBOTexture, 0);
// clear texture bind
glBindTexture(GL_TEXTURE_2D,0);
// check if it worked (probably worth doing :) )
GLuint status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (status != GL_FRAMEBUFFER_COMPLETE_OES)
{
// didn't work
}Then in your loop render to the FBO:
Code:
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_uFBO);
// set the viewport as the FBO won't be the same dimension as the screen
glViewport(0, 0, FBODimension, FBODimension);
// render...Now render the FBO texture and everything else to the screen:
Code:
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1); // 1 is the screen on iPhone for some reason
glViewport(0, 0, 320, 480);
// use your rendered texture
glBindTexture(GL_TEXTURE_2d, m_uFBOTexture)
// render...Rinse and repeat. I hope this helps.
Flash!
Zwilnik Wrote:Those aren't officially supported though and are at the best hacks, so any code or techniques modified to suit them is likely to be inaccurate for proper iPhone development and as such not suitable for this forum.
Miss again. I do realize that this might be not suitable for this forum, but however I must say that my game can be perfectly built using Xcode and the official SDK as well as from linux with the toolchain and by using my custom Makefile. It works and the result is _EXACTLY_ the same. Just for information though.
I suppose we better stop this "holy war" right here :-) I promise I will buy a license from apple if I feel like I have a game which can be released to the appstore to get some money out of it. I find it a useless spending right now.
BR,
Alex
Thanks a lot, Flash!
godexsoft Wrote:Miss again. I do realize that this might be not suitable for this forum, but however I must say that my game can be perfectly built using Xcode and the official SDK as well as from linux with the toolchain and by using my custom Makefile. It works and the result is _EXACTLY_ the same. Just for information though.
I suppose we better stop this "holy war" right here :-) I promise I will buy a license from apple if I feel like I have a game which can be released to the appstore to get some money out of it. I find it a useless spending right now.
BR,
Alex
There's no holy war about it. Your hack might work this time, but you could be wasting devs a lot of time by posting innacurate information about something that doesn't quite work that way in the official SDK.
Combine that with the license agreement devs sign that says they will only use the official SDK calls and you can see where this conflicts with helping proper iPhone devs.
You don't need to spend *any* money to do iPhone development using the proper SDK. Only to install on a device. So you could just work in the proper environment until your game is working well on the simulator and register before you do final testing.
Zwilnik Wrote:. So you could just work in the proper environment until your game is working well on the simulator and register before you do final testing.
Only to discover it's utterly unplayable
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Najdorf Wrote:Only to discover it's utterly unplayable
yup. although probably a lot easier to fix than having to rewrite because you've used a feature that doesn't exist or isn't allowed in the official SDK.
For the sake of $99, which you should be able to make back with the worst of apps, there's no real point in using broken software.
Zwilnik Wrote:There's no holy war about it. Your hack might work this time, but you could be wasting devs a lot of time by posting innacurate information about something that doesn't quite work that way in the official SDK.
Combine that with the license agreement devs sign that says they will only use the official SDK calls and you can see where this conflicts with helping proper iPhone devs.
You don't need to spend *any* money to do iPhone development using the proper SDK. Only to install on a device. So you could just work in the proper environment until your game is working well on the simulator and register before you do final testing.
Accord. That's why I always try to keep my code synced with both platforms. That's a pain.. but I don't have a mac at home so I can't use Xcode/SDK there... otherwise I probably wont even try to get it working under linux :-)
99$ is not that much, I must agree again. However purchasing a mac (even the best price crap machine) is way too much off the path for me at the current status of things :-)
Regards,
Alex
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| iPad,render to texture, low framerate | ldynasa | 0 | 2,171 |
Nov 13, 2010 12:34 AM Last Post: ldynasa |
|
| Render to texture failing | headkaze | 7 | 5,748 |
Sep 1, 2010 09:47 PM Last Post: headkaze |
|
| Performance problems with render to texture method | mbw234 | 6 | 4,304 |
Jun 25, 2010 01:47 AM Last Post: Jamie W |
|
| Render to texture performance | iPhoneGG | 2 | 3,315 |
May 18, 2009 03:31 PM Last Post: ShiftZ |
|
| Drawing Blur (Render to Texture) | Macias | 3 | 5,819 |
Feb 9, 2009 08:04 AM Last Post: munkidesign |
|

