androidShaderExample w/3D model and Custom Shaders

I am trying to modify the androidShaderExample for android to load my own 3D model and vertex and fragment shader for educational purposes. I borrow code from the 3DModelLoaderExample for loading the 3D squirrel model. I am brand new to openFrameworks for android, and any help would be greatly appreciated.

I am getting the following error:
“called unimplemented OpenGL ES API”

Also, I am not sure if my vertex and fragment shaders will work for OpenGL ES and could use some help modifying them so they run on Android. Thank you in advance.


#include "ofMain.h"
#include "ofApp.h"
#include "ofGLProgrammableRenderer.h"

int main(){
ofSetupOpenGL(1024,768, OF_WINDOW);			// <-------- setup the GL context
ofRunApp( new ofApp() );
return 0;

#include <jni.h>
extern "C"{
   void Java_cc_openframeworks_OFAndroid_init( JNIEnv*  env, jobject  thiz ){

---- ofApp.h----

#ifndef _TEST_APP
#define _TEST_APP

#include <GLES2/gl2.h>

#include "ofx3DModelLoader.h"
#include "ofxAndroidApp.h"
#include "ofShader.h"

class ofApp : public ofxAndroidApp{
	void setup();
	void update();
	void draw();
	void keyPressed(int key);
	void keyReleased(int key);
	void windowResized(int w, int h);

	void touchDown(int x, int y, int id);
	void touchMoved(int x, int y, int id);
	void touchUp(int x, int y, int id);
	void touchDoubleTap(int x, int y, int id);
	void touchCancelled(int x, int y, int id);
	void swipe(ofxAndroidSwipeDir swipeDir, int id);

	void pause();
	void stop();
	void resume();
	void reloadTextures();

	bool backPressed();
	void okPressed();
	void cancelPressed();

	ofShader shader;
	bool doShader;

	ofx3DModelLoader squirrelModel;



#include "ofApp.h"
GLfloat lightOnePosition[] = {40.0, 40, 100.0, 0.0};
GLfloat lightOneColor[] = {0.99, 0.99, 0.99, 1.0};

GLfloat lightTwoPosition[] = {-40.0, 40, 100.0, 0.0};
GLfloat lightTwoColor[] = {0.99, 0.99, 0.99, 1.0};
void ofApp::setup(){

squirrelModel.loadModel("shaders/VertibraeCentered.3ds", 10.0);

squirrelModel.setRotation(0, 90, 1, 0, 0);
squirrelModel.setRotation(1, 270, 0, 0, 1);
squirrelModel.setScale(0.9, 0.9, 0.9);
squirrelModel.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0);

shader.load("shaders/x-ray.vert", "shaders/x-ray.frag");
doShader = true;
void ofApp::update(){
squirrelModel.setRotation(1, 270 + ofGetElapsedTimef() * 60, 0, 0, 1);
void ofApp::draw(){
//lets tumble the world with the mouse

//draw in middle of the screen

//tumble according to mouse

 ofSetColor(255, 255, 255, 255);



ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15);

void ofApp::reloadTextures(){
    shader.load("shaders/x-ray.vert", "shaders/x-ray.frag");

bool ofApp::backPressed(){
    return false;


// Application to vertex shader
varying vec3 N;
varying vec3 I;
varying vec4 Cs;

void main()
 vec4 P = gl_ModelViewMatrix * gl_Vertex;
 I  = - vec3 (0);
 N  = gl_NormalMatrix * gl_Normal;
 Cs = gl_Color;
 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;


#ifdef GL_ES
/* define default precision for float, vec, mat. */
precision highp float;

// vertex to fragment shader io
varying vec3 N;
varying vec3 I;
varying vec4 Cs;

// globals
float edgefalloff=.8;
float intensity=.5;
float ambient=.350;

// entry point
void main()
float opac = dot(normalize(-N), normalize(-I));

opac = abs(opac);

opac = ambient + intensity*(1.0-pow(opac, edgefalloff));

gl_FragColor =  opac * Cs;
gl_FragColor.a = opac;

you are using some calls that don’t exist anymore under GLES2, things like glRotate, glPushMatrix… you cna use the OF equivalents though: ofRotate, ofPushMatrix…

Thank you for the help. I changed those calls to work for GLES2. However, I am still getting the “called unimplemented OpenGL ES API” error. I have unresolved inclusions for each of my header files: <GLES2/gl2.h>, “ofx3DModelLoader.h”, “ofxAndroidApp.h”, “ofShader.h”. Any idea what could be the problem there?

check that you have sent up Eclipse correctly and perform the following steps I outlined in this post

Thanks for the suggestions. I checked my paths and they are set up correctly. I am still getting the error: “Cannot run program ‘ndk-build’: Unknown reason.”

I am working within the 3DModelLoaderExample and the shaders seem to be compiling now (I am using the vertex and fragment shaders from the ShaderExample and am using GLES1 instead of GLES2 now). Could anyone help me interpret this LogCat information?