So many improvements!

- Enabled 32 bit colour mode
- Allowed any resolution (default now 800x600 for speed)
- Improve world scale a bit
- Reduce size of player sprite and give a bit of depth for comfort
- Make DVR logo spin
This commit is contained in:
Simon 2016-03-06 21:48:37 +00:00
parent cb484b0058
commit 61058cab74
12 changed files with 93 additions and 60 deletions

View file

@ -11,6 +11,6 @@ rename libs.zip libs.jar
REM Create an archive of the source REM Create an archive of the source
cd ..\src\main\assets\source cd ..\src\main\assets\source
REM del D-VRSource.zip REM del DVRSource.zip
REM 7z a -r -x!.git* -x!*.o -x!*.d -x!obj -x!*.bin -x!app\build -x!app\libs -x!*.jar -x!*.so -x!*.log -x!*.jks -x!*.apk D-VRSource.zip ..\..\..\..\..\* REM 7z a -r -x!.git* -x!*.o -x!*.d -x!obj -x!*.bin -x!app\build -x!app\libs -x!*.jar -x!*.so -x!*.log -x!*.jks -x!*.apk DVRSource.zip ..\..\..\..\..\*
cd ..\..\..\..\jni cd ..\..\..\..\jni

View file

@ -179,7 +179,7 @@ void D_PostEvent(event_t *ev)
static void D_Wipe(int eye) static void D_Wipe(int eye)
{ {
/*
boolean done; boolean done;
int wipestart = I_GetTime () - 1; int wipestart = I_GetTime () - 1;
@ -200,7 +200,7 @@ static void D_Wipe(int eye)
I_FinishUpdate(eye); // page flip or blit buffer I_FinishUpdate(eye); // page flip or blit buffer
} }
while (!done); while (!done);
*/
M_Drawer(); // menu is drawn even on top of wipes M_Drawer(); // menu is drawn even on top of wipes
I_FinishUpdate(eye); // page flip or blit buffer I_FinishUpdate(eye); // page flip or blit buffer
@ -215,6 +215,7 @@ static void D_Wipe(int eye)
gamestate_t wipegamestate = GS_DEMOSCREEN; gamestate_t wipegamestate = GS_DEMOSCREEN;
extern boolean setsizeneeded; extern boolean setsizeneeded;
extern int showMessages; extern int showMessages;
int current_eye;
void D_Display (int eye) void D_Display (int eye)
{ {
@ -224,6 +225,7 @@ void D_Display (int eye)
static gamestate_t oldgamestate = -1; static gamestate_t oldgamestate = -1;
boolean wipe; boolean wipe;
boolean viewactive = false, isborder = false; boolean viewactive = false, isborder = false;
current_eye = eye;
if (nodrawers) // for comparative timing / profiling if (nodrawers) // for comparative timing / profiling
return; return;
@ -323,11 +325,11 @@ void D_Display (int eye)
// normal update // normal update
// if (!wipe || (V_GetMode() == VID_MODEGL)) // if (!wipe || (V_GetMode() == VID_MODEGL))
I_FinishUpdate (eye); // page flip or blit buffer I_FinishUpdate (eye); // page flip or blit buffer
// else { /* else {
// wipe update // wipe update
// wipe_EndScreen(); wipe_EndScreen();
// D_Wipe(eye); D_Wipe(eye);
// } }*/
if (eye == 1) { if (eye == 1) {
I_EndDisplay(); I_EndDisplay();

View file

@ -37,6 +37,7 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <android/log.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
@ -454,25 +455,49 @@ static int newpal = 0;
void I_FinishUpdate (int eye) void I_FinishUpdate (int eye)
{ {
// __android_log_print(ANDROID_LOG_INFO, "I_FinishUpdate", "got this far!");
if (I_SkipFrame()) return; if (I_SkipFrame()) return;
// screen size // screen size
int size = SCREENWIDTH * SCREENHEIGHT; int size = SCREENWIDTH * SCREENHEIGHT;
// ARGB pixels // ARGB pixels
int pixels[size], i; static int *pixels = 0;
if (V_GetMode() == VID_MODE32) {
/*for (i = 0; i < size; i++) {
byte r = screens[0].data[i * 4];
byte g = screens[0].data[i * 4 + 1];
byte b = screens[0].data[i * 4 + 2];
//alpha is ignored
byte a = screens[0].data[i * 4 + 3];
pixels[i] = (0xFF << 24)
| (b << 16)
| (g << 8)
| r;
}*/
//memcpy(pixels, screens[0].data, size * sizeof(int));
//We can literally just pass the pointer to the screen buffer
pixels = (int*)screens[0].data;
}
else if (V_GetMode() == VID_MODE8) {
if (!pixels)
{
pixels = (int*)malloc(size * sizeof(int) + 1);
}
int i;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
byte b = screens[0].data[i]; byte b = screens[0].data[i];
XColor color = colours[b]; XColor color = colours[b];
pixels[i] = (0xFF << 24) pixels[i] = (0xFF << 24)
| (color.red << 16) | (color.red << 16)
| (color.green << 8) | (color.green << 8)
| color.blue; | color.blue;
} }
}
// Send pixels to java // Send pixels to java
jni_send_pixels(pixels, eye); jni_send_pixels(pixels, eye);
@ -656,11 +681,11 @@ void I_CalculateRes(unsigned int width, unsigned int height)
} else { */ } else { */
SCREENWIDTH = (width+15) & ~15; SCREENWIDTH = (width+15) & ~15;
SCREENHEIGHT = height; SCREENHEIGHT = height;
if (!(SCREENWIDTH % 1024)) { // if (!(SCREENWIDTH % 1024)) {
SCREENPITCH = SCREENWIDTH*V_GetPixelDepth()+32; // SCREENPITCH = SCREENWIDTH*V_GetPixelDepth()+32;
} else { // } else {
SCREENPITCH = SCREENWIDTH*V_GetPixelDepth(); SCREENPITCH = SCREENWIDTH*V_GetPixelDepth();
} // }
// } // }
} }
@ -671,12 +696,12 @@ void I_SetRes(void)
{ {
int i; int i;
I_CalculateRes(SCREENWIDTH, SCREENHEIGHT);
// Tell Java graphics have inited // Tell Java graphics have inited
jni_printf("I_SetRes: Creating %dx%d image.", SCREENWIDTH, SCREENHEIGHT); jni_printf("I_SetRes: Creating %dx%d image.", SCREENWIDTH, SCREENHEIGHT);
jni_init_graphics(SCREENWIDTH, SCREENHEIGHT); jni_init_graphics(SCREENWIDTH, SCREENHEIGHT);
I_CalculateRes(SCREENWIDTH, SCREENHEIGHT);
// set first three to standard values // set first three to standard values
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
screens[i].width = SCREENWIDTH; screens[i].width = SCREENWIDTH;

View file

@ -460,11 +460,16 @@ void I_UpdateNoBlit (void)
void I_FinishUpdate (int eye) void I_FinishUpdate (int eye)
{ {
// Get pixels // Get pixels
int i;
int size = X_width * X_height; int size = X_width * X_height;
// ARGB pixels // ARGB pixels
int pixels[size]; // ARGB pixels
static int *pixels = 0;
if (!pixels)
{
pixels = (int*)malloc(size * sizeof(int) + 1);
}
int i;
//printf("I_FinishUpdate\n"); //printf("I_FinishUpdate\n");

View file

@ -63,7 +63,7 @@ tic_vars_t tic_vars;
view_vars_t original_view_vars; view_vars_t original_view_vars;
fixed_t r_stereo_offset = 0x40000; fixed_t r_stereo_offset = 0x30000;
extern int realtic_clock_rate; extern int realtic_clock_rate;
void D_Display(void); void D_Display(void);

View file

@ -400,10 +400,10 @@ void R_ExecuteSetViewSize (void)
// psprite scales // psprite scales
// proff 08/17/98: Changed for high-res // proff 08/17/98: Changed for high-res
pspritescale = FRACUNIT*viewwidth/320; pspritescale = FRACUNIT*viewwidth/480;
pspriteiscale = FRACUNIT*320/viewwidth; pspriteiscale = FRACUNIT*480/viewwidth;
// proff 11/06/98: Added for high-res // proff 11/06/98: Added for high-res
pspriteyscale = (((SCREENHEIGHT*viewwidth)/SCREENWIDTH) << FRACBITS) / 200; pspriteyscale = (((SCREENHEIGHT*viewwidth)/SCREENWIDTH) << FRACBITS) / 300;
// thing clipping // thing clipping
for (i=0 ; i<viewwidth ; i++) for (i=0 ; i<viewwidth ; i++)

View file

@ -41,6 +41,7 @@
#include "r_fps.h" #include "r_fps.h"
#include "v_video.h" #include "v_video.h"
#include "lprintf.h" #include "lprintf.h"
#include <android/log.h>
#define MINZ (FRACUNIT*4) #define MINZ (FRACUNIT*4)
#define BASEYCENTER 100 #define BASEYCENTER 100
@ -86,6 +87,8 @@ int numsprites;
static spriteframe_t sprtemp[MAX_SPRITE_FRAMES]; static spriteframe_t sprtemp[MAX_SPRITE_FRAMES];
static int maxframe; static int maxframe;
extern int current_eye;
// //
// R_InstallSpriteLump // R_InstallSpriteLump
// Local function for R_InitSprites. // Local function for R_InitSprites.
@ -725,14 +728,16 @@ static void R_DrawPSprite (pspdef_t *psp, int lightlevel)
fixed_t tx; fixed_t tx;
tx = psp->sx-160*FRACUNIT; tx = psp->sx-160*FRACUNIT;
int r_stereo_offset = (current_eye == 0) ? 35 : -35;
tx -= patch->leftoffset<<FRACBITS; tx -= patch->leftoffset<<FRACBITS;
x1 = (centerxfrac + FixedMul (tx,pspritescale))>>FRACBITS; x1 = ((centerxfrac + FixedMul (tx,pspritescale))>>FRACBITS) + r_stereo_offset;
tx += patch->width<<FRACBITS; tx += patch->width<<FRACBITS;
x2 = ((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1; x2 = (((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1) + r_stereo_offset;
width = patch->width; width = patch->width;
topoffset = patch->topoffset<<FRACBITS; topoffset = (patch->topoffset - 30)<<FRACBITS;
R_UnlockPatchNum(lump+firstspritelump); R_UnlockPatchNum(lump+firstspritelump);
} }

View file

@ -76,9 +76,9 @@ mus_pause_opt 2
snd_channels 8 snd_channels 8
# Video settings # Video settings
videomode "8" videomode "32"
screen_width 640 screen_width 800
screen_height 400 screen_height 600
use_fullscreen 1 use_fullscreen 1
use_doublebuffer 1 use_doublebuffer 1
translucency 1 translucency 1

View file

@ -8,9 +8,7 @@ import android.content.res.AssetManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.opengl.GLES11Ext;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.opengl.Matrix; import android.opengl.Matrix;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
@ -36,11 +34,7 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
@ -333,6 +327,9 @@ public class MainActivity
if (newState != prevState) if (newState != prevState)
{ {
prevState = newState; prevState = newState;
//Reset head tracker in big screen mode
if (newState != 0)
cardboardView.resetHeadTracker(); cardboardView.resetHeadTracker();
} }
} }
@ -383,14 +380,17 @@ public class MainActivity
// for calculating screen position. // for calculating screen position.
float[] perspective = eye.getPerspective(0.1f, 100.0f); float[] perspective = eye.getPerspective(0.1f, 100.0f);
float scale = openGL.screenScale;
if (mShowingSpashScreen)
scale /= 2;
// Object first appears directly in front of user. // Object first appears directly in front of user.
Matrix.setIdentityM(openGL.modelScreen, 0); Matrix.setIdentityM(openGL.modelScreen, 0);
Matrix.translateM(openGL.modelScreen, 0, 0, 0, -openGL.screenDistance); Matrix.translateM(openGL.modelScreen, 0, 0, 0, -openGL.screenDistance);
Matrix.scaleM(openGL.modelScreen, 0, scale, scale, 1.0f); Matrix.scaleM(openGL.modelScreen, 0, openGL.screenScale, openGL.screenScale, 1.0f);
// Set the position of the screen
if (mShowingSpashScreen) {
float mAngle = 360.0f * (float)((System.currentTimeMillis() % 2000) / 2000.0f);
Matrix.rotateM(openGL.modelScreen, 0, mAngle, 0.0f, 1.0f, 0.0f);
}
Matrix.multiplyMM(openGL.modelView, 0, openGL.view, 0, openGL.modelScreen, 0); Matrix.multiplyMM(openGL.modelView, 0, openGL.view, 0, openGL.modelScreen, 0);
Matrix.multiplyMM(openGL.modelViewProjection, 0, perspective, 0, openGL.modelView, 0); Matrix.multiplyMM(openGL.modelViewProjection, 0, perspective, 0, openGL.modelView, 0);
GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices); GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices);
@ -729,8 +729,7 @@ public class MainActivity
*/ */
@Override @Override
public void OnImageUpdate(int[] pixels, int eye) { public void OnImageUpdate(int[] pixels, int eye) {
mDoomBitmap.setPixels(pixels, 0, mDoomWidth, 0, 0, mDoomWidth, mDoomBitmap.setPixels(pixels, 0, mDoomWidth, 0, 0, mDoomWidth, mDoomHeight);
mDoomHeight);
} }
/** /**

View file

@ -148,8 +148,7 @@ public class OpenGL {
public float[] modelView; public float[] modelView;
public float screenDistance = 8f; public float screenDistance = 8f;
public float screenScale = 4f; public float screenScale = 3f;
public float wadChooserScale = 2.5f;
public static final String vs_Image = public static final String vs_Image =
"uniform mat4 u_MVPMatrix;" + "uniform mat4 u_MVPMatrix;" +
@ -241,10 +240,10 @@ public class OpenGL {
}; };
public static final float[] SCREEN_COORDS = new float[] { public static final float[] SCREEN_COORDS = new float[] {
-1.3f, -1.0f, 1.0f, -1.3f, -1.0f, 0.0f,
-1.3f, 1.0f, 1.0f, -1.3f, 1.0f, 0.0f,
1.3f, 1.0f, 1.0f, 1.3f, 1.0f, 0.0f,
1.3f, -1.0f, 1.0f 1.3f, -1.0f, 0.0f
}; };
public FloatBuffer vertexBuffer; public FloatBuffer vertexBuffer;

View file

@ -9,7 +9,6 @@ import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.Matrix; import android.opengl.Matrix;
import android.util.Pair;
import com.google.vrtoolkit.cardboard.Eye; import com.google.vrtoolkit.cardboard.Eye;
@ -22,7 +21,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import doom.util.DoomTools; import doom.util.DoomTools;
import doom.util.Natives;
/** /**
* Created by Simon on 04/03/2016. * Created by Simon on 04/03/2016.
@ -120,7 +118,7 @@ public class WADChooser {
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setARGB(0xff, 0xff, 0x20, 0x00); paint.setARGB(0xff, 0xff, 0x20, 0x00);
canvas.drawText("<- " + GetChosenWAD() + " ->", 16, 220, paint); canvas.drawText("<- " + GetChosenWAD() + " ->", 24, 220, paint);
openGL.CopyBitmapToTexture(bitmap, openGL.fbo.ColorTexture[0]); openGL.CopyBitmapToTexture(bitmap, openGL.fbo.ColorTexture[0]);
} }
@ -161,7 +159,7 @@ public class WADChooser {
// Object first appears directly in front of user. // Object first appears directly in front of user.
Matrix.setIdentityM(openGL.modelScreen, 0); Matrix.setIdentityM(openGL.modelScreen, 0);
Matrix.translateM(openGL.modelScreen, 0, 0, 0, -openGL.screenDistance); Matrix.translateM(openGL.modelScreen, 0, 0, 0, -openGL.screenDistance);
Matrix.scaleM(openGL.modelScreen, 0, openGL.wadChooserScale, openGL.wadChooserScale, 1.0f); Matrix.scaleM(openGL.modelScreen, 0, openGL.screenScale, openGL.screenScale, 1.0f);
Matrix.multiplyMM(openGL.modelView, 0, openGL.view, 0, openGL.modelScreen, 0); Matrix.multiplyMM(openGL.modelView, 0, openGL.view, 0, openGL.modelScreen, 0);
Matrix.multiplyMM(openGL.modelViewProjection, 0, perspective, 0, openGL.modelView, 0); Matrix.multiplyMM(openGL.modelViewProjection, 0, perspective, 0, openGL.modelView, 0);
GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices); GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices);