summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-11-03 20:22:03 -0400
committerpommicket <pommicket@gmail.com>2022-11-03 20:22:03 -0400
commite894fe92cdc669ae05d15da2a66bc8db5af8bfdf (patch)
treef66e98e3189e3c18730a6d964d96088ed36db282
parente263805bf5e6f4a13f82287803ad3c44e1c1cc5e (diff)
[1.3] allow newer glsl versions w IN,OUT macros, msi version
-rw-r--r--base.h5
-rw-r--r--config.c4
-rw-r--r--gl.c18
-rw-r--r--text.c11
-rw-r--r--windows_installer/ted/ted/ted.vdproj6
5 files changed, 27 insertions, 17 deletions
diff --git a/base.h b/base.h
index 00d6a5b..ee427fc 100644
--- a/base.h
+++ b/base.h
@@ -132,10 +132,11 @@ typedef unsigned long long ullong;
#if _WIN32
static void print(char const *fmt, ...) {
- char buf[256];
+ char buf[2048];
+ buf[2047] = '\0';
va_list args;
va_start(args, fmt);
- vsprintf_s(buf, sizeof buf, fmt, args);
+ vsnprintf(buf, sizeof buf - 1, fmt, args);
va_end(args);
OutputDebugStringA(buf);
}
diff --git a/config.c b/config.c
index 1265eaf..d886756 100644
--- a/config.c
+++ b/config.c
@@ -564,13 +564,13 @@ static i64 config_read_string(Ted *ted, ConfigReader *cfg, char **ptext) {
static void settings_load_bg_shader(Ted *ted, Settings *s) {
char vshader[8192] ;
strbuf_printf(vshader, "attribute vec2 v_pos;\n\
-varying vec2 t_pos;\n\
+OUT vec2 t_pos;\n\
void main() { \n\
gl_Position = vec4(v_pos * 2.0 - 1.0, 0.0, 1.0);\n\
t_pos = v_pos;\n\
}");
char fshader[8192];
- strbuf_printf(fshader, "varying vec2 t_pos;\n\
+ strbuf_printf(fshader, "IN vec2 t_pos;\n\
uniform float t_time;\n\
uniform float t_save_time;\n\
uniform vec2 t_aspect;\n\
diff --git a/gl.c b/gl.c
index 1c41d54..0f39190 100644
--- a/gl.c
+++ b/gl.c
@@ -133,16 +133,22 @@ static GLuint glsl_version(void) {
switch (v) {
case 200: return 110;
case 210: return 120;
+ case 300: return 130;
+ case 310: return 140;
+ case 320: return 150;
}
- // don't go above 130. i don't want to write two different shaders one using varying and one using whatever new stuff GLSL has these days
- return 130;
+ return v;
}
// compile a GLSL shader
static GLuint gl_compile_shader(char error_buf[256], char const *code, GLenum shader_type) {
GLuint shader = glCreateShader(shader_type);
- char header[32];
- strbuf_printf(header, "#version %u\n#line 1\n", glsl_version());
+ char header[128];
+ int glsl = glsl_version();
+ strbuf_printf(header, "#version %u\n\
+#define IN %s\n\
+#define OUT %s\n\
+#line 1\n", glsl, glsl >= 130 ? "in" : "varying", glsl >= 130 ? "out" : "varying");
const char *sources[2] = {
header,
code
@@ -240,13 +246,13 @@ static GLuint gl_geometry_vbo, gl_geometry_vao;
static void gl_geometry_init(void) {
char const *vshader_code = "attribute vec2 v_pos;\n\
attribute vec4 v_color;\n\
- varying vec4 color;\n\
+ OUT vec4 color;\n\
void main() {\n\
gl_Position = vec4(v_pos, 0.0, 1.0);\n\
color = v_color;\n\
}\n\
";
- char const *fshader_code = "varying vec4 color;\n\
+ char const *fshader_code = "IN vec4 color;\n\
void main() {\n\
gl_FragColor = color;\n\
}\n\
diff --git a/text.c b/text.c
index 4a17bbb..6d40cc5 100644
--- a/text.c
+++ b/text.c
@@ -92,16 +92,16 @@ static bool text_init(void) {
char const *vshader_code = "attribute vec4 v_color;\n\
attribute vec2 v_pos;\n\
attribute vec2 v_tex_coord;\n\
-varying vec4 color;\n\
-varying vec2 tex_coord;\n\
+OUT vec4 color;\n\
+OUT vec2 tex_coord;\n\
void main() {\n\
color = v_color;\n\
tex_coord = v_tex_coord;\n\
gl_Position = vec4(v_pos, 0.0, 1.0);\n\
}\n\
";
- char const *fshader_code = "varying vec4 color;\n\
-varying vec2 tex_coord;\n\
+ char const *fshader_code = "IN vec4 color;\n\
+IN vec2 tex_coord;\n\
uniform sampler2D sampler;\n\
void main() {\n\
vec4 tex_color = texture2D(sampler, tex_coord);\n\
@@ -125,6 +125,9 @@ static Status text_load_char_page(Font *font, int page) {
// already loaded
return true;
}
+
+ glGetError(); // clear error
+
font->char_pages[page] = calloc(CHAR_PAGE_SIZE, sizeof *font->char_pages[page]);
for (int bitmap_width = 128, bitmap_height = 128; bitmap_width <= 4096; bitmap_width *= 2, bitmap_height *= 2) {
u8 *bitmap = calloc((size_t)bitmap_width, (size_t)bitmap_height);
diff --git a/windows_installer/ted/ted/ted.vdproj b/windows_installer/ted/ted/ted.vdproj
index 26dd79d..2aa175e 100644
--- a/windows_installer/ted/ted/ted.vdproj
+++ b/windows_installer/ted/ted/ted.vdproj
@@ -505,15 +505,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:ted"
- "ProductCode" = "8:{1D2D8F3B-2992-4032-8862-18E719C7D6B1}"
- "PackageCode" = "8:{F3148080-3E4B-45DA-97CD-BAFF6AF5962D}"
+ "ProductCode" = "8:{0B9F7A90-5694-46BE-8F99-039661289C76}"
+ "PackageCode" = "8:{0AE7BA1E-211E-485D-86CB-D16B2F869C0A}"
"UpgradeCode" = "8:{844F6C2B-DF3B-4A81-9BD5-603401BBA651}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:FALSE"
"InstallAllUsers" = "11:FALSE"
- "ProductVersion" = "8:22.09.3021"
+ "ProductVersion" = "8:22.11.0320"
"Manufacturer" = "8:ted"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"