Fixes to get Android tests rendering

This commit is contained in:
Aaron Culliney 2015-02-24 20:53:19 -08:00
parent fadb806c92
commit c3969f9d1d
4 changed files with 35 additions and 39 deletions

View File

@ -64,7 +64,6 @@ void Java_org_deadc0de_apple2_Apple2Activity_nativeOnPause(JNIEnv *env, jobject
void Java_org_deadc0de_apple2_Apple2Activity_nativeRender(JNIEnv *env, jobject obj) {
c_keys_handle_input(-1, 0, 0);
#define FPS_LOG 1
#if FPS_LOG
static uint32_t prevCount = 0;
static uint32_t idleCount = 0;
@ -82,8 +81,6 @@ void Java_org_deadc0de_apple2_Apple2Activity_nativeRender(JNIEnv *env, jobject o
}
#endif
if (_vid_dirty) {
video_driver_render();
}
video_driver_render();
}

View File

@ -68,18 +68,14 @@ public class Apple2Activity extends Activity {
Log.d(TAG, "First time copying stuff-n-things out of APK for ease-of-NDK access...");
try {
_copyFile(dataDir, "shaders", "Basic.vsh");
_copyFile(dataDir, "shaders", "Basic.fsh");
_copyFile(dataDir, "disks", "blank.dsk");
_copyFile(dataDir, "disks", "blank.nib");
_copyFile(dataDir, "disks", "blank.po");
_copyFile(dataDir, "disks", "etc.dsk");
_copyFile(dataDir, "disks", "flapple140.po");
_copyFile(dataDir, "disks", "mystery.dsk");
_copyFile(dataDir, "disks", "ProDOS.dsk");
_copyFile(dataDir, "disks", "speedtest.dsk");
_copyFile(dataDir, "disks", "testdisplay1.dsk");
_copyFile(dataDir, "disks", "testvm1.dsk");
String[] shaders = getAssets().list("shaders");
for (String shader : shaders) {
_copyFile(dataDir, "shaders", shader);
}
String[] disks = getAssets().list("disks");
for (String disk : disks) {
_copyFile(dataDir, "disks", disk);
}
} catch (IOException e) {
Log.e(TAG, "problem copying resources : "+e);
System.exit(1);

View File

@ -49,7 +49,7 @@ import javax.microedition.khronos.opengles.GL10;
*/
class Apple2View extends GLSurfaceView {
private final static String TAG = "Apple2View";
private final static boolean DEBUG = true;
private final static boolean DEBUG = false;
private Apple2Activity mActivity = null;
@ -165,10 +165,8 @@ class Apple2View extends GLSurfaceView {
// Now return the "best" one
EGLConfig best = chooseConfig(egl, display, configs);
if (DEBUG) {
Log.w(TAG, "BEST CONFIG : ");
printConfig(egl, display, best);
}
Log.w(TAG, "Using EGL CONFIG : ");
printConfig(egl, display, best);
return best;
}

View File

@ -324,12 +324,16 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
// Determine if GLSL version 140 is supported by this context.
// We'll use this info to generate a GLSL shader source string
// with the proper version preprocessor string prepended
float glLanguageVersion;
float glLanguageVersion = 0.f;
char *shaderLangVersion = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
if (shaderLangVersion == NULL) {
ERRQUIT("shader toolchain unavailable");
}
#if TARGET_OS_IPHONE
sscanf((char *)glGetString(GL_SHADING_LANGUAGE_VERSION), "OpenGL ES GLSL ES %f", &glLanguageVersion);
sscanf(shaderLangVersion, "OpenGL ES GLSL ES %f", &glLanguageVersion);
#else
sscanf((char *)glGetString(GL_SHADING_LANGUAGE_VERSION), "%f", &glLanguageVersion);
sscanf(shaderLangVersion, "%f", &glLanguageVersion);
#endif
// GL_SHADING_LANGUAGE_VERSION returns the version standard version form
@ -620,9 +624,7 @@ static void gldriver_update(int unused) {
#endif
c_keys_handle_input(-1, 0, 0);
if (_vid_dirty) {
glutPostRedisplay();
}
glutPostRedisplay();
glutTimerFunc(17, gldriver_update, 0);
}
#endif
@ -660,22 +662,25 @@ static void gldriver_render(void) {
// that we calculated above
glUniformMatrix4fv(uniformMVPIdx, 1, GL_FALSE, mvp);
// Update texture from indexed-color Apple //e internal framebuffer
unsigned int count = SCANWIDTH * SCANHEIGHT;
char pixels[SCANWIDTH * SCANHEIGHT * 4];
for (unsigned int i=0, j=0; i<count; i++, j+=4) {
uint8_t index = *(fb + i);
*( (uint32_t*)(pixels + j) ) = (uint32_t)(
((uint32_t)(colormap[index].red) << 0 ) |
((uint32_t)(colormap[index].green) << 8 ) |
((uint32_t)(colormap[index].blue) << 16) |
((uint32_t)0xff << 24)
);
if (_vid_dirty) {
// Update texture from indexed-color Apple //e internal framebuffer
unsigned int count = SCANWIDTH * SCANHEIGHT;
for (unsigned int i=0, j=0; i<count; i++, j+=4) {
uint8_t index = *(fb + i);
*( (uint32_t*)(pixels + j) ) = (uint32_t)(
((uint32_t)(colormap[index].red) << 0 ) |
((uint32_t)(colormap[index].green) << 8 ) |
((uint32_t)(colormap[index].blue) << 16) |
((uint32_t)0xff << 24)
);
}
}
glBindTexture(GL_TEXTURE_2D, a2TextureName);
glTexImage2D(GL_TEXTURE_2D, /*level*/0, /*internal format*/GL_RGBA, SCANWIDTH, SCANHEIGHT, /*border*/0, /*format*/GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)&pixels[0]);
glGetError();
if (_vid_dirty) {
glTexImage2D(GL_TEXTURE_2D, /*level*/0, /*internal format*/GL_RGBA, SCANWIDTH, SCANHEIGHT, /*border*/0, /*format*/GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)&pixels[0]);
}
// Bind our vertex array object
#if USE_VAO