Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-05-2011, 04:37 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 30
Anonymous Username is on a distinguished road
Default 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.
Anonymous Username is offline   Reply With Quote
Old 11-07-2011, 07:24 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2011
Age: 25
Posts: 169
mer10 is on a distinguished road
Default

Quote:
Originally Posted by Anonymous Username View Post
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.
mer10 is online now   Reply With Quote
Old 11-17-2011, 06:14 PM   #3 (permalink)
Registered Member
 
Naughty_Ottsel's Avatar
 
Join Date: Aug 2008
Location: Gillingham, Dorset, UK
Age: 19
Posts: 218
Naughty_Ottsel is on a distinguished road
Send a message via MSN to Naughty_Ottsel
Default

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.
__________________
Follow me on Twitter
Naughty_Ottsel is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:00 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0