Log in or register to post comments

Replace the model used in ImageTargets

January 6, 2013 - 11:38am #1

Hi Team :

1) I have a new file meh.h and I moved it to Jni Folder on proyect. This file was build from file object (meh.obj) using perl script

2) On Eclipse Proyect I have replaced this lines :

 

 glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &mehVerts[0]);

 glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &mehNormals[0]);

 glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &mehTexCoords[0]);

and these lines too :

 

glDrawArrays(GL_TRIANGLES, 0, mehNumVerts);

#include meh.h

3) Save All & Close Eclipse Proyect

4) Run ndk-build on DOS prompt and throw this message:

 

C:\Development\Android\vuforia-sdk-android-2-0-30\samples\ImageTargets-2-0-6>ndk
-build
"Compile++ arm  : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTarge
ts_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:405:48: error: 'mehVertices' was not declared in this scope
 
jni/ImageTargets.cpp:409:48: error: 'mehTexCoords' was not declared in this scop
e
jni/ImageTargets.cpp:422:50: error: too few arguments to function 'void glDrawEl
ements(GLenum, GLsizei, GLenum, const GLvoid*)'
C:/android-ndk-r8d/platforms/android-8/arch-arm/usr/include/GLES2/gl2.h:515:37:
note: declared here
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
 
Team: Please your tips to behave this event,
Thanks in advanced,
 
German Medina Neria

 

Hi, no need to apologize, I'm

January 15, 2013 - 11:07pm #17

Hi, no need to apologize, I'm glad that it now works!

Replace the model used in ImageTarget

January 15, 2013 - 8:23pm #16

Hi Alessadro B:

 

 

First, my apologies for delay in reply and then to confirm you that the project is already running successfully
True, it only needed a refresh on the project enviroment, then run ndk-build and after that then launch the android emulator.
 
Again thank you very much for the support
regards
 
German Medina Neria

Hi, does the ndk-build

January 14, 2013 - 6:51am #15

Hi, does the ndk-build results in a successfull build ? Have you also refreshed the project in Eclipse after that ?

 

Replace the model used in ImageTargets

January 14, 2013 - 5:22am #14

Hi Alessandro;

 

Then I followed you with change

 

 
        /*glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                       (const GLvoid*) &teapotIndices[0]);
                       */
        glDrawArrays(GL_TRIANGLES, 0, mehNumVerts);
 
But after, I run As Android Application I get this message:
 
the library libQCAR.so could not be loaded
 
Please I would appreciate your help with this issue.
Thanks in advanced,
 
 
 

Hi, this is the code that I

January 11, 2013 - 8:57am #13

Hi, this is the code that I just tested (compield and run), which works:

Note: make sure to revert to the original clean ImageTargets.cpp (which compiles and works), and then make these changes:

 

 

/*
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &teapotVertices[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &teapotNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &teapotTexCoords[0]);
 
                              */
 
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                                     (const GLvoid*) &mehVerts[0]);
 
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                                     (const GLvoid*) &mehNormals[0]);
        
 
        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        //glEnableVertexAttribArray(textureCoordHandle);
        
 
And this change:
 
        /*glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                       (const GLvoid*) &teapotIndices[0]);
                       */
        glDrawArrays(GL_TRIANGLES, 0, mehNumVerts);
 
 
Also, add #include "meh.h".
 
And set the kObjectScale variable to something bigger than 3.0 (e.g. 100).
 
This should compile and run as I just verified.
Let me know if something is not clear.
 

And also could you specify if

January 11, 2013 - 5:09am #12

And also could you specify if you are using OpenGL 1.1 or 2.0 ?

 

to verify that, check this flag in your Android.mk file:

USE_OPENGL_ES_1_1 := false    (...or is it set to true ?)

 

Hi, the fact that you get

January 11, 2013 - 12:36am #11

Hi, the fact that you get errors when you run the app in Eclipse is normal, because the ndk-build failed for the C++ part, so you need first to fix the C++ code.

What I see is that there something else wrong in your ImageTargets.cpp, but I need you to send me the whole file;

can you send it to me (same email address as before) ? 

I'll try to compile it and see what is wrong.

Thanks

 

Replace the model used in ImageTargets

January 10, 2013 - 7:48pm #10

Hi AlessandroB again:

Following your indications, here is the update :

1) Running ndk-build command :

 

C:\Development\Android\vuforia-sdk-android-2-0-30\samples\ImageTargets-2-0-6>ndk
-build
"Compile++ arm  : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTarge
ts_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:419:51: error: void value not ignored as it ought to be
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
 
C:\Development\Android\vuforia-sdk-android-2-0-30\samples\ImageTargets-2-0-6>
 
2) After thatm running on eclipse throw next message and app crashed:
 
01-10 22:31:00.696: E/dalvikvm(1607): could not disable core file generation for pid 1607: Operation not permitted
01-10 22:31:00.976: D/dalvikvm(1607): GC_EXTERNAL_ALLOC freed 57K, 49% free 2662K/5123K, external 2486K/2773K, paused 116ms
01-10 22:31:25.460: E/QCAR(1607): The library libQCAR.so could not be loaded
01-10 22:31:25.460: E/QCAR(1607): The library libImageTargets.so could not be loaded
01-10 22:31:25.460: D/QCAR(1607): ImageTargets::onCreate
01-10 22:31:25.550: D/dalvikvm(1607): GC_EXTERNAL_ALLOC freed 632K, 50% free 3251K/6407K, external 4004K/4051K, paused 22ms
01-10 22:31:25.580: W/dalvikvm(1607): No implementation found for native Lcom/qualcomm/QCARSamples/ImageTargets/ImageTargets;.getOpenGlEsVersionNative ()I
01-10 22:31:25.580: W/dalvikvm(1607): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
01-10 22:31:25.590: E/AndroidRuntime(1607): FATAL EXCEPTION: main
01-10 22:31:25.590: E/AndroidRuntime(1607): java.lang.UnsatisfiedLinkError: getOpenGlEsVersionNative
01-10 22:31:25.590: E/AndroidRuntime(1607): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.getOpenGlEsVersionNative(Native Method)
01-10 22:31:25.590: E/AndroidRuntime(1607): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.getInitializationFlags(ImageTargets.java:384)
01-10 22:31:25.590: E/AndroidRuntime(1607): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.onCreate(ImageTargets.java:355)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1727)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.os.Looper.loop(Looper.java:130)
01-10 22:31:25.590: E/AndroidRuntime(1607): at android.app.ActivityThread.main(ActivityThread.java:3859)
01-10 22:31:25.590: E/AndroidRuntime(1607): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 22:31:25.590: E/AndroidRuntime(1607): at java.lang.reflect.Method.invoke(Method.java:507)
01-10 22:31:25.590: E/AndroidRuntime(1607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
01-10 22:31:25.590: E/AndroidRuntime(1607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:648)
01-10 22:31:25.590: E/AndroidRuntime(1607): at dalvik.system.NativeStart.main(Native Method)
 
Please any other advise I would appreciate it
Thanks in advanced,
 
German Medina Neria
 

Hi, as I explained to you in

January 10, 2013 - 5:22am #9

Hi,

as I explained to you in a previous message, your meh.h file is correct, but you have to do the following:

1- remove (or comment out) this line:

  // glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &mehTexCoord[0]);

  (because your file does not define 'mehTexCoords')

2- Replace this line:

    glDrawArrays(GL_TRIANGLES, 0, mehVerts); // WRONG CODE

    with this one:

     glDrawArrays(GL_TRIANGLES, 0, mehNumVerts); // CORRECT CODE

3- In CubeShader.h, replace:

    gl_FragColor = texture2D(texSampler2D, mehTexCoord); //WRONG CODE
 
  with this line:
  
     gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);//CORRECT CODE

 

Save the file, and rebuild with ndk-build.

 

Replace the model used in ImageTargets

January 10, 2013 - 5:10am #8

Hi Alessandro B:

This is my Summary : (file inserted on jni folder is meh.h)

 

On ImageTargets.cpp
 
glUseProgram(shaderProgramID);
         
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &mehVerts[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &mehNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &mehTexCoord[0]);
        
        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);
        
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
        glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
                           (GLfloat*)&modelViewProjection.data[0] );
        glDrawArrays(GL_TRIANGLES, 0, mehVerts);
        //glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
        //               (const GLvoid*) &mehIndices[0]);
 
        SampleUtils::checkGlError("ImageTargets renderFrame");
 
On Cubeshaders.h
 
static const char* cubeFragmentShader = " \
 \
precision mediump float; \
 \
varying vec2 texCoord; \
varying vec4 normal; \
 \
uniform sampler2D texSampler2D; \
 \
void main() \
{ \
   gl_FragColor =  texture2D(texSampler2D, mehTexCoord); \
} \
";
 

Running ndk-build i have this message :

 

C:\Development\Android\vuforia-sdk-android-2-0-30\samples\ImageTargets-2-0-6>ndk
-build
"Compile++ arm  : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTarge
ts_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:408:48: error: 'mehTexCoord' was not declared in this scope
 
jni/ImageTargets.cpp:420:41: error: 'mehIndices' was not declared in this scope
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
 
On meh.h file is the only variable : mehVerts , My question is: the source problem is that variables mehTexCoord and mehIndices are not in the meh.h file and the export of the object file to .h file is not correctly ?
 
Please any other tips to resolve this issue I would appreciate it
 
Thanks in advanced,
german Medina Neria
 

Hi,   gl_FragColor =

January 8, 2013 - 11:28pm #7

Hi,

  gl_FragColor = texture2D(texSampler2D, texCoord); is located in the file called "CubeShader.h" (same JNI directory where ImageTargets.cpp is located); note: it is shader code, not standard code, so it is enclosed in a string.

also, replace the glDrawElements( ... ) with this:

   glDrawArrays(GL_TRIANGLES, 0, mehNumVerts);

Then it should be good.

Replace the model used in ImageTargets

January 8, 2013 - 10:06pm #6

Hi :

Here are my results :

1.- mehVerts is working, I saw this come from (was declared into meh.h)

2.- Please your asistance, about mehTexCoords, I do not find ( gl_FragColor = texture2D(texSampler2D, texCoord);) to replace it

3.- On this command line was :

 

glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                       (const GLvoid*) &mehIndices[0]);
 
Throw error :
jni/ImageTargets.cpp:420:41: error: 'mehIndices' was not declared in this scope
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1

and I replaced by

 

glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                       (const GLvoid*) &mehNumVerts[0]);
Throw error : 

 

jni/ImageTargets.cpp:420:54: error: invalid types 'unsigned int[int]' for array subscript
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1

4.- mehTexCoords and mehIndices does not become on meh.h file , is something wrong with this file ?

Thanks in advanced,

German Medina Neria

Thanks for the file. The file

January 8, 2013 - 1:04pm #5

Thanks for the file. The file looks OK, however you need to pay attention to the following issues in your code:

- be sure to use "mehVerts" and not "mehVertices" (just make a text search in your ImageTargets.cpp to be sure that you never use "mehVertices", but you always use "mehVerts")

- the "mehTexCoords" is not defined in meh.h, so you need to either:

    a. re-export the OBJ (and create a new meh.h) by making sure that you are also exporting the texture coordinates (so that the meh.h will contain mehTexCoords)

OR:

  b. comment out the OpenGL code using mehTexCoords; in this case, you will also need to change the CubeShader.h, by replacing this line:

       gl_FragColor = texture2D(texSampler2D, texCoord);

   with:

     gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);

 

I hope this helps.

 

 

Can you send me the < meh.h

January 8, 2013 - 1:19am #4

Can you send me the < meh.h > file to this address: aboccala@qti.qualcomm.com

 

Replace the model used in ImageTargets

January 7, 2013 - 9:29pm #3

Hi:

 

Here is my code on ImageTargets.cpp

 

#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
 
#ifdef USE_OPENGL_ES_1_1
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
 
#include <QCAR/QCAR.h>
#include <QCAR/CameraDevice.h>
#include <QCAR/Renderer.h>
#include <QCAR/VideoBackgroundConfig.h>
#include <QCAR/Trackable.h>
#include <QCAR/TrackableResult.h>
#include <QCAR/Tool.h>
#include <QCAR/Tracker.h>
#include <QCAR/TrackerManager.h>
#include <QCAR/ImageTracker.h>
#include <QCAR/CameraCalibration.h>
#include <QCAR/UpdateCallback.h>
#include <QCAR/DataSet.h>
 
 
#include "SampleUtils.h"
#include "Texture.h"
#include "CubeShaders.h"
#include "Teapot.h"
#include "meh.h"
 
......and continue ::
 
Please your comments on this subjetc
Thanks in advanced again,
 
German Medina Neria

 

Hi, have you included the

January 6, 2013 - 11:13pm #2

Hi, have you included the meh.h header in ImageTargets.cpp, i.e. have you added this line:

#include "meh.h"

(see line of code where you have  <  #include "Teapot.h"  >)

?

Log in or register to post comments