Merge remote-tracking branch 'origin/master' into cdrom_changes

This commit is contained in:
OBattler
2025-03-14 19:42:50 +01:00
6 changed files with 58 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ extern "C"
#include <86box/config.h>
#include <86box/qt-glslp-parser.h>
#include <86box/path.h>
#include <86box/plat.h>
extern void startblit();
extern void endblit();
@@ -81,14 +82,38 @@ static int endswith(const char *str, const char *ext) {
return 0;
}
static int
glsl_detect_bom(const char *fn)
{
FILE *fp;
unsigned char bom[4] = { 0, 0, 0, 0 };
fp = plat_fopen(fn, "rb");
if (fp == NULL)
return 0;
(void) !fread(bom, 1, 3, fp);
if (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF) {
fclose(fp);
return 1;
}
fclose(fp);
return 0;
}
static char *load_file(const char *fn) {
FILE *f = fopen(fn, "rb");
int bom = glsl_detect_bom(fn);
FILE *f = plat_fopen(fn, "rb");
if (!f)
return 0;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
if (bom) {
fsize -= 3;
fseek(f, 3, SEEK_SET);
}
char *data = (char*)malloc(fsize + 1);
fread(data, fsize, 1, f);
@@ -131,12 +156,15 @@ static int get_parameters(glslp_t *glsl) {
int i;
struct parameter p;
for (i = 0; i < glsl->num_shaders; ++i) {
char line[1024];
struct shader *shader = &glsl->shaders[i];
FILE *f = fopen(shader->shader_fn, "rb");
int bom = glsl_detect_bom(shader->shader_fn);
FILE *f = plat_fopen(shader->shader_fn, "rb");
if (!f)
return 0;
char line[1024];
if (bom) {
fseek(f, 3, SEEK_SET);
}
while (fgets(line, sizeof(line) - 1, f) && glsl->num_parameters < MAX_PARAMETERS) {
int num = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", p.id, p.description,
&p.default_value, &p.min, &p.max, &p.step);

View File

@@ -63,6 +63,7 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent)
} else {
ui->buttonConfigure->setEnabled(false);
}
ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS);
} else {
ui->buttonRemove->setDisabled(true);
ui->buttonMoveUp->setDisabled(true);
@@ -177,6 +178,7 @@ void OpenGLShaderManagerDialog::on_buttonAdd_clicked()
item->setData(Qt::UserRole + 2, (qulonglong)(uintptr_t)shaderfile);
if (ui->shaderListWidget->count()) {
ui->shaderListWidget->setCurrentRow(ui->shaderListWidget->count() - 1);
ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS);
}
} else {
QMessageBox::critical(this, tr("GLSL error"), tr("Could not load filename %1").arg(res));
@@ -197,6 +199,7 @@ void OpenGLShaderManagerDialog::on_buttonRemove_clicked()
on_shaderListWidget_currentRowChanged(ui->shaderListWidget->currentRow());
}
ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS);
}
void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted()

View File

@@ -18,6 +18,11 @@
* Copyright 2021-2022 Cacodemon345
* Copyright 2021-2022 Teemu Korhonen
*/
#ifdef __HAIKU__
#include <OS.h>
#endif
#include <cstdio>
#include <mutex>
@@ -828,6 +833,8 @@ plat_set_thread_name(void *thread, const char *name)
pthread_setname_np(truncated);
# elif defined(Q_OS_NETBSD)
pthread_setname_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated, "%s");
# elif defined(__HAIKU__)
rename_thread(find_thread(NULL), truncated);
# elif defined(Q_OS_OPENBSD)
pthread_set_name_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated);
# else