11-05-2011, 04:37 PM
#1 (permalink )
Registered Member
Join Date: Nov 2011
Posts: 30
12 errors with open gl I've made
A while back I bought Iphone game development for dummies without reading reviews for it, apparently its crap. I wrote the code they used in the book and added everything to the header file so that's not the problem. I'm getting errors like
"_glGenFramebuffers", referenced from:
-[OpenGL prepareOpenGl] in OpenGl.o
symbol(s) not found
thats one of the twelve, all the errors end with "referenced" from.
heres the full code.
Opengl.h
Code:
#import <UIKit/UIKit.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/es2/glext.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenGl : UIView {
EAGLContext* context;
GLuint framebuffer;
GLuint colorRenderBuffer;
GLuint depthBuffer;
}
Opengl.m
Code:
#import "OpenGl.h"
@implementation OpenGl
- (void) prepareOpenGL {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
[EAGLContext setCurrentContext:context];
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenRenderbuffers(1, &colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable: (CAEAGLLayer*) self.layer];
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderBuffer);
GLint height, width;
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
glGenRenderbuffers(1, &depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
NSLog (@"failed to create a complete render buffer!");
}
}
- (void) awakeFromNib {
[self prepareOpenGL];
[self render];
}
-(void) render {
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glViewport(0, 0, self.bounds.size.width, self.bounds.size.height);
glClearColor(0.5, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT) ;
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context presentRenderbuffer:GL_RENDERBUFFER];
}
@end
I really don't know what I'm doing here :/
Last edited by Anonymous Username; 11-05-2011 at 05:00 PM .
11-07-2011, 07:24 PM
#2 (permalink )
Registered Member
Join Date: Oct 2011
Age: 25
Posts: 169
Quote:
Originally Posted by
Anonymous Username
A while back I bought Iphone game development for dummies without reading reviews for it, apparently its crap. I wrote the code they used in the book and added everything to the header file so that's not the problem. I'm getting errors like
"_glGenFramebuffers", referenced from:
-[OpenGL prepareOpenGl] in OpenGl.o
symbol(s) not found
thats one of the twelve, all the errors end with "referenced" from.
heres the full code.
Opengl.h
Code:
#import <UIKit/UIKit.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/es2/glext.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenGl : UIView {
EAGLContext* context;
GLuint framebuffer;
GLuint colorRenderBuffer;
GLuint depthBuffer;
}
Opengl.m
Code:
#import "OpenGl.h"
@implementation OpenGl
- (void) prepareOpenGL {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
[EAGLContext setCurrentContext:context];
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenRenderbuffers(1, &colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable: (CAEAGLLayer*) self.layer];
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderBuffer);
GLint height, width;
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
glGenRenderbuffers(1, &depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
NSLog (@"failed to create a complete render buffer!");
}
}
- (void) awakeFromNib {
[self prepareOpenGL];
[self render];
}
-(void) render {
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glViewport(0, 0, self.bounds.size.width, self.bounds.size.height);
glClearColor(0.5, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT) ;
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context presentRenderbuffer:GL_RENDERBUFFER];
}
@end
I really don't know what I'm doing here :/
Do you have xcode 4.2? I'd recommend starting a new OpenGL Game project if you do as it will lay out all the basic code framework you have there and provide you a decent starting place.
11-17-2011, 06:14 PM
#3 (permalink )
Registered Member
Join Date: Aug 2008
Location: Gillingham, Dorset, UK
Age: 19
Posts: 218
May seem a bit silly but have you added the OpenGL framework to the project. Easily forgotten and can cause a lot of issues and errors.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 378
10 members and 368 guests
apatsufas , comicool , Creativ , Dalia , dansparrow , LunarMoon , mer10 , Murphy , pbart , Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55