[iPhone] Please help with OpenGL ES optimization
Hello!
Haven't asked for help in a while, but this time I am really without ideas.
Basically I am working on this 2D Game which should be released soon, but drawing performance is rather miserable (~25 Fps, playable but not enjoyable).
If there are some optimizations please give me a hint, Im a beginner with OpenGL
Here is my OpenGL Code:
[EAGLContext setCurrentContext:context];
glViewport(0, 0, backingWidth, backingHeight);
glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
glClear(GLCOLOR_BUFFERBIT);
Paddle* paddle = gModel.paddle;
////////////////DRAWING MAID///////////////////
ATTexture2D* maidTex = charImgA[gModel.mascotState];
if (!maidTex) {
//Lazy Loading
UIImage* img = [UIImage imageNamed:[NSString stringWithFormat:@"char-%d.png", gModel.mascotState, nil]];
maidTex = [[ATTexture2D alloc] initWithImage:img];
charImgA[gModel.mascotState] = maidTex;
int msImgWidth = 77;
int msImgHeight = 133;
CGRect maidRect = CGRectMake(paddle.box->center.x - (msImgWidth/2), 480-msImgHeight, msImgWidth, msImgHeight);
[maidTex drawInRect:maidRect];
////////////////DRAWING PADDLE///////////////////
CGRect rect = CGRectMake(paddle.box->getPoint(0).x,paddle.box->getPoint(0).y , paddle.box->extent.x * 2, paddle.box->extent.y * 2);
glPushMatrix();
glTranslatef(paddle.box->center.x, paddle.box->center.y, 0);
glRotatef(paddle.rotateState, 0, 0, 1);
glTranslatef(-paddle.box->center.x, -paddle.box->center.y, 0);
[paddleImg drawInRect:rect];
glPopMatrix();
////////////////DRAWING BLOCKS///////////////////
//We have 4 types of image pools
//Each type of block should take a picture from exactly one of the pools
//Here about 90 blocks loaded
NSArray* blockA = [gModel.blockMan getAllBlocks];
for (Block* block in blockA) {
CGRect rect = CGRectMake(block.box->getPoint(0).x,block.box->getPoint(0).y , block.box->extent.x * 2, block.box->extent.y * 2);
//Map the blocktype to the index of the pool->What pool should be used for this image?
int arrayIndex = blockTypeToImageAMappingA[block.type];
//Get the pool from the array
NSArray* imgPool = [blockImgAA objectAtIndex:arrayIndex];
//Get the array of the blockstates
//Choose one of the pictures from the pool to draw, this stays the same for the lifetime of the block, but is random
NSArray* imgA = [imgPool objectAtIndex:block.randID%[imgPool count]];
//Get the texture according to state of block
int index = MIN([imgA count]-1, block.state);
ATTexture2D* tex = [imgA objectAtIndex:index];
//block.blockImg = [imgA objectAtIndex:index];
//Draw the chosen texture
[tex drawInRect:rect];
////////////////DRAWING BALLS///////////////////
//About 10-20 should be supported
for (int i=0; i<[gModel.specialA count]; i++) {
Ball* ball = [gModel.specialA objectAtIndex:i];
ATTexture2D* tex = specialImgA [ball.specialType];
if (!tex) {
//Lazy Loading
NSString* str = [NSString stringWithFormat:@"special-%d%d.png", ball.specialType/10, ball.specialType%10, nil];
tex = [[ATTexture2D alloc] initWithImage:[UIImage imageNamed:str]];
specialImgA[ball.specialType] = tex;
[tex drawAtPoint:[ball getCenter]];
for (int i=0; i<[gModel.ballA count]; i++) {
Ball* ball = [gModel.ballA objectAtIndex:i];
[ballImg drawAtPoint:[ball getCenter]];
glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
[context presentRenderbuffer:GLRENDERBUFFEROES];
Comments: ATTexture is basically Apples Texture2D
Message was edited by: Max Ullinger
If rendering is slow, maybe it's because the textures aren't in a hardware-friendly format. CrashLanding's Texture2D class only supports RGBA8888, RGB565, and A8, i.e. no PVRTC textures. Another possibility is that you're rendering with alpha-testing/alpha-blending. The iPhone's GPU is supposed to be a lot faster if you draw as much geometry as you can without alpha-testing or alpha-blending -- it's part of their tile-based deferred rendering (TBDR).
If the CPU is slow, maybe it's all the Objective-C method calls. Each one of those is technically a search through the class hierarchy to find an appropriate method.
That's all I can see.
Similar Messages
-
I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.
If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it. Also, try changing the password associated with the Apple ID that you were using for iMessage.
-
How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore.
On the new computer, I am getting a message that my all purchases would be deleted if I sync it with new iTunes library.
Please help with proper steps, if any.Also see... these 2 Links...
Recovering your iTunes library from your iPod or iOS device
https://discussions.apple.com/docs/DOC-3991
Syncing to a New Computer...
https://discussions.apple.com/docs/DOC-3141 -
Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.
Hello Priyanks,
I found an article with steps you can take to troubleshoot issues with an iPhone not connecting to your car stereo:
iOS: Troubleshooting car stereo connections
http://support.apple.com/kb/TS3581
Thank you for using Apple Support Communities.
Best,
Sheila M. -
My instagram account won't link in with my iphone please help
my instagram account won't link in with my iphone please help... I can't upload any of my photos to instagram
Won't like to what? Are you saying you can't access your camera roll from the Instagram app? Check Settings>Privacy>Photos and make sure Instagram is set to "On". You can't use the share button from a photo in your camera roll to post a picture to Instagram if that's what you're trying to do. That's not a feature of iOS.
-
Hello everyone, im using iphone 4, my problem is that i cant update my iphone from 5.0.1 to 5.1.1 while using software update in settings on my iphone please help......
Downgrading to a previous version of iOS is not supported.
Sounds like your iPhone was hacked/modified/jailbroken to work
with wireless carrier other than the one it was purchased from. The
update has relocked it to the original carrier. Contact the original
carrier to see if they offer unlocking and if you qualify - only the
carrier to which the iPhone is locked can unlock it.
What does it say when you look at Settings=>General=>Carrier?
Be advised that the previous modifications to change from original carrier
to your local Carrier may have rendered the iPhone unable to be
officially unlocked. -
cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?
If you mean updae server
Update Server
Try:
- Powering off and then back on your router.
- iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
- Change the DNS to either Google's or Open DNS servers
Public DNS — Google Developers
OpenDNS IP Addresses
- For one user uninstalling/reinstalling iTunes resolved the problem
- Try on another computer/network
- Wait if it is an Apple problem
Otherwise what server are you talking about -
I would like to keep all my Music and photos on my mac but only top rated music and certain photos on my iPad and iPhone how do i stop iCloud from sending all to iPad and iPhone
please help
Regards
Steve DaveyIf you manually manage the device the you can remove the content from the PC after you have put it on the device. However this isn't the recommended way. At some point you'll probably need to restore it which involves wiping all the data. If you don't have all this data to hand then you'll have to try to recover it from a now problematic device first. It's much easier to sync with your library - yes you have two copies, but that's not a waste, it is prudent. As long as you have two copies you can afford to lose one knowing you have a backup. In practice I keep a complete backup of my library, in addition to the subsets of it that I can put on my devices.
tt2 -
I can't use my apple account in my Iphone please help me a message appear said"This ID has not used in the iTunes Store"
Hello, BaraaBa.
Thank you for visiting Apple Support Communities.
This sounds like your Apple ID has not yet been used with the iTunes Store. Here is an article that I would recommend going through when experiencing this issue.
Use your Apple ID with the iTunes Store
Open the latest version of iTunes.
Choose Store > Sign In.
Enter your Apple ID and password and click Sign In.
Click Review when asked to review your information.
Enter your billing information.
Click Continue after you enter your credit card and billing information. You can remove or edit your credit card information at any time. Learn more about updating your iTunes Store account information.
Using an existing Apple ID with the iTunes Store, Mac App Store, and iBooks Store
http://support.apple.com/kb/HT2589
Cheers,
Jason H. -
Hello my name is amer and i live in iran and i have one iphone lock.but my country limited us very very.and we are very poor and dont can pay money to unlock my iphone.please help me.thank you very math.my s/n iphone is: 012652000197750.my email iS: [email protected] please help me im very poor.im student and dont have money to keep on.
Only your cell service provider can unlock the phone. We cannot help you with that.
BTW, you should not provide information on your serial number or email address in an open forum. -
I bought used iPhone and on this iPhone I'm not able to make new account on i Cloud'. How can I use this iCloud's on used iPhone Please help me
When I logging there it told me that maximum no of iCloud's Account already activated on this iPhone.
Please help me how can I open new iCloud's account on this iPhone
Regard
Faiz khanSet up the account using a desktop or laptop, then sign
into that account on your iPhone.
I am not aware of any method around the restriction once
the maximum has been created on any individual iPhne. -
I have a bluetooth headset that only works in phone feature but not in itunes or apps on my iphone, please help.
It works fine through my macbook, can't find anything in settings on iphone to resolve problemThe headset has to have A2DP capability, which most (I believe) do not.
http://en.wikipedia.org/wiki/Bluetooth_profile -
Please help with the message I am receving on startup ""You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported."
I have read some of the replies in the Apple Support Communities, but as I am no techie, I would have no idea how I would implement that solution.
Please help with what I need to type, how, where, etc.
Many thanks
AppleSueIn HunterCreekI am afraid there is no solution.
PowerPC refers to the processing chip used by Apple before they transferred to Intel chips. They are very different, and applications written only for PPC Macs cannot work on a Mac running Lion.
You could contact the developers to see if they have an updated version in the pipeline. -
i just bought an airport express. i set it up and was able to be detected by my macbook, but i still cant connect wirelessly. the same goes when i tried my iphone. please help!
Is the status light green?
Your Airport device may be in Bridge Mode.
Airport Utility 6:
Open Airport Utility, select the Airport Express and click Edit. Navigate to the Network tab and change Router Mode to DHCP and NAT. Then click Update on the bottom right.
Airport Utility 5:
Open Airport Utility and click Manual Setup. Navigate to the Internet icon and change Connection Sharing to Share a Public IP Address. Then click Update on the bottom right. -
Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.
Adobe - Lightroom : For Macintosh
Hal
Maybe you are looking for
-
How to change the SID during system copy
This blog /people/johannes.heinrich/blog/2006/07/07/new-features-in-db2-udb-v9--part-3 (i.e. the "new feature of V9" in this group) only talk about the system copy without changing the SID. In reality, we often want to change the SID during the syst
-
Composition of business team in GRC Access control project
Hi Can I get any information about the composition of business team in a GRC access control project? What type of people form this team? Please provide some clarity on the role of business people in this type of projects. Regards Abhijeet
-
Hi, I am encountering the following errors trying to run the MRUA for our Metadata Repository Upgrade on an AIX 5.3 box: <mrua_runs> ../mrua/mrua.sh -oracle_home /u01/oracle/product/9.2.0.8 -oid_host ourhost.domain.com -oid_ssl_port 3130 Executing mr
-
i seem to have lost the abiity to use the spot visualization option in lightroom 5.2... anyone experiencing the same problem and do you have a solution?? thanks
-
Hi There, I am a student and currently working on a ASP ->MS ACCESS application. I have converted that application to JSP->MS ACCESS. Now I am planning to migrate to JSP->Oracle and want to buy a JDBC driver for the same. Can anybody guide me to buyi