Hello, I’m trying to “port” a class that I built for an Android application.
The application I’m working on is making augmented reality but the code logic is structured by PVRTools. I did not use the shell and was abble to get a skeleton working:
<br />
/*<br />
* PVRManager.h<br />
*/<br />
<br />
#ifndef PVRMANAGER_H_<br />
#define PVRMANAGER_H_<br />
<br />
#include <unistd.h><br />
<br />
#include <QCAR/Matrices.h><br />
<br />
#include <GLES2/gl2.h><br />
#include <GLES2/gl2ext.h><br />
<br />
#include <OGLES2Tools.h><br />
<br />
<br />
class PVRManager {<br />
private:<br />
GLuint baseTexture;<br />
GLuint bloomTexture;<br />
GLuint blurTextures[2];<br />
<br />
GLuint lightVertShader;<br />
GLuint lightFragShader;<br />
struct {<br />
GLuint id;<br />
GLuint MVPMatrixLoc;<br />
GLuint lightDirLoc;<br />
} lightShaderPgm;<br />
<br />
GLuint preBloomVertShader;<br />
GLuint preBloomFragShader;<br />
struct {<br />
GLuint id;<br />
GLuint MVPMatrixLoc;<br />
GLuint lightDirLoc;<br />
GLuint bloomIntensity;<br />
} preBloomShaderPgm;<br />
<br />
GLuint postBloomVertShader;<br />
GLuint postBloomFragShader;<br />
struct {<br />
GLuint id;<br />
} postBloomShaderPgm;<br />
<br />
GLuint blurFragShader;<br />
GLuint blurVertShader;<br />
struct {<br />
GLuint id;<br />
GLuint texelOffsetX;<br />
GLuint texelOffsetY;<br />
} blurShaderPgm;<br />
<br />
float touchX;<br />
float touchY;<br />
<br />
float texelOffset;<br />
<br />
float nowRot;<br />
float lastRot;<br />
float diffRot;<br />
<br />
CPVRTModelPOD podScene;<br />
<br />
GLint baseFBO;<br />
GLuint blurFBOs[2];<br />
GLuint depthBuffer;<br />
<br />
GLuint *vbo;<br />
GLuint *vboIdx;<br />
<br />
bool loadTextures();<br />
bool loadShaders(CPVRTString* error);<br />
bool loadFBOs();<br />
<br />
void reset();<br />
void drawScene();<br />
void drawAxisAlignedQuad(PVRTVec2 lowerLeft, PVRTVec2 upperRight);<br />
void updateRotVelocity();<br />
<br />
public:<br />
PVRManager();<br />
virtual ~PVRManager();<br />
<br />
float sceneRot;<br />
<br />
bool initRendering();<br />
bool changeScene(int markerId);<br />
void render(QCAR::Matrix44F MVMatrix, QCAR::Matrix44F MVPMatrix, PVRTVec4 lightPosVec);<br />
<br />
void touchDown(float x, float y);<br />
void touchMove(float x, float y);<br />
void touchUp(float x, float y);<br />
<br />
unsigned long getTime();<br />
};<br />
<br />
#endif /* PVRMANAGER_H_ */<br />
```<br />
<br />
In order to port the application to the iOS devices, I was able to translate the PVRManager into a so-a-like mm file but because of the different logic used by QCAR (augmented reality) in the iOS environement, I had to make a singleton variance of that PVRManager so that I would call the appropriated methods from the same object anywhere. I guess that's when it started to get ugly...<br />
//
// PVRManager.h
//
#import
#import "OGLES2Tools.h"
#import
@interface PVRManager : NSObject
{
@public
CGFloat sceneRot;
NSUInteger screenWidth;
NSUInteger screenHeight;
@private
NSArray *podFiles;
GLuint baseTexture;
GLuint bloomTexture;
GLuint blurTextures[2];
GLuint lightVertShader;
GLuint lightFragShader;
struct {
GLuint pgmId;
GLuint MVPMatrixLoc;
GLuint lightDirLoc;
} lightShaderPgm;
GLuint preBloomVertShader;
GLuint preBloomFragShader;
struct {
GLuint pgmId;
GLuint MVPMatrixLoc;
GLuint lightDirLoc;
GLuint bloomIntensity;
} preBloomShaderPgm;
GLuint postBloomVertShader;
GLuint postBloomFragShader;
struct {
GLuint pgmId;
} postBloomShaderPgm;
GLuint blurFragShader;
GLuint blurVertShader;
struct {
GLuint pgmId;
GLuint texelOffsetX;
GLuint texelOffsetY;
} blurShaderPgm;
CGFloat touchX;
CGFloat touchY;
CGFloat texelOffset;
CGFloat nowRot;
CGFloat lastRot;
CGFloat diffRot;
CPVRTModelPOD podScene;
GLint baseFBO;
GLuint blurFBOs[2];
GLuint depthBuffer;
GLuint *vbo;
GLuint *vboIdx;
}
@property (nonatomic) CGFloat sceneRot;
@property (nonatomic) NSUInteger screenWidth, screenHeight;
+ (PVRManager *)getInstance;
- (BOOL)initManager;
- (BOOL)changeScene:(NSInteger) markerId;
- (void)render:(QCAR::Matrix44F) MVMatrix
:(QCAR::Matrix44F) MVPMatrix
:(PVRTVec4) lightPosVec;
- (void)touchDown:(CGFloat) x
:(CGFloat) y;
- (void)touchMove:(CGFloat) x
:(CGFloat) y;
- (void)touchUp:(CGFloat) x
:(CGFloat) y;
@end
extern PVRManager *pvrMngr;
I had it to the point where I can load assets with a<br />
PVRTTextureLoadFromPVR([[[bundle pathForResource:@"baseTexture"
ofType:@".pvr"
inDirectory:@"textures"] UTF8String], &baseTexture)
That method is called within [[PVRManager getInstance] initManager] and cause an EXC_BAD_ACCESS which I can trace back to<br />
OGLES2/PVRTTextureAPI.cpp
PVRTTextureLoadFromPointer(TexFile.DataPtr(), texName, psTextureHeader, bAllowDecompress, nLoadFromLevel,NULL,pMetaData)
bool bIsPVRTCSupported = CPVRTgles2Ext::IsGLExtensionSupported(“GL_IMG_texture_compression_pvrtc”);
OGLES2/PVRTgles2Ext
where = (GLubyte *) strstr((const char *) start, extension);
<br />
I can't figure out the rest, in fact, I'm some of a noob.<br />
I'm sure I can't get something like a singleton instance in mm file working to call cpp function, but I don't know how. If anyone could help...<br />
Thanks.