From 0f5b24c83ca2daf58a12e615e4e59ba31d64350e Mon Sep 17 00:00:00 2001 From: Alexander Mahr Date: Sat, 1 Mar 2025 10:58:16 +0100 Subject: [PATCH] remove text draw sutff --- app/src/nativecode/main.c | 380 +++++++++++++++++++------------------- 1 file changed, 190 insertions(+), 190 deletions(-) diff --git a/app/src/nativecode/main.c b/app/src/nativecode/main.c index 73be410..ed74093 100644 --- a/app/src/nativecode/main.c +++ b/app/src/nativecode/main.c @@ -154,97 +154,97 @@ float Heightmap[HMX*HMY]; extern struct android_app * gapp; -void DrawHeightmap() -{ - int x, y; - //float fdt = ((iframeno++)%(360*10))/10.0; - - mountainangle += .2; - if( mountainangle < 0 ) mountainangle += 360; - if( mountainangle > 360 ) mountainangle -= 360; - - mountainoffsety = mountainoffsety - ((mountainoffsety-100) * .1); - - float eye[3] = { (float)(sin(mountainangle*(3.14159/180.0))*30*sin(mountainoffsety/100.)), (float)(cos(mountainangle*(3.14159/180.0))*30*sin(mountainoffsety/100.)), (float)(30*cos(mountainoffsety/100.)) }; - float at[3] = { 0,0, 0 }; - float up[3] = { 0,0, 1 }; - - tdSetViewport( -1, -1, 1, 1, screenx, screeny ); - - tdMode( tdPROJECTION ); - tdIdentity( gSMatrix ); - tdPerspective( 30, ((float)screenx)/((float)screeny), .1, 200., gSMatrix ); - - tdMode( tdMODELVIEW ); - tdIdentity( gSMatrix ); - tdTranslate( gSMatrix, 0, 0, -40 ); - tdLookAt( gSMatrix, eye, at, up ); - - float scale = 60./HMX; - - for( x = 0; x < HMX-1; x++ ) - for( y = 0; y < HMY-1; y++ ) - { - float tx = x-HMX/2; - float ty = y-HMY/2; - float pta[3]; - float ptb[3]; - float ptc[3]; - float ptd[3]; - - float normal[3]; - float lightdir[3] = { .6, -.6, 1 }; - float tmp1[3]; - float tmp2[3]; - - RDPoint pto[6]; - - pta[0] = (tx+0)*scale; pta[1] = (ty+0)*scale; pta[2] = Heightmap[(x+0)+(y+0)*HMX]*scale; - ptb[0] = (tx+1)*scale; ptb[1] = (ty+0)*scale; ptb[2] = Heightmap[(x+1)+(y+0)*HMX]*scale; - ptc[0] = (tx+0)*scale; ptc[1] = (ty+1)*scale; ptc[2] = Heightmap[(x+0)+(y+1)*HMX]*scale; - ptd[0] = (tx+1)*scale; ptd[1] = (ty+1)*scale; ptd[2] = Heightmap[(x+1)+(y+1)*HMX]*scale; - - tdPSub( pta, ptb, tmp2 ); - tdPSub( ptc, ptb, tmp1 ); - tdCross( tmp1, tmp2, normal ); - tdNormalizeSelf( normal ); - - tdFinalPoint( pta, pta ); - tdFinalPoint( ptb, ptb ); - tdFinalPoint( ptc, ptc ); - tdFinalPoint( ptd, ptd ); - - if( pta[2] >= 1.0 ) continue; - if( ptb[2] >= 1.0 ) continue; - if( ptc[2] >= 1.0 ) continue; - if( ptd[2] >= 1.0 ) continue; - - if( pta[2] < 0 ) continue; - if( ptb[2] < 0 ) continue; - if( ptc[2] < 0 ) continue; - if( ptd[2] < 0 ) continue; - - pto[0].x = pta[0]; pto[0].y = pta[1]; - pto[1].x = ptb[0]; pto[1].y = ptb[1]; - pto[2].x = ptd[0]; pto[2].y = ptd[1]; - - pto[3].x = ptc[0]; pto[3].y = ptc[1]; - pto[4].x = ptd[0]; pto[4].y = ptd[1]; - pto[5].x = pta[0]; pto[5].y = pta[1]; - -// CNFGColor(((x+y)&1)?0xFFFFFF:0x000000); - - float bright = tdDot( normal, lightdir ); - if( bright < 0 ) bright = 0; - CNFGColor( 0xff | ( ( (int)( bright * 90 ) ) << 24 ) ); - -// CNFGTackPoly( &pto[0], 3 ); CNFGTackPoly( &pto[3], 3 ); - CNFGTackSegment( pta[0], pta[1], ptb[0], ptb[1] ); - CNFGTackSegment( pta[0], pta[1], ptc[0], ptc[1] ); - CNFGTackSegment( ptb[0], ptb[1], ptc[0], ptc[1] ); - - } -} +//Heightmap void DrawHeightmap() +//Heightmap { +//Heightmap int x, y; +//Heightmap //float fdt = ((iframeno++)%(360*10))/10.0; +//Heightmap +//Heightmap mountainangle += .2; +//Heightmap if( mountainangle < 0 ) mountainangle += 360; +//Heightmap if( mountainangle > 360 ) mountainangle -= 360; +//Heightmap +//Heightmap mountainoffsety = mountainoffsety - ((mountainoffsety-100) * .1); +//Heightmap +//Heightmap float eye[3] = { (float)(sin(mountainangle*(3.14159/180.0))*30*sin(mountainoffsety/100.)), (float)(cos(mountainangle*(3.14159/180.0))*30*sin(mountainoffsety/100.)), (float)(30*cos(mountainoffsety/100.)) }; +//Heightmap float at[3] = { 0,0, 0 }; +//Heightmap float up[3] = { 0,0, 1 }; +//Heightmap +//Heightmap tdSetViewport( -1, -1, 1, 1, screenx, screeny ); +//Heightmap +//Heightmap tdMode( tdPROJECTION ); +//Heightmap tdIdentity( gSMatrix ); +//Heightmap tdPerspective( 30, ((float)screenx)/((float)screeny), .1, 200., gSMatrix ); +//Heightmap +//Heightmap tdMode( tdMODELVIEW ); +//Heightmap tdIdentity( gSMatrix ); +//Heightmap tdTranslate( gSMatrix, 0, 0, -40 ); +//Heightmap tdLookAt( gSMatrix, eye, at, up ); +//Heightmap +//Heightmap float scale = 60./HMX; +//Heightmap +//Heightmap for( x = 0; x < HMX-1; x++ ) +//Heightmap for( y = 0; y < HMY-1; y++ ) +//Heightmap { +//Heightmap float tx = x-HMX/2; +//Heightmap float ty = y-HMY/2; +//Heightmap float pta[3]; +//Heightmap float ptb[3]; +//Heightmap float ptc[3]; +//Heightmap float ptd[3]; +//Heightmap +//Heightmap float normal[3]; +//Heightmap float lightdir[3] = { .6, -.6, 1 }; +//Heightmap float tmp1[3]; +//Heightmap float tmp2[3]; +//Heightmap +//Heightmap RDPoint pto[6]; +//Heightmap +//Heightmap pta[0] = (tx+0)*scale; pta[1] = (ty+0)*scale; pta[2] = Heightmap[(x+0)+(y+0)*HMX]*scale; +//Heightmap ptb[0] = (tx+1)*scale; ptb[1] = (ty+0)*scale; ptb[2] = Heightmap[(x+1)+(y+0)*HMX]*scale; +//Heightmap ptc[0] = (tx+0)*scale; ptc[1] = (ty+1)*scale; ptc[2] = Heightmap[(x+0)+(y+1)*HMX]*scale; +//Heightmap ptd[0] = (tx+1)*scale; ptd[1] = (ty+1)*scale; ptd[2] = Heightmap[(x+1)+(y+1)*HMX]*scale; +//Heightmap +//Heightmap tdPSub( pta, ptb, tmp2 ); +//Heightmap tdPSub( ptc, ptb, tmp1 ); +//Heightmap tdCross( tmp1, tmp2, normal ); +//Heightmap tdNormalizeSelf( normal ); +//Heightmap +//Heightmap tdFinalPoint( pta, pta ); +//Heightmap tdFinalPoint( ptb, ptb ); +//Heightmap tdFinalPoint( ptc, ptc ); +//Heightmap tdFinalPoint( ptd, ptd ); +//Heightmap +//Heightmap if( pta[2] >= 1.0 ) continue; +//Heightmap if( ptb[2] >= 1.0 ) continue; +//Heightmap if( ptc[2] >= 1.0 ) continue; +//Heightmap if( ptd[2] >= 1.0 ) continue; +//Heightmap +//Heightmap if( pta[2] < 0 ) continue; +//Heightmap if( ptb[2] < 0 ) continue; +//Heightmap if( ptc[2] < 0 ) continue; +//Heightmap if( ptd[2] < 0 ) continue; +//Heightmap +//Heightmap pto[0].x = pta[0]; pto[0].y = pta[1]; +//Heightmap pto[1].x = ptb[0]; pto[1].y = ptb[1]; +//Heightmap pto[2].x = ptd[0]; pto[2].y = ptd[1]; +//Heightmap +//Heightmap pto[3].x = ptc[0]; pto[3].y = ptc[1]; +//Heightmap pto[4].x = ptd[0]; pto[4].y = ptd[1]; +//Heightmap pto[5].x = pta[0]; pto[5].y = pta[1]; +//Heightmap +//Heightmap // CNFGColor(((x+y)&1)?0xFFFFFF:0x000000); +//Heightmap +//Heightmap float bright = tdDot( normal, lightdir ); +//Heightmap if( bright < 0 ) bright = 0; +//Heightmap CNFGColor( 0xff | ( ( (int)( bright * 90 ) ) << 24 ) ); +//Heightmap +//Heightmap // CNFGTackPoly( &pto[0], 3 ); CNFGTackPoly( &pto[3], 3 ); +//Heightmap CNFGTackSegment( pta[0], pta[1], ptb[0], ptb[1] ); +//Heightmap CNFGTackSegment( pta[0], pta[1], ptc[0], ptc[1] ); +//Heightmap CNFGTackSegment( ptb[0], ptb[1], ptc[0], ptc[1] ); +//Heightmap +//Heightmap } +//Heightmap } int HandleDestroy() @@ -280,73 +280,73 @@ void AudioCallback( struct CNFADriver * sd, short * out, short * in, int framesp } */ -void MakeNotification( const char * channelID, const char * channelName, const char * title, const char * message ) -{ - static int id; - id++; - - const struct JNINativeInterface * env = 0; - const struct JNINativeInterface ** envptr = &env; - const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm; - const struct JNIInvokeInterface * jnii = *jniiptr; - - jnii->AttachCurrentThread( jniiptr, &envptr, NULL); - env = (*envptr); - - jstring channelIDStr = env->NewStringUTF( ENVCALL channelID ); - jstring channelNameStr = env->NewStringUTF( ENVCALL channelName ); - - // Runs getSystemService(Context.NOTIFICATION_SERVICE). - jclass NotificationManagerClass = env->FindClass( ENVCALL "android/app/NotificationManager" ); - jclass activityClass = env->GetObjectClass( ENVCALL gapp->activity->clazz ); - jmethodID MethodGetSystemService = env->GetMethodID( ENVCALL activityClass, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); - jstring notificationServiceName = env->NewStringUTF( ENVCALL "notification" ); - jobject notificationServiceObj = env->CallObjectMethod( ENVCALL gapp->activity->clazz, MethodGetSystemService, notificationServiceName); - - // create the Notification channel. - jclass notificationChannelClass = env->FindClass( ENVCALL "android/app/NotificationChannel" ); - jmethodID notificationChannelConstructorID = env->GetMethodID( ENVCALL notificationChannelClass, "", "(Ljava/lang/String;Ljava/lang/CharSequence;I)V" ); - jobject notificationChannelObj = env->NewObject( ENVCALL notificationChannelClass, notificationChannelConstructorID, channelIDStr, channelNameStr, 3 ); // IMPORTANCE_DEFAULT - jmethodID createNotificationChannelID = env->GetMethodID( ENVCALL NotificationManagerClass, "createNotificationChannel", "(Landroid/app/NotificationChannel;)V" ); - env->CallVoidMethod( ENVCALL notificationServiceObj, createNotificationChannelID, notificationChannelObj ); - - env->DeleteLocalRef( ENVCALL channelNameStr ); - env->DeleteLocalRef( ENVCALL notificationChannelObj ); - - // Create the Notification builder. - jclass classBuilder = env->FindClass( ENVCALL "android/app/Notification$Builder" ); - jstring titleStr = env->NewStringUTF( ENVCALL title ); - jstring messageStr = env->NewStringUTF( ENVCALL message ); - jmethodID eventConstructor = env->GetMethodID( ENVCALL classBuilder, "", "(Landroid/content/Context;Ljava/lang/String;)V" ); - jobject eventObj = env->NewObject( ENVCALL classBuilder, eventConstructor, gapp->activity->clazz, channelIDStr ); - jmethodID setContentTitleID = env->GetMethodID( ENVCALL classBuilder, "setContentTitle", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;" ); - jmethodID setContentTextID = env->GetMethodID( ENVCALL classBuilder, "setContentText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;" ); - jmethodID setSmallIconID = env->GetMethodID( ENVCALL classBuilder, "setSmallIcon", "(I)Landroid/app/Notification$Builder;" ); - - // You could do things like setPriority, or setContentIntent if you want it to do something when you click it. - - env->CallObjectMethod( ENVCALL eventObj, setContentTitleID, titleStr ); - env->CallObjectMethod( ENVCALL eventObj, setContentTextID, messageStr ); - env->CallObjectMethod( ENVCALL eventObj, setSmallIconID, 17301504 ); // R.drawable.alert_dark_frame - - // eventObj.build() - jmethodID buildID = env->GetMethodID( ENVCALL classBuilder, "build", "()Landroid/app/Notification;" ); - jobject notification = env->CallObjectMethod( ENVCALL eventObj, buildID ); - - // NotificationManager.notify(...) - jmethodID notifyID = env->GetMethodID( ENVCALL NotificationManagerClass, "notify", "(ILandroid/app/Notification;)V" ); - env->CallVoidMethod( ENVCALL notificationServiceObj, notifyID, id, notification ); - - env->DeleteLocalRef( ENVCALL notification ); - env->DeleteLocalRef( ENVCALL titleStr ); - env->DeleteLocalRef( ENVCALL activityClass ); - env->DeleteLocalRef( ENVCALL messageStr ); - env->DeleteLocalRef( ENVCALL channelIDStr ); - env->DeleteLocalRef( ENVCALL NotificationManagerClass ); - env->DeleteLocalRef( ENVCALL notificationServiceObj ); - env->DeleteLocalRef( ENVCALL notificationServiceName ); - -} +//notification void MakeNotification( const char * channelID, const char * channelName, const char * title, const char * message ) +//notification { +//notification static int id; +//notification id++; +//notification +//notification const struct JNINativeInterface * env = 0; +//notification const struct JNINativeInterface ** envptr = &env; +//notification const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm; +//notification const struct JNIInvokeInterface * jnii = *jniiptr; +//notification +//notification jnii->AttachCurrentThread( jniiptr, &envptr, NULL); +//notification env = (*envptr); +//notification +//notification jstring channelIDStr = env->NewStringUTF( ENVCALL channelID ); +//notification jstring channelNameStr = env->NewStringUTF( ENVCALL channelName ); +//notification +//notification // Runs getSystemService(Context.NOTIFICATION_SERVICE). +//notification jclass NotificationManagerClass = env->FindClass( ENVCALL "android/app/NotificationManager" ); +//notification jclass activityClass = env->GetObjectClass( ENVCALL gapp->activity->clazz ); +//notification jmethodID MethodGetSystemService = env->GetMethodID( ENVCALL activityClass, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); +//notification jstring notificationServiceName = env->NewStringUTF( ENVCALL "notification" ); +//notification jobject notificationServiceObj = env->CallObjectMethod( ENVCALL gapp->activity->clazz, MethodGetSystemService, notificationServiceName); +//notification +//notification // create the Notification channel. +//notification jclass notificationChannelClass = env->FindClass( ENVCALL "android/app/NotificationChannel" ); +//notification jmethodID notificationChannelConstructorID = env->GetMethodID( ENVCALL notificationChannelClass, "", "(Ljava/lang/String;Ljava/lang/CharSequence;I)V" ); +//notification jobject notificationChannelObj = env->NewObject( ENVCALL notificationChannelClass, notificationChannelConstructorID, channelIDStr, channelNameStr, 3 ); // IMPORTANCE_DEFAULT +//notification jmethodID createNotificationChannelID = env->GetMethodID( ENVCALL NotificationManagerClass, "createNotificationChannel", "(Landroid/app/NotificationChannel;)V" ); +//notification env->CallVoidMethod( ENVCALL notificationServiceObj, createNotificationChannelID, notificationChannelObj ); +//notification +//notification env->DeleteLocalRef( ENVCALL channelNameStr ); +//notification env->DeleteLocalRef( ENVCALL notificationChannelObj ); +//notification +//notification // Create the Notification builder. +//notification jclass classBuilder = env->FindClass( ENVCALL "android/app/Notification$Builder" ); +//notification jstring titleStr = env->NewStringUTF( ENVCALL title ); +//notification jstring messageStr = env->NewStringUTF( ENVCALL message ); +//notification jmethodID eventConstructor = env->GetMethodID( ENVCALL classBuilder, "", "(Landroid/content/Context;Ljava/lang/String;)V" ); +//notification jobject eventObj = env->NewObject( ENVCALL classBuilder, eventConstructor, gapp->activity->clazz, channelIDStr ); +//notification jmethodID setContentTitleID = env->GetMethodID( ENVCALL classBuilder, "setContentTitle", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;" ); +//notification jmethodID setContentTextID = env->GetMethodID( ENVCALL classBuilder, "setContentText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;" ); +//notification jmethodID setSmallIconID = env->GetMethodID( ENVCALL classBuilder, "setSmallIcon", "(I)Landroid/app/Notification$Builder;" ); +//notification +//notification // You could do things like setPriority, or setContentIntent if you want it to do something when you click it. +//notification +//notification env->CallObjectMethod( ENVCALL eventObj, setContentTitleID, titleStr ); +//notification env->CallObjectMethod( ENVCALL eventObj, setContentTextID, messageStr ); +//notification env->CallObjectMethod( ENVCALL eventObj, setSmallIconID, 17301504 ); // R.drawable.alert_dark_frame +//notification +//notification // eventObj.build() +//notification jmethodID buildID = env->GetMethodID( ENVCALL classBuilder, "build", "()Landroid/app/Notification;" ); +//notification jobject notification = env->CallObjectMethod( ENVCALL eventObj, buildID ); +//notification +//notification // NotificationManager.notify(...) +//notification jmethodID notifyID = env->GetMethodID( ENVCALL NotificationManagerClass, "notify", "(ILandroid/app/Notification;)V" ); +//notification env->CallVoidMethod( ENVCALL notificationServiceObj, notifyID, id, notification ); +//notification +//notification env->DeleteLocalRef( ENVCALL notification ); +//notification env->DeleteLocalRef( ENVCALL titleStr ); +//notification env->DeleteLocalRef( ENVCALL activityClass ); +//notification env->DeleteLocalRef( ENVCALL messageStr ); +//notification env->DeleteLocalRef( ENVCALL channelIDStr ); +//notification env->DeleteLocalRef( ENVCALL NotificationManagerClass ); +//notification env->DeleteLocalRef( ENVCALL notificationServiceObj ); +//notification env->DeleteLocalRef( ENVCALL notificationServiceName ); +//notification +//notification } void HandleThisWindowTermination() { @@ -516,7 +516,7 @@ uint32_t randomtexturedata[256*256]; int main( int argc, char ** argv ) { - int x, y; +//Heightmap int x, y; double ThisTime; double LastFPSTime = OGGetAbsoluteTime(); @@ -527,11 +527,11 @@ int main( int argc, char ** argv ) HandleWindowTermination = HandleThisWindowTermination; - for( x = 0; x < HMX; x++ ) - for( y = 0; y < HMY; y++ ) - { - Heightmap[x+y*HMX] = tdPerlin2D( x, y )*8.; - } +//Heightmap for( x = 0; x < HMX; x++ ) +//Heightmap for( y = 0; y < HMY; y++ ) +//Heightmap { +//Heightmap Heightmap[x+y*HMX] = tdPerlin2D( x, y )*8.; +//Heightmap } //A-s-s-e-t-s const char * assettext = "Not Found,2"; //A-s-s-e-t-s AAsset * file = AAssetManager_open( gapp->activity->assetManager, "asset.txt", AASSET_MODE_BUFFER ); @@ -563,10 +563,10 @@ int main( int argc, char ** argv ) int i; iframeno++; - if( iframeno == 200 ) - { - MakeNotification( "default", "rawdraw alerts", "rawdraw", "Hit frame two hundred\nNew Line" ); - } +//notification if( iframeno == 200 ) +//notification { +//notification MakeNotification( "default", "rawdraw alerts", "rawdraw", "Hit frame two hundred\nNew Line" ); +//notification } CNFGHandleInput(); //SENSORSTURFF AccCheck(); @@ -582,7 +582,7 @@ int main( int argc, char ** argv ) // Mesh in background CNFGSetLineWidth( 9 ); - DrawHeightmap(); +//Heightmap DrawHeightmap(); CNFGPenX = 0; CNFGPenY = 400; CNFGColor( 0xffffffff ); //A-s-s-e-t-s CNFGDrawText( assettext, 15 ); @@ -594,27 +594,27 @@ int main( int argc, char ** argv ) CNFGDrawText( st, 10 ); CNFGSetLineWidth( 2 ); - // Square behind text - CNFGColor( 0x303030ff ); - CNFGTackRectangle( 600, 0, 950, 350); - - CNFGPenX = 10; CNFGPenY = 10; - - // Text - CNFGColor( 0xffffffff ); - for( i = 0; i < 1; i++ ) - { - int c; - char tw[2] = { 0, 0 }; - for( c = 0; c < 256; c++ ) - { - tw[0] = c; - - CNFGPenX = ( c % 16 ) * 20+606; - CNFGPenY = ( c / 16 ) * 20+5; - CNFGDrawText( tw, 4 ); - } - } +//texts // Square behind text +//texts CNFGColor( 0x303030ff ); +//texts CNFGTackRectangle( 600, 0, 950, 350); +//texts +//texts CNFGPenX = 10; CNFGPenY = 10; +//texts +//texts // Text +//texts CNFGColor( 0xffffffff ); +//texts for( i = 0; i < 1; i++ ) +//texts { +//texts int c; +//texts char tw[2] = { 0, 0 }; +//texts for( c = 0; c < 256; c++ ) +//texts { +//texts tw[0] = c; +//texts +//texts CNFGPenX = ( c % 16 ) * 20+606; +//texts CNFGPenY = ( c / 16 ) * 20+5; +//texts CNFGDrawText( tw, 4 ); +//texts } +//texts } // Green triangles CNFGPenX = 0;