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
cd ..\src\main\assets\source
REM del 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 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 DVRSource.zip ..\..\..\..\..\*
cd ..\..\..\..\jni

View file

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

View file

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

View file

@ -460,11 +460,16 @@ void I_UpdateNoBlit (void)
void I_FinishUpdate (int eye)
{
// Get pixels
int i;
int size = X_width * X_height;
// 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");

View file

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

View file

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

View file

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

View file

@ -558,7 +558,7 @@ void V_UpdateTrueColorPalette(video_mode_t mode) {
ng = (int)(g*t+roundUpG);
nb = (int)(b*t+roundUpB);
Palettes32[((p*256+i)*VID_NUMCOLORWEIGHTS)+w] = (
(nr<<16) | (ng<<8) | nb
(nr<<16) | (ng<<8) | nb
);
}
}

View file

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

View file

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

View file

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

View file

@ -9,7 +9,6 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.util.Pair;
import com.google.vrtoolkit.cardboard.Eye;
@ -22,7 +21,6 @@ import java.util.List;
import java.util.Map;
import doom.util.DoomTools;
import doom.util.Natives;
/**
* Created by Simon on 04/03/2016.
@ -120,7 +118,7 @@ public class WADChooser {
paint.setAntiAlias(true);
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]);
}
@ -161,7 +159,7 @@ public class WADChooser {
// Object first appears directly in front of user.
Matrix.setIdentityM(openGL.modelScreen, 0);
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.modelViewProjection, 0, perspective, 0, openGL.modelView, 0);
GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices);