Log in or register to post comments

variable naming in QualcommShared files

December 26, 2010 - 8:03pm #1

This may seem a silly question but i was trying to understand exactly how the texture loaded in java was being accessed in the native code.

I noticed that in the shared project files, eg in QCARSampleActivity.java the variable names are prefixed with "m" eg mTextures.. while in the native code, there is no such prefix. can someone tell me if this is some fixed convention to prefix "m" and is it necessary?

In the native code, in ImageTargets.cpp,

extern Texture** textures;

where exactly is the variable that is pointed to by "texture" loaded, is it mTextures?

Re: variable naming in QualcommShared files

December 29, 2010 - 6:30am #2

Sorry for the late reply, we were having forum trouble yesterday.

The use of the "m" prefix is just convention, and not at all required. It hints that the variable is a member variable of the class, to help you distinguish it from local variables in a method.

If you are using version 0.9.7 of the SDK, the native textures variable exists in the Shared project's QCARSampleActivity.cpp file. Native code can't point directly to variables declared in Java code. If you look at the initApplicationNative method in QCARSampleActivity.cpp, you will see how the texture data is initialized with jni calls from native to Java.

Please note that in version 0.10.0 of the SDK the Shared project code has been merged into each individual sample, so the textures variable is no longer declared extern.

- Kim

Log in or register to post comments