Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions ltw/src/main/tinywrapper/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "main.h"
#include "unpack.h"
#include "libraryinternal.h"
#include "env.h"
#include "env.h"

void glClearDepth(GLdouble depth) {
if(!current_context) return;
Expand Down Expand Up @@ -168,7 +168,14 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei widt
current_context->proxy_intformat = internalformat;
return;
}

if (target == GL_TEXTURE_2D && (width < 1024 && height <
1024)) {
// 确保纹理参数适合字体渲染
es3_functions.glTexParameteri(target,
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
es3_functions.glTexParameteri(target,
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
// No data, just initialization
if(data == NULL) {
make_format_non_generic(&internalformat, &type, &format);
Expand Down Expand Up @@ -249,16 +256,32 @@ void glTexParameterf( GLenum target,
if(!filter_params_float(target, pname, param)) return;
es3_functions.glTexParameterf(target, pname, param);
}
void glTexParameteri( GLenum target,
GLenum pname,
GLint param) {
if(!current_context) return;
if(!filter_params_integer(target, pname, param)) return;
if(!filter_params_float(target, pname, (GLfloat)param)) return;
remove_mipmaps(pname, &param);
make_depthtex_nearest(target, pname, &param);
es3_functions.glTexParameteri(target, pname, param);
}
void glTexParameteri( GLenum target,
GLenum pname,
GLint param) {
if(!current_context) return;
if(!filter_params_integer(target, pname, param)) return;
if(!filter_params_float(target, pname, (GLfloat)param))
return;
remove_mipmaps(pname, &param);
make_depthtex_nearest(target, pname, &param);

// 添加对字体纹理的特殊处理
if (target == GL_TEXTURE_2D && (pname ==
GL_TEXTURE_MIN_FILTER || pname == GL_TEXTURE_MAG_FILTER)) {
// 将不支持的滤波模式转换为支持的模式
if (param == GL_LINEAR_MIPMAP_LINEAR || param ==
GL_NEAREST_MIPMAP_NEAREST ||
param == GL_NEAREST_MIPMAP_LINEAR || param ==
GL_LINEAR_MIPMAP_NEAREST) {
// 不支持mipmap,使用基本滤波
param = (param == GL_LINEAR_MIPMAP_LINEAR || param
== GL_LINEAR_MIPMAP_NEAREST) ? GL_LINEAR : GL_NEAREST;
}
}

es3_functions.glTexParameteri(target, pname, param);
}

void glTexParameterfv( GLenum target,
GLenum pname,
Expand Down Expand Up @@ -364,7 +387,7 @@ const GLubyte* glGetString(GLenum name) {
case GL_SHADING_LANGUAGE_VERSION:
return (const GLubyte*)"4.60 LTW";
case GL_VENDOR:
return (const GLubyte*)"artDev, SerpentSpirale, CADIndie";
return (const GLubyte*)"artDev, SerpentSpirale, CADIndie, IQge";
case GL_EXTENSIONS:
if(current_context->extensions_string != NULL) return (const GLubyte*)current_context->extensions_string;
return (const GLubyte*)es3_functions.glGetString(GL_EXTENSIONS);
Expand Down
9 changes: 6 additions & 3 deletions ltw/src/main/tinywrapper/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ INTERNAL es3_functions_t es3_functions;

static void error_sysegl() {
__android_log_print(ANDROID_LOG_ERROR, "LTWInit", "Failed to load system EGL: %s", dlerror());
abort();
// abort();
return;
Comment on lines -24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EGL is required for LTW. Why return here instead of abort?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EGL is required for LTW. Why return here instead of abort?

As FCL wouldn't start, I attempted to use

}

static void error_init(const char* functionName) {
__android_log_print(ANDROID_LOG_ERROR, "LTWInit", "Failed to load function \"%s\"", functionName);
abort();
// abort();
return;
}

static void init_es3_proc() {
Expand Down Expand Up @@ -72,7 +74,8 @@ static eglMustCastToProperFunctionPointerType resolve_stub(const char* procname)

static void unknown_stub() {
printf("Unknown stub! Aborting to produce backtrace...\n");
abort();
// abort();
return;
}

eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) {
Expand Down
9 changes: 9 additions & 0 deletions ltw/src/main/tinywrapper/unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ void glPixelStoref( GLenum pname,

void glPixelStorei( GLenum pname,
GLint param) {
if(!current_context) return;
if (pname == GL_UNPACK_ALIGNMENT) {

if (param != 1 && param != 2 && param != 4) {
param = 4;
}
}
es3_functions.glPixelStorei(pname, param);

switch (pname) {
case GL_UNPACK_SWAP_BYTES:
current_context->unpack.swap_bytes = param == GL_TRUE;
Expand Down