Opengl es advanced

Member
Posts: 39
Joined: 2008.09
Post: #1
I'm now having quite a success with opengl on iphone, but there are several issues, which I was unable to solve. I really spent quite some time digging the internet with no success.

1. I'd like to render only a portion of texture. Even the official guide recommends using texture atlases but it doesn't explain how!
(I'm using texture2d.h class from crashlander, and actually the whole game takes this example as a starting point. )
So far I found only one solution - setting glScissor before the draw every time for every surface, and setting back when done.
It seems allright, but won't there be perfomance issues?
I also want to render my bitmap font this way, and using this approach I would call it like 100-1000 times maximum each frame.

2. Why the coordinates in crashlander sample are reversed? I.e. I have to add y = 480-y; when blitting. I'm fine to do this, but now I'm using "landscape" mode, as my game would be landscape. I rotate the coordinates, but the scissor doesn't get rotated when I rotate the whole view (using glRotate). And I can't find the correct transformation for scissor rectangle to solve this.

3. I've seen quite some questions regarding this, but no proper answer. I want to get pixel data from surfaces. Actually, I only need alpha values. I wouldn't want linear "raw data", I only need the given pixel's data.
There's a glGetPixels function, but it supposed's to only work with the current render buffer. I tried blitting surface, reading pixels data without swapping buffers, so that user would not notice anything, but this didn't work for me.

It's allright if I have to create UIImage, but there's no proper way to get pixel data from it either. I only need a simple getPixel(x,y) function, which will return RGBA data of a given pixel.

PS: I see it became quite a sport telling about some NDA here, which most of the people never read anyway. Please feel free not to post this stuff here, just skip it.
Answering these questions however wouldn't break NDA anyway, since they are mostly about opengl es, not the iphone. If you still think you're breaking the NDA, please answer me privately.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
1) change the texture coordinates on your quad to select the portion of the texture you want
2) this seems very iPhone-specific and is probably under NDA
3) I don't know why glReadPixels wouldn't work for you...
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #3
jaguard Wrote:PS: I see it became quite a sport telling about some NDA here, which most of the people never read anyway. Please feel free not to post this stuff here, just skip it.
Answering these questions however wouldn't break NDA anyway, since they are mostly about opengl es, not the iphone. If you still think you're breaking the NDA, please answer me privately.

Unfortunately most of your post does violate the iPhone NDA. However some sections of your post are open to OpenGL ES only, the multiple references are in violation. The issue that comes up with the NDA is we are not allowed to discuss anything related to the iPhone even if that code works elsewhere as long as it is clearly stated it is for the iPhone.

Also this is the wrong attitude towards a legal contract that you signed. This forum will uphold the NDA whether you feel it is worthy of doing so or not. On a personal level I do not recommend signing contracts that you do not read.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #4
Your call to glOrthof is what defines your coordinate system.

Redefine your x, y, w, and h parameters for your call to glOrthof and you don't need to swap your y axis.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #5
waaaaaaay off-topic, but longjumper, what are you doing with one post? Assuming you are actually the real "longjumper", where have you been?
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #6
I've been around, where have YOU been! Wink

Always in #idevgames
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #7
longjumper Wrote:I've been around, where have YOU been! Wink

Always in #idevgames

Haha! Oh, right, I don't hang out in the chat rooms, hehe...

What the heck happened to your post count?
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #8
I had to recreate my account, but I have no idea why.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #9
longjumper Wrote:I had to recreate my account, but I have no idea why.

Ah, that explains it. [end OT]
Quote this message in a reply
Post Reply