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

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!

Related

UE5 OpenCV: Can’t grab VideoCapture

I’m trying to read camera input using the built-in OpenCV library in UE5 but no matter what I do, I can’t seem to make cv::VideoCapture.read() return anything. cv::VideoCapture.grab() also returns false every time.
It works fine on the same machine with regular C++ with OpenCV 4.6.0 and the VideoCapture is definitely open and the camera turns on as expected.
Is there something about Unreal’s built-in implementation I need to know about? (Other than it used OpenCV 4.5.5). I can’t seem to find any info online about this.
This is what my header files look like:
#pragma once
#include "PreOpenCVHeaders.h"
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc.hpp>
#include "PostOpenCVHeaders.h"
#include "CameraReader.generated.h"
And my Plugin’s Build file:
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"OpenCVHelper",
"OpenCV",
// ... add other public dependencies that you statically link with here ...
}
);
Using Windows 11 with Kinect 2.0.
I thought maybe I was missing some OpenCV DLLs since I can only find a custom Unreal version of the OpenCV World DLL, so I tried overriding the default OpenCV plugin and adding the FFMPEG and MSMF DLLs myself but that didn’t change anything.
Edit: After many attempted building OpenCV from source, I only managed to get GStreamer and FFMPEG to work.
The OpenCV library that comes with UE5 is not built with FFmpeg or with the Media Foundation library, so it cannot read video from a file or from a camera.
You can try to build your own version of OpenCV with FFmpeg or Media Foundation support and use that instead of the one that comes with UE5.

"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.

OpenGL ES on the iPhone with 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>

Windows/opengl glext.h build issue

So I'm trying to bring a c++ project using Qt and OpenGL written and compiled on a Linux machine over to my Windows 7 machine at home, but I'm running into some difficulty. First I learned that some gl things (like GL_TEXTURE0) were no longer defined because gl.h doesn't define them for windows. Also, the glext.h that I have does not define some functions like glActiveTexture. Both of these issues I found could be solved by bringing in a newer glext.h.
My most immediate issue seems to be that I'm not bringing it in correctly. If I do:
#define GL_GLEXT_LEGACY //should prevent old glext.h from being included
#define GL_GLEXT_PROTOTYPES //should make glActiveTexture be defined
#include <qgl.h>
#include "glext.h" //local up-to-date glext.h
#include <QGLShaderProgram>
then make tells me that I have undefined references to glActiveTexture. If I include QGLShaderProgram before glext.h, then I still have that problem, but make also warns me that I am redefining quite a few things that are defined in both QGLShaderProgram and glext, so I know the latter file is being included. Any help would really be appreciated.
You are on a right path, but like Nick Meyer wrote, you need to get pointers to the functions at runtime.
There is a nice and clean example already in Qt installation directory, at least since 4.6. Check "Boxes" from "demos"-directory. There is glextensions.h/cpp that takes care of those required functions in Qt-way, using Qt's QGLContext etc.
If you're lazy like me, just hop over to
http://glew.sourceforge.net
and use that, no need to fiddle around with different header files and manually retrieving function pointers. It's as simple as
/* in every source file using OpenGL */
#include <GL/glew.h>
and
/* for each OpenGL context */
if( createGLContext(...) == SUCCESSFULL )
glewInit()
If you're using Qt you should probably use qmake - and just add
QT += opengl
to your qmake project file.