OpenGL ES on the iPhone with C++? - c++

I'm trying to run some working C++ OpenGL code on the iPhone. So far, I managed to run an Objective-C/OpenGL ES example on the iPhone, and some Objective-C->plain C++ file ("hello world" output to the console).
But I can't any C++ OpenGL code. The exact problem is including the OpenGL library in the C++ file:
If I use the imports for Objective-C:
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
it will say at all gl* calls "Use of undeclared identifier 'gl*'".
If I use the imports I use in only C++:
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
It says OpenGL/OpenGL.h file not found (which I had expected, since OpenGL is full OpenGL library, not OpenGL ES).
So how do I use this C++ file?
Already searched:
http://www.hackint0sh.org/iphone-developer-exchange-9/iphone-sdk-can-i-use-c-opengl-38638.htm
iPhone - OpenGL using C++ tutorial/snippet
https://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html#//apple_ref/doc/uid/TP40008793-CH103-SW1
But I don't find how to use the C++ file.

Try:-
#include <OpenGLES/AEGL.h>

Related

"No matching function for call to ... " when using CGImage in C++ source

I'm porting a game written in C++ and OpenGL to run on iOS and OpenGL ES. The original version uses libpng and jpeglib for loading image data as sprites, and I want to replace these with CoreGraphics functions.
At the top of the C++ source file which contains the image loading functions, I've added the following:
#ifdef TOUCH_VERSION
#include <Foundation/Foundation.h>
#include <CoreGraphics/CoreGraphics.h>
#else
#include <png.h>
#include <jpeglib.h>
#endif
The TOUCH_VERSION compiler flag is defined (and is working, since it's not complaining about missing png.h and jpeglib.h). The problem I'm having is that it's not recognising any CGImage functions. For example:
CGDataProviderRef dataProvider = CGDataProviderCreateWithFilename(path);
results in the error ImageBuffer.cpp:166:42: No matching function for call to 'CGDataProviderCreateWithFilename'. Initially when I added the CF and CG includes, it autocompleted the CoreGraphics type and function names so I presumed the header import had worked, but when I built I got errors that NSString and other Objective C types were not defined. I added -x objective-c to the C flags, and -x objective-c++ to the C++ flags and it resolved this error, but then the error above appeared.
Thanks in advance for any help!
Ahh, sorted. I realised that the C++ function was using std::string as the CGDataProviderCreateWithFilename is expecting const char * as the filename. When I changed this to CGDataProviderCreateWithFilename(path.c_str()) it stopped complaining about the lack of a matching function.

Can't compile OpenGL project under OSX

There's an OpenGL project I have to work on for a course I am attending.
There were link errors due to GLEW. After some research, I found out that on OSX GLEW is not necessary.
I included following headers.
//#include "CL/cl_gl.h"
#include <OpenGL/glu.h>
#include <OpenGL/gl.h>
//#include <OpenGL/glext.h>
//#include <GLUT/glut.h>
But I am still getting compile errors of following kind:
use of undeclared identifier 'GL_TEXTURE_BUFFER_EXT'
glBindTexture(GL_TEXTURE_BUFFER_EXT, 0);
^
Where on OSX is the GLenum GL_TEXTURE_BUFFER_EXT resp. GL_TEXTURE_BUFFER defined?
The EXT variant will only be defined in glext.h or the headers which come or are generated by the various GL extenstion loaders. The actual GL_TEXTURE_BUFFER enum is defined in OpenGL/gl3.h. On OSX, modern GL is part of the OS, and you can directly link the modern GL funtions. However, I would still recommend using some GL loader, just for portability reasons.

Code-sense in embedXcode doesn't hightlight syntax for the library I've included

Code-sense mostly works-- all of the core Arduino types are hightlighted properly. But no types
referencing the FastLED library are.
My code compiles fine. And, syntax is hightlighted properly in FastLED.h
How can I make use of code-sense in xCode for Arduino libraries?
At the top of my .ino file, I do this
// Core library for code-sense
#include "Wiring.h"
#include "Arduino.h"
// Include application, user and local libraries
#include "LocalLibrary.h"
#include "FastLED.h"
I am running XCode 5.1 on OSX 10.9.2 with embedXcode+ (professional) release 136. I checked out the FastLED_2.1 branch, as master does not support Teensy 3.1, the board I am using.
Solved. It appears that NO libraries listed in USER_LIBS_LIST confer the benefits to code-sense to your main ino file. However, once I moved the FastLED from
/Users/justin/Documents/Arduino/Libraries
to
/Applications/Arduino.app/Contents/Resources/Java/libraries
and restarted XCode, everything works great.
It seems the table for libraries reached an overflow.
WARNING Overflow reached

OpenGL Linking error? Unresolved external glCreateShader()

I'm working on an OpenGL program to test out shaders and trying to compile them. However, the call to glCreateShader() (and other shader calls like glDeleteShader) give the following error:
(this error is from glCreateShader())
Error 3 error LNK2001: unresolved external symbol _pglCreateShader
I'm using Visual Studio 2012 and on windows 7. Got one of the latest nvidia cards including the latest drivers so can't be my OpenGL version.
I'm using the glTools header files for all the helper functions for the OpenGL Superbible 4th edition. Not sure if there is an error in using these files?
I'll post my includes in case this could be of any help as well.
#pragma once
#include <Windows.h>
// Basic C++ includes
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
using namespace std;
// OpenGL specific and GUI includes
#include "shared/gltools.h"
#include "shared/math3d.h"
#include <SOIL.h>
And linker options:
soil.lib;opengl32.lib;gltools.lib;
Oké, the problem has been solved thanks to the answers:
I edited my glTools.h to include 'gl/glew.h' instead of "glee.h", added a ;glew32.lib option to my linker and added glewInit() before entering the main loop. I've also added the GLEW libs,dlls and includes into the appropriate folder and all the functions work like they should! :)
Grab a copy of GLEW to handle extension loading.
Doing it by hand is...annoying.
On Windows, you use WGL, and when using WGL you can't just link against the GL functions directly. All the functions you get are these; you're supposed to dynamically grab the pointer to the GL entry point you want with wglGetProcAddress (as in here) before you can use them.
Basically, OpenGL on Windows is a PITA if you do the GL entrypoint function pointer loading manually. It's much easier to use a utility library to grab the pointers for you, such as GLEW.

Is there an equivalent to OpenAL <alc.h> in OpenSL ES?

I made a game in C++ with OpenGL ES rendering and using OpenAL for sound. To make it work on iPhone I could not use ALUT so I use only "al.h" and "alc.h".
I now try to build my game with the last Android SDK, that supports native applications and added sound support with OpenSL ES. (I believed OpenSL ES was to OpenAL what OpenGL ES is to OpenGL.)
I would like to know if by chance there is an equivalent to the "alc.h" file for OpenSL ES :
#if defined (MYAPP_IOS)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#elif defined (MYAPP_ANDROID)
#include <EGL/egl.h>
// alc.h equivalent for OpenSL ES here ?
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
If not, does anybody know a way to handle context and device in OpenSL ES in a similar way than OpenAL (or maybe a way to handle that in both without needing "alc.h" ?). The two errors Android ndk-build returns are of that type :
error: ISO C++ forbids declaration of 'ALCcontext' with no type
I found this on the site that seemed to have what you're looking for:
Android OpenAL?
Looks like someone was able to compile OpenAL for Android. Hopefully this can get you started!