Skip to content

Commit

Permalink
removed C++ warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nebogeo committed Feb 20, 2018
1 parent 6113cdb commit b216b26
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 475 deletions.
25 changes: 3 additions & 22 deletions android/app/src/main/jni/Android.mk
Expand Up @@ -5,38 +5,19 @@ include $(CLEAR_VARS)

LOCAL_MODULE := starwisp-core

LOCAL_CFLAGS := -DANDROID_NDK -fpermissive -DDISABLE_IMPORTGL -O3 -Wno-write-strings -DNDEBUG
LOCAL_CFLAGS := -DANDROID_NDK -Wswitch -fpermissive -DDISABLE_IMPORTGL -O3 -Wno-write-strings -DNDEBUG
APP_OPTIM := release

LOCAL_SRC_FILES := \
fluxa/Sample.cpp \
fluxa/Allocator.cpp \
fluxa/Graph.cpp \
fluxa/GraphNode.cpp \
fluxa/Modules.cpp \
fluxa/ModuleNodes.cpp \
core/list.cpp \
core/db.cpp \
core/db_container.cpp \
core/fixed.cpp \
core/geometry.cpp \
core/idmap.cpp \
core/noise.cpp \
sqlite/sqlite3.c \
scheme/scheme.cpp \
engine/primitive.cpp \
engine/text_primitive.cpp \
engine/scenenode.cpp \
engine/scenegraph.cpp \
engine/texture.cpp \
engine/importgl.c \
engine/obj_reader.cpp \
engine/nomadic.cpp \
engine/engine.cpp \
jellyfish/jellyfish.cpp \
jellyfish/jellyfish_primitive.cpp \
audio.cpp \
app-android.c
app.cpp \
app-android.c

LOCAL_LDLIBS := -lGLESv1_CM -lOpenSLES -ldl -llog

Expand Down
50 changes: 2 additions & 48 deletions android/app/src/main/jni/app-android.c
Expand Up @@ -4,43 +4,20 @@
#include <android/log.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "app.h"
#include "scheme/scheme.h"

static int sWindowWidth = 320;
static int sWindowHeight = 480;

void Java_foam_starwisp_Scheme_nativeInit(JNIEnv* env)
{
appInit();
}

/* Call to initialize the graphics state */
void Java_foam_starwisp_Scheme_nativeInitGL( JNIEnv* env )
{
importGLInit();
initGL();
}

void Java_foam_starwisp_Scheme_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
sWindowWidth = w;
sWindowHeight = h;
__android_log_print(ANDROID_LOG_INFO, "SanAngeles", "resize w=%d h=%d", w, h);
}


void Java_foam_starwisp_Scheme_nativeDone(JNIEnv* env)
{
appDeinit();
importGLDeinit();
}

void Java_foam_starwisp_Scheme_nativeRender( JNIEnv* env )
{
appRender(sWindowWidth, sWindowHeight);
}


jstring Java_foam_starwisp_Scheme_nativeEval(JNIEnv* env, jobject thiz, jstring code)
{
const char *native_code = (*env)->GetStringUTFChars(env, code, 0);
Expand All @@ -55,26 +32,3 @@ jstring Java_foam_starwisp_Scheme_nativeEval(JNIEnv* env, jobject thiz, jstring
return (*env)->NewStringUTF(env,"");
}

void Java_foam_starwisp_Scheme_nativeLoadTexture(JNIEnv* env, jobject thiz, jstring texname, jbyteArray arr, jint w, jint h)
{
char *data = (char *) (*env)->GetByteArrayElements(env,arr,NULL);
int len = (*env)->GetArrayLength(env, arr);
const char *filename = (*env)->GetStringUTFChars(env, texname, 0);

__android_log_print(ANDROID_LOG_INFO, "starwisp", "loading texture");


int id=appLoadTexture(filename,w,h,data);

__android_log_print(ANDROID_LOG_INFO, "starwisp", "loaded texture");

(*env)->ReleaseStringUTFChars(env, texname, filename);
(*env)->ReleaseByteArrayElements(env,arr,data,JNI_ABORT);
}

// create the engine and output mix objects
void Java_foam_starwisp_Scheme_createEngine(JNIEnv* env, jclass clazz)
{
audio_init();
create_audio_engine();
}
9 changes: 1 addition & 8 deletions android/app/src/main/jni/app.h
Expand Up @@ -4,16 +4,9 @@
extern "C" {
#endif

#define WINDOW_DEFAULT_WIDTH 640
#define WINDOW_DEFAULT_HEIGHT 480
#define WINDOW_BPP 16

extern void appInit();
extern void initGL();
extern void appDeinit();
extern void appEval(char *code);
extern void appRender(int width, int height);
extern unsigned int appLoadTexture(const char *filename, int width, int height, char* data);
extern void appEval(const char *code);

#ifdef __cplusplus
}
Expand Down
106 changes: 0 additions & 106 deletions android/app/src/main/jni/engine/nomadic.cpp
Expand Up @@ -19,9 +19,7 @@
#include <float.h>
#include <assert.h>

#include "importgl.h"
#include "app.h"
#include "engine/engine.h"
#include "scheme/scheme.h"

scheme *sc=NULL;;
Expand All @@ -46,119 +44,15 @@ void appInit()
if (log_file!=NULL) scheme_set_output_port_file(sc, log_file);
}

void initGL()
{
int a;

glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDisable(GL_LIGHT1);
glDisable(GL_LIGHT2);

glEnableClientState(GL_VERTEX_ARRAY);

engine::init();
}

// Called from the app framework.
void appDeinit()
{
fclose(log_file);
int a;
}


static void gluPerspective(GLfloat fovy, GLfloat aspect,
GLfloat zNear, GLfloat zFar)
{
GLfloat xmin, xmax, ymin, ymax;

ymax = zNear * (GLfloat)tan(fovy * 3.141 / 360);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;

glFrustumx((GLfixed)(xmin * 65536), (GLfixed)(xmax * 65536),
(GLfixed)(ymin * 65536), (GLfixed)(ymax * 65536),
(GLfixed)(zNear * 65536), (GLfixed)(zFar * 65536));
}


static void prepareFrame(int width, int height)
{
glViewport(0, 0, width, height);

engine::get()->set_screensize(width,height);

// glClearColorx((GLfixed)(engine::get()->m_clear_r * 65536),
// (GLfixed)(engine::get()->m_clear_g * 65536),
// (GLfixed)(engine::get()->m_clear_b * 65536),
// (GLfixed)(0.5 * 65536));
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (float)width / height, 0.5f, 150);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();
}


static void configureLightAndMaterial()
{
static GLfixed light0Position[] = { -0x40000, 0x100000, 0x00000, 0 };
static GLfixed light0Diffuse[] = { 0x10000, 0x10000, 0x10000, 0x10000 };
static GLfixed light1Position[] = { 0x10000, -0x20000, -0x10000, 0 };
static GLfixed light1Diffuse[] = { 0x11eb, 0x23d7, 0x5999, 0x10000 };
static GLfixed light2Position[] = { -0x10000, 0, -0x40000, 0 };
static GLfixed light2Diffuse[] = { 0x11eb, 0x2b85, 0x23d7, 0x10000 };
static GLfixed materialSpecular[] = { 0x10000, 0x10000, 0x10000, 0x10000 };

glLightxv(GL_LIGHT0, GL_POSITION, light0Position);
glLightxv(GL_LIGHT0, GL_DIFFUSE, light0Diffuse);
glLightxv(GL_LIGHT1, GL_POSITION, light1Position);
glLightxv(GL_LIGHT1, GL_DIFFUSE, light1Diffuse);
glLightxv(GL_LIGHT2, GL_POSITION, light2Position);
glLightxv(GL_LIGHT2, GL_DIFFUSE, light2Diffuse);
// glMaterialxv(GL_FRONT_AND_BACK, GL_SPECULAR, materialSpecular);

// glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, 60 << 16);
glEnable(GL_COLOR_MATERIAL);
}

// Called from the app framework.
/* The tick is current time in milliseconds, width and height
* are the image dimensions to be rendered.
*/
void appRender(int width, int height)
{
// Prepare OpenGL ES for rendering of the frame.
prepareFrame(width, height);

// Configure environment.
configureLightAndMaterial();

scheme_load_string(sc,"(frame-hook)");

glPushMatrix();
engine::get()->render();
glPopMatrix();
}

void appEval(char *code)
{
scheme_load_string(sc,code);
fflush(log_file);
}

u32 appLoadTexture(const char *filename,int width, int height, char* data)
{
return engine::get()->load_texture(filename,width,height,(u8*)data);
}

0 comments on commit b216b26

Please sign in to comment.