Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Hello everyone,

I am trying to setup my C++ programs in XCode to use GLSL. But it seems that am unable to find either a decent description of what to do on the internet or to do the setup myself.

Any ideas or links on how to setup the XCode to use GLSL in the code?

Thanks!
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
You weren't clear as to whether you were interested in how to use GLSL or how to write a non Cocoa Carbon application that make use of GLSL.

Hopefully you'll find attached a totally uninteresting, but working, GLUT based Xcode project (thrown together just for you) that demonstrates the loading, compiling, attachment and rendering of an OpenGL Shader Language Vertex/Fragment pair used in the rendering of a simple blue line.

http://att.macrumors.com/attachment.php?attachmentid=205822&stc=1&d=1259909615
 

Attachments

  • GLSL_GPU.zip
    6.6 KB · Views: 1,220

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Well, I tried including GLEW into my code.
I am extending somebody else's code and that uses GLEW(but on XCode). So I need to include GLEW in my codes. How do I do that in Xcode? My code is in C++.

Thanks!

You weren't clear as to whether you were interested in how to use GLSL or how to write a non Cocoa Carbon application that make use of GLSL.

Hopefully you'll find attached a totally uninteresting, but working, GLUT based Xcode project (thrown together just for you) that demonstrates the loading, compiling, attachment and rendering of an OpenGL Shader Language Vertex/Fragment pair used in the rendering of a simple blue line.

http://att.macrumors.com/attachment.php?attachmentid=205822&stc=1&d=1259909615
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
Instead of your intended audience guessing what you want suppose you tell them.

What version of Xcode and Mac OS are you using and targeting?

Is the end product to be distributed or is it for your use only?
 

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
I am extremely sorry for the unclear reply previously. And it was incorrect too..

The code that I have already is for Windows - a visual studio project and it uses glew. Now installing glew on windows seems pretty straightforward, but setting up glew to be used in an XCode project does not seem to be as straightforward (or so it seems from my searches on the same). Is it possible to create a GLEW framework- if yes then how?

The code that I am writing is not to be distributed, but is for research purposes...

I am using Snow Leopard and Xcode 3.2.

I hope I am clearer now.

Thanks!

Instead of your intended audience guessing what you want suppose you tell them.

What version of Xcode and Mac OS are you using and targeting?

Is the end product to be distributed or is it for your use only?
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
Place the attached folder into your GLEW 1.5.1 folder. In it you'll find an Xcode project,'GLEW.xcodeproj', that will create a "GLEW.framework" suitable for inclusion within your own application bundle.

As provide it's setup to build a 10.5, and later, compatible 32-bit PowerPC/Intel, and 64 bit Intel framework. The framework includes the glew headers so you'll be able to use it like any other framework on the Mac.

You'll find instructions for copying and embedding a framework in the documentation available within the Xcode help system.

http://att.macrumors.com/attachment.php?attachmentid=205983&stc=1&d=1259995358
 

Attachments

  • Macintosh Xcode.zip
    6.3 KB · Views: 552

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Hello,

Well I tried your solution. I built the framework it seems correctly.
Previously I was getting a linker error, but now I get a runtime error of EXC_BAD_ACCESS.

I am including the Glew framework and including GLEW/glew.h in a project (without referencing any function from the glew.h). I have not embedded the framework, since I did not see the need of it (according to what appeared from the Xcode help).

Any clues on why is this happening?

Thanks

Place the attached folder into your GLEW 1.5.1 folder. In it you'll find an Xcode project,'GLEW.xcodeproj', that will create a "GLEW.framework" suitable for inclusion within your own application bundle.

As provide it's setup to build a 10.5, and later, compatible 32-bit PowerPC/Intel, and 64 bit Intel framework. The framework includes the glew headers so you'll be able to use it like any other framework on the Mac.

You'll find instructions for copying and embedding a framework in the documentation available within the Xcode help system.

http://att.macrumors.com/attachment.php?attachmentid=205983&stc=1&d=1259995358
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
I think you'll find that I setup the framework to be used as an embedded framework.

If you check the projects target "Build" settings and look at the "Deployment" section under "Installation Directory" you'll find "@executable_path/../Frameworks/"

Check out these two Apple Documents on developing and deploying frameworks.

<https://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html>
<https://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html>
 

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Well... I did all the embedding, I am still getting the EXC_BAD_ACCESS error. Now what can be the problem?
 

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Okay.. So here it goes. It is nothing but your original project, with an embedded GLEW framework.

The building process seems to be working fine, but there is a runtime error of EXC_BAD_ACCESS...
 

Attachments

  • GLSL_GPU 2.zip
    1.1 MB · Views: 258

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
OK, I could again do this for you but you wouldn't learn as much as doing it yourself.

And I could write it all out for you but I don't feel well and am lazy today so check out this tutorial video that demonstrates the creation of a framework and an application that will contain and use the framework.

It uses an earlier version of Xcode but you should be able to apply what's presented to what you're using.

<http://rentzsch.com/share/embeddingFrameworks.mov>

Please let us know how it turns out.
 

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
NO help.. It seems I am doing everything that was said in the video and in the xcode help, and still I am missing something, something because of which something which should not be accessed is being accessed. I do not want you to write out the whole code for me, but if you can please tell me what I am missing, that would do enough..
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
Within the project window double-cllick the generated "GLSL Demo" item. The Terminal should launch with some output. Whats displayed in the Terminal window?

EDIT:

I forgot that we're working with a 'Command Line Tool' type executable which is NOT an application bundle and thus doesn't have an "Frameworks" folder in which to embed the GLEW framework.

You'll need to modify the GLEW project changing the "Deployment" section under "Installation Directory" you'll find "@executable_path/../Frameworks/" to probably "@executable_path/". Followed by a modification of the "GLSL Demo" project to compy the glew.framework to the exec utable folder instead of the frameworks folder.

EDIT:

Well that won't work either. Let me look into it!
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
Where to go from here depends upon what kind of application you plan on building.

The example I first supplied was a more or less a test rig for to show loading, calling and rendering using OpenGL shaders. To do it quickly I posted a working example that used GLUT. GLUT is a CLI based application and not the traditional Mac OS bundled application.

What is it you plan on making.

If it is a traditional Mac bundled application then the framework path we been going down will not work with a CLI base application. You may find that the section titled "Testing Your Framework in Place" in the document <https://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html> to be useful.
 

kacharo

macrumors newbie
Original poster
Dec 1, 2009
12
0
Okay.. so got it working finally..

I am not embedding the framework now in my application. It is not needed actually. I simply copied the framework in /Library/Frameworks folder and used it in my application.
The segmentation fault was coming because I had not used glewInit() anywhere. After adding that function, it is working fine now (of course I have to still use other extensions).

I suppose I had got the embedding right once, but I misled myself into other things, and now am not even getting the embedding right somehow. Maybe use of DYLB thing would help, but will work on that at some other time...

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.