Merge pull request #1480 from mar753/lowering_rendering_resolution_option

Lowering rendering resolution option
This commit is contained in:
baka0815 2019-02-04 19:36:11 +01:00 committed by GitHub
commit 3c8e1110c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 490 additions and 47 deletions

View File

@ -299,6 +299,10 @@ void LoadSettings()
settings.rend.UseMipmaps = cfgLoadInt("config", "rend.UseMipmaps", 1);
settings.rend.WideScreen = cfgLoadInt("config", "rend.WideScreen", 0);
settings.rend.Clipping = cfgLoadInt("config", "rend.Clipping", 1);
settings.rend.
VerticalResolution = cfgLoadInt("config", "rend.ResolutionPercentage", 100);
settings.rend.
HorizontalResolution = cfgLoadInt("config", "rend.ResolutionPercentage", 100);
settings.pvr.subdivide_transp = cfgLoadInt("config", "pvr.Subdivide", 0);

View File

@ -1081,7 +1081,7 @@ void DrawModVols()
glStencilFunc(GL_EQUAL,0x81,0x81); //only pixels that are Modvol enabled, and in area 1
//clear the stencil result bit
glStencilMask(0x3); //write to lsb
glStencilMask(0x3); //write to lsb
glStencilOp(GL_ZERO,GL_ZERO,GL_ZERO);
#ifndef NO_STENCIL_WORKAROUND
//looks like a driver bug ?
@ -1155,3 +1155,89 @@ void DrawStrips()
#endif
}
}
void fullscreenQuadPrepareFramebuffer(float xScale, float yScale) {
// Bind the default framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, screen_width, screen_height);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reduce width to keep 4:3 aspect ratio (640x480)
u32 reducedWidth = 4 * screen_height / 3;
u32 reducedWidthOffset = (screen_width - reducedWidth) / 2;
glScissor(reducedWidthOffset, 0, reducedWidth, screen_height);
if (settings.rend.WideScreen &&
(pvrrc.fb_X_CLIP.min==0) && ((pvrrc.fb_X_CLIP.max+1)/xScale==640) &&
(pvrrc.fb_Y_CLIP.min==0) && ((pvrrc.fb_Y_CLIP.max+1)/yScale==480 ))
{
glDisable(GL_SCISSOR_TEST);
}
else
{
glEnable(GL_SCISSOR_TEST);
}
}
void fullscreenQuadBindVertexData(float screenToNativeXScale, float screenToNativeYScale,
GLint & vsPosition, GLint & vsTexcoord, GLint & fsTexture)
{
u32 quadVerticesNumber = 4;
glUseProgram(gl.fullscreenQuadShader);
glBindBuffer(GL_ARRAY_BUFFER, fullscreenQuad.positionsBuffer);
glEnableVertexAttribArray( vsPosition );
glVertexAttribPointer(vsPosition, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, fullscreenQuad.texcoordsBuffer);
glEnableVertexAttribArray( vsTexcoord );
const float2 texcoordsArray[] =
{
{ screenToNativeXScale, screenToNativeYScale },
{ 0.0f, screenToNativeYScale },
{ 0.0f, 0.0f },
{ screenToNativeXScale, 0.0f },
};
glBufferData(GL_ARRAY_BUFFER, sizeof(float2) * quadVerticesNumber, texcoordsArray, GL_STATIC_DRAW);
glVertexAttribPointer(vsTexcoord, 2, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fullscreenQuad.indexBuffer);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, fullscreenQuad.framebufferTexture);
glUniform1i(fsTexture, 0);
}
void DrawFullscreenQuad(float screenToNativeXScale, float screenToNativeYScale, float xScale, float yScale) {
u32 quadIndicesNumber = 6;
GLint boundArrayBuffer = 0;
GLint boundElementArrayBuffer = 0;
GLint vsPosition= glGetAttribLocation(gl.fullscreenQuadShader, "position");
GLint vsTexcoord= glGetAttribLocation(gl.fullscreenQuadShader, "texture_coord");
GLint fsTexture = glGetUniformLocation(gl.fullscreenQuadShader, "texture_data");
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &boundArrayBuffer);
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &boundElementArrayBuffer);
fullscreenQuadPrepareFramebuffer(xScale, yScale);
fullscreenQuadBindVertexData(screenToNativeXScale, screenToNativeYScale, vsPosition, vsTexcoord, fsTexture);
glDrawElements(GL_TRIANGLES, quadIndicesNumber, GL_UNSIGNED_BYTE, 0);
// Unbind buffers
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER, boundArrayBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, boundElementArrayBuffer);
glDisableVertexAttribArray( vsPosition );
glDisableVertexAttribArray( vsTexcoord );
// Restore vertex attribute pointers (OSD drawing preparation)
SetupMainVBO();
}

View File

@ -421,6 +421,62 @@ void main() \n\
gl_FragColor=vtx_base*texture(tex,uv.st); \n\n\
}";
const char* FullscreenQuadVertexShader =
"%s \n\
\n\
#define TARGET_GL %s \n\
\n\
#define GLES2 0 \n\
#define GLES3 1 \n\
#define GL2 2 \n\
#define GL3 3 \n\
\n\
#if TARGET_GL == GLES2 || TARGET_GL == GL2 \n\
#define in attribute \n\
#define out varying \n\
#endif \n\
\n\
in vec3 position; \n\
in vec2 texture_coord; \n\
\n\
out vec2 vs_texture_coord; \n\
\n\
void main() \n\
{ \n\
vs_texture_coord = texture_coord; \n\
gl_Position = vec4(position, 1); \n\
}";
const char* FullscreenQuadFragmentShader =
"%s \n\
\n\
#define TARGET_GL %s \n\
\n\
#define GLES2 0 \n\
#define GLES3 1 \n\
#define GL2 2 \n\
#define GL3 3 \n\
\n\
#if TARGET_GL == GLES2 || TARGET_GL == GLES3 \n\
precision mediump float; \n\
#endif \n\
\n\
#if TARGET_GL != GLES2 && TARGET_GL != GL2 \n\
out vec4 FragColor; \n\
#define gl_FragColor FragColor \n\
#else \n\
#define in varying \n\
#define texture texture2D \n\
#endif \n\
\n\
uniform sampler2D texture_data; \n\
\n\
in vec2 vs_texture_coord; \n\
\n\
void main() \n\
{ \n\
gl_FragColor = texture(texture_data, vs_texture_coord.st); \n\
}";
gl_ctx gl;
@ -428,6 +484,8 @@ int screen_width;
int screen_height;
GLuint fogTextureId;
GLFramebufferData fullscreenQuad;
#if (HOST_OS != OS_DARWIN) && !defined(TARGET_NACL32)
#if defined(GLES) && !defined(USE_SDL)
// Create a basic GLES context
@ -824,7 +882,15 @@ GLuint gl_CompileShader(const char* shader,GLuint type)
*compile_log=0;
glGetShaderInfoLog(rv, compile_log_len, &compile_log_len, compile_log);
printf("Shader: %s \n%s\n",result?"compiled!":"failed to compile",compile_log);
if (type == GL_VERTEX_SHADER) {
printf("Vertex shader: %s \n%s\n", result ? "compiled!" : "failed to compile", compile_log);
}
else if (type == GL_FRAGMENT_SHADER) {
printf("Fragment shader: %s \n%s\n", result ? "compiled!" : "failed to compile", compile_log);
}
else {
printf("Shader: %s \n%s\n", result ? "compiled!" : "failed to compile", compile_log);
}
free(compile_log);
}
@ -832,7 +898,10 @@ GLuint gl_CompileShader(const char* shader,GLuint type)
return rv;
}
GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader)
GLuint gl_CompileAndLink(
const char* VertexShader,
const char* FragmentShader,
void (*bindAttribLocationCallback)(GLuint) = NULL)
{
//create shaders
GLuint vs=gl_CompileShader(VertexShader ,GL_VERTEX_SHADER);
@ -842,15 +911,9 @@ GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader)
glAttachShader(program, vs);
glAttachShader(program, ps);
//bind vertex attribute to vbo inputs
glBindAttribLocation(program, VERTEX_POS_ARRAY, "in_pos");
glBindAttribLocation(program, VERTEX_COL_BASE_ARRAY, "in_base");
glBindAttribLocation(program, VERTEX_COL_OFFS_ARRAY, "in_offs");
glBindAttribLocation(program, VERTEX_UV_ARRAY, "in_uv");
#ifndef GLES
glBindFragDataLocation(program, 0, "FragColor");
#endif
if (bindAttribLocationCallback != NULL) {
bindAttribLocationCallback(program);
}
glLinkProgram(program);
@ -874,6 +937,8 @@ GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader)
die("shader compile fail\n");
}
glDetachShader(program, vs);
glDetachShader(program, ps);
glDeleteShader(vs);
glDeleteShader(ps);
@ -902,6 +967,65 @@ int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode,
return rv;
}
void generateFullscreenQuadVertices() {
const u32 verticesNumber = 4;
const u32 indicesNumber = 6;
const float3 quadPositions[] =
{
{ 1.0f, 1.0f, 0.0f },
{ -1.0f, 1.0f, 0.0f },
{ -1.0f, -1.0f, 0.0f },
{ 1.0f, -1.0f, 0.0f },
};
if (!fullscreenQuad.positionsBuffer) {
glGenBuffers(1, &fullscreenQuad.positionsBuffer);
}
glBindBuffer(GL_ARRAY_BUFFER, fullscreenQuad.positionsBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(float3) * verticesNumber, quadPositions, GL_STATIC_DRAW);
const float2 quadTexcoords[] =
{
{ 1.0f, 1.0f },
{ 0.0f, 1.0f },
{ 0.0f, 0.0f },
{ 1.0f, 0.0f },
};
if (!fullscreenQuad.texcoordsBuffer) {
glGenBuffers(1, &fullscreenQuad.texcoordsBuffer);
}
glBindBuffer(GL_ARRAY_BUFFER, fullscreenQuad.texcoordsBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(float2) * verticesNumber, quadTexcoords, GL_STATIC_DRAW);
const u8 quadIndices[] =
{
0, 1, 2,
0, 2, 3,
};
if (!fullscreenQuad.indexBuffer) {
glGenBuffers(1, &fullscreenQuad.indexBuffer);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fullscreenQuad.indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(u8) * indicesNumber, quadIndices, GL_STATIC_DRAW);
// Unbind
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void bindDefaultAttribLocations(GLuint program)
{
//bind vertex attribute to vbo inputs
glBindAttribLocation(program, VERTEX_POS_ARRAY, "in_pos");
glBindAttribLocation(program, VERTEX_COL_BASE_ARRAY, "in_base");
glBindAttribLocation(program, VERTEX_COL_OFFS_ARRAY, "in_offs");
glBindAttribLocation(program, VERTEX_UV_ARRAY, "in_uv");
#ifndef GLES
glBindFragDataLocation(program, 0, "FragColor");
#endif
}
bool CompilePipelineShader( PipelineShader* s)
{
char pshader[8192];
@ -912,9 +1036,7 @@ bool CompilePipelineShader( PipelineShader* s)
s->pp_Texture,s->pp_IgnoreTexA,s->pp_ShadInstr,s->pp_Offset,s->pp_FogCtrl);
sprintf(vshader,VertexShaderSource, gl.glsl_version_header, gl.gl_version);
s->program=gl_CompileAndLink(vshader,pshader);
s->program = gl_CompileAndLink(vshader, pshader, bindDefaultAttribLocations);
//setup texture 0 as the input for the shader
GLuint gu=glGetUniformLocation(s->program, "tex");
@ -1020,25 +1142,33 @@ bool gl_create_resources()
findGLVersion();
char vshader[8192];
const u32 maxShaderSize = 8192;
char vshader[maxShaderSize];
sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version);
char fshader[8192];
char fshader[maxShaderSize];
sprintf(fshader, ModifierVolumeShader, gl.glsl_version_header, gl.gl_version);
gl.modvol_shader.program = gl_CompileAndLink(vshader, fshader, bindDefaultAttribLocations);
gl.modvol_shader.program=gl_CompileAndLink(vshader,fshader);
gl.modvol_shader.scale = glGetUniformLocation(gl.modvol_shader.program, "scale");
gl.modvol_shader.sp_ShaderColor = glGetUniformLocation(gl.modvol_shader.program, "sp_ShaderColor");
gl.modvol_shader.depth_scale = glGetUniformLocation(gl.modvol_shader.program, "depth_scale");
sprintf(fshader, OSD_Shader, gl.glsl_version_header, gl.gl_version);
gl.OSD_SHADER.program=gl_CompileAndLink(vshader,fshader);
gl.OSD_SHADER.program = gl_CompileAndLink(vshader, fshader, bindDefaultAttribLocations);
printf("OSD: %d\n",gl.OSD_SHADER.program);
gl.OSD_SHADER.scale=glGetUniformLocation(gl.OSD_SHADER.program, "scale");
gl.OSD_SHADER.depth_scale=glGetUniformLocation(gl.OSD_SHADER.program, "depth_scale");
glUniform1i(glGetUniformLocation(gl.OSD_SHADER.program, "tex"),0); //bind osd texture to slot 0
if ((settings.rend.VerticalResolution != 100 || settings.rend.HorizontalResolution != 100) && !gl.fullscreenQuadShader) {
sprintf(vshader, FullscreenQuadVertexShader, gl.glsl_version_header, gl.gl_version);
sprintf(fshader, FullscreenQuadFragmentShader, gl.glsl_version_header, gl.gl_version);
gl.fullscreenQuadShader = gl_CompileAndLink(vshader, fshader);
generateFullscreenQuadVertices();
}
//#define PRECOMPILE_SHADERS
#ifdef PRECOMPILE_SHADERS
for (u32 i=0;i<sizeof(gl.pogram_table)/sizeof(gl.pogram_table[0]);i++)
@ -1069,8 +1199,6 @@ GLuint gl_CompileShader(const char* shader,GLuint type);
bool gl_create_resources();
//setup
bool gles_init()
{
@ -1100,6 +1228,13 @@ bool gles_init()
return true;
}
bool isExtensionSupported(const char * name) {
if (!strstr((const char *)glGetString(GL_EXTENSIONS), name)) {
return false;
}
return true;
}
void UpdateFogTexture(u8 *fog_table, GLenum texture_slot, GLint fog_image_format)
{
glActiveTexture(texture_slot);
@ -1495,6 +1630,63 @@ void OSD_DRAW()
#endif
}
void fullscreenQuadCreateTemporaryFBO(float & screenToNativeXScale, float & screenToNativeYScale)
{
// Generate and bind a render buffer which will become a depth buffer
if (!fullscreenQuad.framebufferRenderbuffer) {
glGenRenderbuffers(1, &fullscreenQuad.framebufferRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, fullscreenQuad.framebufferRenderbuffer);
#ifdef GLES
if (isExtensionSupported("GL_OES_packed_depth_stencil")) {
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, screen_width, screen_height);
}
else if (isExtensionSupported("GL_OES_depth24")) {
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, screen_width, screen_height);
}
else {
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, screen_width, screen_height);
}
#else
//OpenGL >= 3.0 is required
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, screen_width, screen_height);
#endif
}
// Create a texture for rendering to - may be a color render buffer as well
if (!fullscreenQuad.framebufferTexture) {
glGenTextures(1, &fullscreenQuad.framebufferTexture);
glBindTexture(GL_TEXTURE_2D, fullscreenQuad.framebufferTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, screen_width, screen_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
}
// Create the object that will allow us to render to the aforementioned texture (one for every rtt texture address)
if (!fullscreenQuad.framebuffer) {
glGenFramebuffers(1, &fullscreenQuad.framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, fullscreenQuad.framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fullscreenQuad.framebufferTexture, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fullscreenQuad.framebufferRenderbuffer);
#ifdef GLES
if (isExtensionSupported("GL_OES_packed_depth_stencil")) {
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fullscreenQuad.framebufferRenderbuffer);
}
#else
//OpenGL >= 3.0 is required
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fullscreenQuad.framebufferRenderbuffer);
#endif
GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
verify(uStatus == GL_FRAMEBUFFER_COMPLETE);
}
else {
glBindFramebuffer(GL_FRAMEBUFFER, fullscreenQuad.framebuffer);
}
glViewport(0, 0, screen_width * screenToNativeXScale, screen_height * screenToNativeYScale);
}
bool ProcessFrame(TA_context* ctx)
{
//disable RTTs for now ..
@ -1615,8 +1807,18 @@ bool RenderFrame()
//float A=-B*max_invW+vnear;
//these should be adjusted based on the current PVR scaling etc params
float dc_width=640;
float dc_height=480;
float dc_width = 640;
float dc_height = 480;
float screenToNativeXScale = 1.0f;
float screenToNativeYScale = 1.0f;
if (settings.rend.HorizontalResolution >= 1 && settings.rend.HorizontalResolution < 100) {
screenToNativeXScale = settings.rend.HorizontalResolution / 100.0f;
}
if (settings.rend.VerticalResolution >= 1 && settings.rend.VerticalResolution < 100) {
screenToNativeYScale = settings.rend.VerticalResolution / 100.0f;
}
if (!is_rtt)
{
@ -1812,8 +2014,12 @@ bool RenderFrame()
else
{
#if HOST_OS != OS_DARWIN
//Fix this in a proper way
glBindFramebuffer(GL_FRAMEBUFFER,0);
if (settings.rend.VerticalResolution == 100 && settings.rend.HorizontalResolution == 100) {
glViewport(0, 0, screen_width, screen_height);
}
else {
fullscreenQuadCreateTemporaryFBO(screenToNativeXScale, screenToNativeYScale);
}
#endif
}
@ -1863,30 +2069,29 @@ bool RenderFrame()
printf("SCI: %f, %f, %f, %f\n", offs_x+pvrrc.fb_X_CLIP.min/scale_x,(pvrrc.fb_Y_CLIP.min/scale_y)*dc2s_scale_h,(pvrrc.fb_X_CLIP.max-pvrrc.fb_X_CLIP.min+1)/scale_x*dc2s_scale_h,(pvrrc.fb_Y_CLIP.max-pvrrc.fb_Y_CLIP.min+1)/scale_y*dc2s_scale_h);
#endif
if (settings.rend.WideScreen && pvrrc.fb_X_CLIP.min==0 && ((pvrrc.fb_X_CLIP.max+1)/scale_x==640) && (pvrrc.fb_Y_CLIP.min==0) && ((pvrrc.fb_Y_CLIP.max+1)/scale_y==480 ) )
{
glDisable(GL_SCISSOR_TEST);
}
else
{
float width = (pvrrc.fb_X_CLIP.max - pvrrc.fb_X_CLIP.min + 1) / scale_x;
float height = (pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1) / scale_y;
float min_x = pvrrc.fb_X_CLIP.min / scale_x;
float min_y = pvrrc.fb_Y_CLIP.min / scale_y;
if (!is_rtt)
{
// Add x offset for aspect ratio > 4/3
min_x = min_x * dc2s_scale_h + ds2s_offs_x;
// Invert y coordinates when rendering to screen
min_y = screen_height - (min_y + height) * dc2s_scale_h;
width *= dc2s_scale_h;
height *= dc2s_scale_h;
if (settings.rend.VerticalResolution == 100 && settings.rend.HorizontalResolution == 100) {
if (settings.rend.WideScreen && pvrrc.fb_X_CLIP.min == 0 &&
((pvrrc.fb_X_CLIP.max + 1) / scale_x == 640) && (pvrrc.fb_Y_CLIP.min == 0) &&
((pvrrc.fb_Y_CLIP.max + 1) / scale_y == 480)) {
glDisable(GL_SCISSOR_TEST);
} else {
float width = (pvrrc.fb_X_CLIP.max - pvrrc.fb_X_CLIP.min + 1) / scale_x;
float height = (pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1) / scale_y;
float min_x = pvrrc.fb_X_CLIP.min / scale_x;
float min_y = pvrrc.fb_Y_CLIP.min / scale_y;
if (!is_rtt) {
// Add x offset for aspect ratio > 4/3
min_x = min_x * dc2s_scale_h + ds2s_offs_x;
// Invert y coordinates when rendering to screen
min_y = screen_height - (min_y + height) * dc2s_scale_h;
width *= dc2s_scale_h;
height *= dc2s_scale_h;
}
glScissor(min_x + 0.5f, min_y + 0.5f, width + 0.5f, height + 0.5f);
glEnable(GL_SCISSOR_TEST);
}
glScissor(min_x + 0.5f, min_y + 0.5f, width + 0.5f, height + 0.5f);
glEnable(GL_SCISSOR_TEST);
}
//restore scale_x
scale_x /= scissoring_scale_x;
@ -1900,6 +2105,10 @@ bool RenderFrame()
KillTex=false;
if (!is_rtt && (settings.rend.VerticalResolution != 100 || settings.rend.HorizontalResolution != 100)) {
DrawFullscreenQuad(screenToNativeXScale, screenToNativeYScale, scale_x, scale_y);
}
return !is_rtt;
}

View File

@ -40,12 +40,35 @@
#define VERTEX_COL_OFFS_ARRAY 2
#define VERTEX_UV_ARRAY 3
struct float2
{
float x;
float y;
};
struct float3
{
float x;
float y;
float z;
};
struct GLFramebufferData {
GLuint framebuffer;
GLuint framebufferRenderbuffer;
GLuint framebufferTexture;
GLuint positionsBuffer;
GLuint texcoordsBuffer;
GLuint indexBuffer;
};
//vertex types
extern u32 gcflip;
extern GLFramebufferData fullscreenQuad;
void DrawStrips();
void DrawFullscreenQuad(float, float, float, float);
struct PipelineShader
{
@ -97,11 +120,14 @@ struct gl_ctx
#endif
} vbo;
GLuint fullscreenQuadShader;
const char *gl_version;
const char *glsl_version_header;
int gl_major;
bool is_gles;
GLuint fog_image_format;
//GLuint matrix;
};

View File

@ -618,6 +618,8 @@ struct settings_t
bool WideScreen;
bool ModifierVolumes;
bool Clipping;
u32 VerticalResolution;
u32 HorizontalResolution;
} rend;
struct

View File

@ -25,6 +25,8 @@ public class Emulator extends Application {
public static final String pref_pvrrender = "pvr_render";
public static final String pref_syncedrender = "synced_render";
public static final String pref_modvols = "modifier_volumes";
public static final String pref_resolutionv = "resolution_vertical";
public static final String pref_resolutionh = "resolution_horizontal";
public static final String pref_bootdisk = "boot_disk";
public static final String pref_usereios = "use_reios";
@ -47,6 +49,8 @@ public class Emulator extends Application {
public static boolean pvrrender = false;
public static boolean syncedrender = false;
public static boolean modvols = true;
public static int resolutionv = 100;
public static int resolutionh = 100;
public static String bootdisk = null;
public static boolean usereios = false;
@ -69,6 +73,8 @@ public class Emulator extends Application {
Emulator.clipping = mPrefs.getBoolean(pref_clipping, clipping);
Emulator.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender);
Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
Emulator.resolutionv = mPrefs.getInt(pref_resolutionv, resolutionv);
Emulator.resolutionh = mPrefs.getInt(pref_resolutionh, resolutionh);
Emulator.bootdisk = mPrefs.getString(pref_bootdisk, bootdisk);
Emulator.usereios = mPrefs.getBoolean(pref_usereios, usereios);
}
@ -97,6 +103,8 @@ public class Emulator extends Application {
JNIdc.syncedrender(Emulator.syncedrender ? 1 : 0);
JNIdc.modvols(Emulator.modvols ? 1 : 0);
JNIdc.usereios(Emulator.usereios ? 1 : 0);
JNIdc.resolutionv(Emulator.resolutionv);
JNIdc.resolutionh(Emulator.resolutionh);
JNIdc.bootdisk(Emulator.bootdisk);
JNIdc.dreamtime(DreamTime.getDreamtime());
}
@ -110,6 +118,8 @@ public class Emulator extends Application {
JNIdc.pvrrender(mPrefs.getBoolean(pref_pvrrender, pvrrender) ? 1 : 0);
JNIdc.syncedrender(mPrefs.getBoolean(pref_syncedrender, syncedrender) ? 1 : 0);
JNIdc.modvols(mPrefs.getBoolean(pref_modvols, modvols) ? 1 : 0);
JNIdc.resolutionv(mPrefs.getInt(pref_resolutionv, resolutionv));
JNIdc.resolutionh(mPrefs.getInt(pref_resolutionh, resolutionh));
JNIdc.bootdisk(mPrefs.getString(pref_bootdisk, bootdisk));
}

View File

@ -420,6 +420,31 @@ public class OptionsFragment extends Fragment {
}
});
int resolutionVertical = mPrefs.getInt(Emulator.pref_resolutionv, Emulator.resolutionv);
final String resolutionText = getActivity().getString(R.string.resolution) + ": ";
final TextView resolutionTextView = getView().findViewById(R.id.resolution);
resolutionTextView.setText((resolutionText + String.valueOf(resolutionVertical) + "%"));
final SeekBar resolutionVHSeek = getView().findViewById(R.id.resolutionvh_seekbar);
resolutionVHSeek.setProgress(resolutionVertical - 1); //can take vertical OR horizontal (the same values)
resolutionVHSeek.setIndeterminate(false);
resolutionVHSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
resolutionTextView.setText((resolutionText + String.valueOf(progress + 1) + "%"));
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
//the same progress for both resolutions
mPrefs.edit().putInt(Emulator.pref_resolutionv, progress + 1).apply();
mPrefs.edit().putInt(Emulator.pref_resolutionh, progress + 1).apply();
}
});
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -703,6 +728,8 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Emulator.pref_clipping).apply();
mPrefs.edit().remove(Emulator.pref_pvrrender).apply();
mPrefs.edit().remove(Emulator.pref_syncedrender).apply();
mPrefs.edit().remove(Emulator.pref_resolutionv).apply();
mPrefs.edit().remove(Emulator.pref_resolutionh).apply();
mPrefs.edit().remove(Emulator.pref_bootdisk).apply();
mPrefs.edit().remove(Config.pref_showfps).apply();
mPrefs.edit().remove(Config.pref_rendertype).apply();

View File

@ -47,6 +47,8 @@ public final class JNIdc
public static native void pvrrender(int render);
public static native void syncedrender(int sync);
public static native void modvols(int volumes);
public static native void resolutionv(int resolutionv);
public static native void resolutionh(int resolutionv);
public static native void bootdisk(String disk);
public static native void usereios(int reios);
public static native void dreamtime(long clock);

View File

@ -63,6 +63,8 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_frameskip(JNIEnv *env
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_pvrrender(JNIEnv *env,jobject obj, jint render) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_syncedrender(JNIEnv *env,jobject obj, jint sync) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_modvols(JNIEnv *env,jobject obj, jint volumes) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_resolutionv(JNIEnv *env,jobject obj, jint resolutionv) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_resolutionh(JNIEnv *env,jobject obj, jint resolutionh) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_bootdisk(JNIEnv *env,jobject obj, jstring disk) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_usereios(JNIEnv *env,jobject obj, jint reios) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_dreamtime(JNIEnv *env,jobject obj, jlong clock) __attribute__((visibility("default")));
@ -159,6 +161,16 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_modvols(JNIEnv *env,j
settings.rend.ModifierVolumes = volumes;
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_resolutionv(JNIEnv *env,jobject obj, jint resolutionv)
{
settings.rend.VerticalResolution = resolutionv;
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_resolutionh(JNIEnv *env,jobject obj, jint resolutionh)
{
settings.rend.HorizontalResolution = resolutionh;
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_usereios(JNIEnv *env,jobject obj, jint reios)
{
settings.bios.UseReios = reios;

View File

@ -749,6 +749,34 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:text="@string/resolution" />
</TableRow>
<TableRow
android:layout_marginTop="5dp"
android:gravity="center_vertical" >
<SeekBar
android:id="@+id/resolutionvh_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center_vertical|left"
android:max="99"
android:progress="99" />
</TableRow>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -749,6 +749,34 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:text="@string/resolution" />
</TableRow>
<TableRow
android:layout_marginTop="5dp"
android:gravity="center_vertical" >
<SeekBar
android:id="@+id/resolutionvh_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center_vertical|left"
android:max="99"
android:progress="99" />
</TableRow>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -45,6 +45,9 @@
<string name="select_software">Softwarerendering erzwingen</string>
<string name="select_sound">Emulator-Sound deaktivieren</string>
<string name="select_depth">Rendering-Tiefe</string>
<string name="resolution">Auflösung (niedriger = schneller)</string>
<string name="resolution_vertical">Vertikal</string>
<string name="resolution_horizontal">Horizontal</string>
<string name="games_listing">Verfügbare Dreamcast-Spiele</string>

View File

@ -23,6 +23,9 @@
<string name="select_stretch">Tryb Szerokoekranowy</string>
<string name="set_frameskip">Wartość Frameskip</string>
<string name="select_render">PVR Rendering (na razie nie działa)</string>
<string name="resolution">Rozdzielczość (mniej = szybciej)</string>
<string name="resolution_vertical">Pionowa</string>
<string name="resolution_horizontal">Pozioma</string>
<string name="games_listing">Dostępne gry Dreamcast\'a</string>

View File

@ -54,6 +54,9 @@
<string name="select_software">Use Software Layer</string>
<string name="select_sound">Disable Emulator Sound</string>
<string name="select_depth">View Rendering Depth</string>
<string name="resolution">Resolution (lower = faster)</string>
<string name="resolution_vertical">Vertical</string>
<string name="resolution_horizontal">Horizontal</string>
<string name="boot_disk">Boot Disk (ie. Gameshark, Utopia)</string>
<string name="clipping">Clipping</string>