Code Search for Developers
 
 
  

paper-jni.cxx from gzz at Krugle


Show paper-jni.cxx syntax highlighted

/*
paper-jni.cxx
 *    
 *    Copyright (c) 2003, Tuomas J. Lukka
 *    
 *    This file is part of Gzz.
 *    
 *    Gzz is free software; you can redistribute it and/or modify it under
 *    the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *    
 *    Gzz is distributed in the hope that it will be useful, but WITHOUT
 *    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
 *    Public License for more details.
 *    
 *    You should have received a copy of the GNU Lesser General
 *    Public License along with Gzz; if not, write to the Free
 *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *    
 *    
 */
/*
 * Written by Tuomas J. Lukka
 */

#include <iostream>
#include <GL/glu.h>
#include <vector>
#include "gzz_gfx_gl_Paper.h"

#include "libutil/ObjectStorer.hxx"


#include <libpaper/Paper.hxx>

using Util::ObjectStorer;
using namespace CallGL;

using std::cout;

#define GLERR { int er = glGetError(); if(er != GL_NO_ERROR) \
		    cout << "===== OPENGL ERROR "<<__FILE__<<" "<<__LINE__ \
			<<"  "<<gluErrorString(er)<<"\n"; \
	    }

ObjectStorer<Paper::Paper> papers("papers");

JNIEXPORT jint JNICALL Java_gzz_gfx_gl_Paper_impl_1create
  (JNIEnv *, jclass) {

      Paper::Paper *p = new Paper::Paper();
      return papers.add(p);
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1delete
  (JNIEnv *, jclass, jint id) {

      papers.remove(id);
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1clone
  (JNIEnv *, jclass, jint from_id, jint to_id) {
  *papers[to_id] = *papers[from_id];
}


JNIEXPORT jint JNICALL Java_gzz_gfx_gl_Paper_impl_1getNPasses
  (JNIEnv *, jclass, jint id) {

      return papers[id]->size();
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1setNPasses
  (JNIEnv *, jclass, jint id, jint size) {
      papers[id]->resize(size);
}

JNIEXPORT jint JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1getNTexGens
  (JNIEnv *, jclass, jint id, jint pass) {
      return (*papers[id])[pass].texgen.size();
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1setNTexGens
  (JNIEnv *, jclass, jint id, jint pass, jint size) {
      (*papers[id])[pass].texgen.resize(size);
}

JNIEXPORT jint JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1getNLightSetups
  (JNIEnv *, jclass, jint id, jint pass) {
      return (*papers[id])[pass].setup.size();
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1setNLightSetups
  (JNIEnv *, jclass, jint id, jint pass, jint size) {
      (*papers[id])[pass].setup.resize(size);
}


JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1setSetupcode
  (JNIEnv *env, jclass, jint id, jint pass, jstring code) {
      GLERR
      const char *utf = env->GetStringUTFChars(code, 0);

      (*papers[id])[pass].setupcode = CallGLCode(utf);

      GLERR

      env->ReleaseStringUTFChars(code, utf);
}

JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1getSetupcode
  (JNIEnv *env, jclass, jint id, jint pass) {

      string s = (*papers[id])[pass].setupcode.getSource();
      return env->NewStringUTF(s.c_str());
}


JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1setTeardowncode
  (JNIEnv *env, jclass, jint id, jint pass, jstring code) {
      GLERR
      const char *utf = env->GetStringUTFChars(code, 0);

      (*papers[id])[pass].teardowncode = CallGLCode(utf);

      GLERR

      env->ReleaseStringUTFChars(code, utf);
}

JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1getTeardowncode
  (JNIEnv *env, jclass, jint id, jint pass) {

      string s = (*papers[id])[pass].teardowncode.getSource();
      return env->NewStringUTF(s.c_str());
}


JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1putNormalTexGen
  (JNIEnv *env, jclass, jint id, jint pass, jint ind, jfloatArray arr) {

      GLERR

      jfloat *floats = env->GetFloatArrayElements(arr, 0);

      (*papers[id])[pass].texgen[ind] = shared_ptr<Paper::TexGen>(new Paper::TexGen(floats));

      GLERR

      env->ReleaseFloatArrayElements(arr, floats, JNI_ABORT);
      
}

JNIEXPORT void JNICALL Java_gzz_gfx_gl_Paper_impl_1Pass_1putEmbossTexGen
  (JNIEnv *env, jclass, jint id, jint pass, jint ind, jfloatArray arr, jfloat eps) {

      GLERR

      jfloat *floats = env->GetFloatArrayElements(arr, 0);

      (*papers[id])[pass].texgen[ind] = shared_ptr<Paper::TexGen>(new Paper::TexGenEmboss(floats, eps));

      GLERR

      env->ReleaseFloatArrayElements(arr, floats, JNI_ABORT);
      
}




See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  GzzGL-jni.cxx
  Makefile
  paper-jni.cxx