PDA

View Full Version : Conflicting Types for '-(int)resizeFromLayer:(CAEAGLLayer *)layer' Warning




MachCUBED
Feb 14, 2011, 08:37 PM
Hello everyone, I just got a strange warning that I can't trace. here goes:
RingsState.h


#import <Foundation/Foundation.h>
#import "EAGLView.h"
#import "Sprite3D.h"
#import "Camera.h"
#import "Particle.h"
#import "Ring.h"
#import "ESRenderer.h"

@interface RingsState : EAGLView <UIAccelerometerDelegate, ESRenderer> {

EAGLContext *context;

GLint screenX;
GLint screenY;

...
}

...


RingsState.mm


...
- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer
//---warning: Conflicting Types for '-(int)resizeFromLayer:(CAEAGLLayer *)layer'

{
// Allocate color buffer backing based on the current layer size
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);

// ADDED DEPTH BEGIN
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, backingWidth, backingHeight);
// ADDED DEPTH END

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
return NO;
}

return YES;
}
...


ESRenderer.h


#import <QuartzCore/QuartzCore.h>

#import <OpenGLES/EAGL.h>
#import <OpenGLES/EAGLDrawable.h>

@protocol ESRenderer <NSObject>

- (void)render;
- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer;
//---warning: Previous Declaration of '-(BOOL)resizeFromLayer:(CAEAGLLayer *)layer'

@end


EAGLView.h is modified to inherit from a new class called GameState.


...
@interface EAGLView : GameState
{
...
}
...


GameState inherits from UIView, just as EAGLView used to.


...
@interface GameState : UIView {
GameStateManager* gsManager;
}
...


resizeFromLayer: is not defined with the return type int in any of my source files. What's going on?



RonC
Feb 14, 2011, 10:15 PM
I'm not an expert on this area, but it smells like a type mismatch. It's either the return value or the parameter list.

I suspect that BOOL and int are the same thing internally - int - so that's not the problem. Since this only has one parameter, it must be there.

Where is CAEAGLLayer defined? According to the documentation, it's in CAEAGLLayer.h. Does that get included in ESRenderer.h?

If it does, then I'm lost.

Ron C

MachCUBED
Feb 15, 2011, 03:47 PM
That's ok, the above problem turned out not to be the best way to solve my problem. This is all part of a huge graphics programming project. I'm basically trying to update the project at http://sourceforge.net/projects/iphonegamebook/files/iPhoneGameBook_CH5/ to ES 2.0 and its a huge mess. I basically did some code surgery using the OpenGL template, and the menu works fine. However, the game environment isn't being rendered because I haven't figured out how to pass all the relevant stuff to my ES2Renderer.

UPDATE: I took a totally new approach, using the OpenGL ES template. This time, I've made a subclass of ES2Renderer called PlayTest. I then initialized it as my ES2Renderer in my EAGLView class. Everything compiled just fine, but the object was not rendered on the screen. However, glClearColor worked as it should have. Thus, I now have the relevant classes on Pastebin.com:

ES2Renderer.h (http://pastebin.com/DDBQQx49)
ES2Renderer.m (http://pastebin.com/gv0YJZTS)
PlayTest.h (http://pastebin.com/Vka5qceb)
PlayTest.mm (http://pastebin.com/b9wnGm9N)
Ship.h (http://pastebin.com/tZ20zE19)
Ship.mm (http://pastebin.com/pwSGgveH)
Sprite3D.h (http://pastebin.com/nrCMZCNW)
Sprite3D.mm (http://pastebin.com/xpw3hGKz)
Model.h (http://pastebin.com/SDacpx7N)
Model.mm (http://pastebin.com/Lf0maLMk)
GLProgram.h (http://pastebin.com/PLqWacdY)
GLProgram.m (http://pastebin.com/Y1z8Nm56)

GameState protocol:


#import <UIKit/UIKit.h>


@protocol GameState

-(void) updateLoop;

@optional
-(BOOL) handleEvent:(void*)event;

@end


Please bear in mind that to compile this program, you need to download the PowerVR SDK (http://www.imgtec.com/powervr/insider/powervr-sdk.asp) from imgtec.com and copy the main source files to your project directory. Also, GLCommon.h is included in Jeff LaMarche's example project available from this blog post (http://iphonedevelopment.blogspot.com/2010/07/opengl-es-20-book-teaser.html).

Moderator, please change the topic of the thread to the title of this post.

MachCUBED
Feb 18, 2011, 02:50 PM
deleted due to code being moved to Pastebin.com

chown33
Feb 18, 2011, 03:41 PM
Put the code on pastebin (or a similar site), then paste the URL here.

If anyone is going to attempt to answer the question, they'll have to grab enough code to compile it themselves. Scrolling through multiple posts here isn't really helping them obtain the code, and it certainly isn't clarifying what the problem is.

I'm not even sure what the unanswered question is. Oh, wait, I see it buried in post #3. Or maybe not, since there's an Update there that ends by saying "this was fixed". So I still ain't sure what the question is.