![]() |
|
|
|
Thread Tools | Display Modes |
|
(#1)
|
|
|
Member
Posts: 2
Join Date: 2009.02
Location: London, UK
|
Render to texture example -
2009.02.09, 09:59 AM
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/li...rogramming.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? |
|
|
|
|
(#2)
|
|
|
Member
Posts: 26
Join Date: 2006.04
Location: Great Britain
|
2009.02.09, 10:55 AM
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?). |
|
|
|
|
(#3)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2009.02.09, 03:14 PM
hi
not everyone has the program.. can u copy your example somehow? thanks alex |
|
|
|
|
(#4)
|
|
|
Moderator
Posts: 1,501
Join Date: 2003.10
Location: Virginia, USA
|
2009.02.09, 03:25 PM
|
|
|
|
|
(#5)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2009.02.10, 05:26 AM
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.
|
|
|
|
|
(#6)
|
|
|
Moderator
Posts: 417
Join Date: 2002.04
Location: Newcastle, UK
|
2009.02.10, 07:33 AM
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.
|
|
|
|
|
(#7)
|
||
|
Member
Posts: 26
Join Date: 2006.04
Location: Great Britain
|
2009.02.11, 07:17 AM
Quote:
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...
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...
|
|
|
|
|
|
(#8)
|
||
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2009.02.11, 08:23 AM
Quote:
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 |
|
|
|
|
|
(#9)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2009.02.11, 08:29 AM
Thanks a lot, Flash!
|
|
|
|
|
(#10)
|
||
|
Moderator
Posts: 417
Join Date: 2002.04
Location: Newcastle, UK
|
2009.02.11, 12:48 PM
Quote:
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. |
|
|
|
|
|
(#11)
|
|
|
Member
Posts: 1,059
Join Date: 2003.01
Location: Italy
|
2009.02.11, 05:09 PM
Only to discover it's utterly unplayable :P
|
|
|
|
|
(#12)
|
|
|
Moderator
Posts: 417
Join Date: 2002.04
Location: Newcastle, UK
|
2009.02.11, 09:17 PM
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. |
|
|
|
|
(#13)
|
||
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2009.02.12, 05:54 AM
Quote:
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 |
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|