Skip to content

Commit 6d9c3ac

Browse files
committed
Merge branch 'master' into kivutar/gl
2 parents 67ec74b + eda5d86 commit 6d9c3ac

14 files changed

Lines changed: 267 additions & 126 deletions

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ before_install:
2121
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libglfw3-dev libopenal-dev xorg-dev -y --allow-unauthenticated; fi
2222
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
2323
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install glfw openal-soft; fi
24+
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install make; fi
2425
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then wget http://static.kivutar.me/openal-soft-1.19.0-bin.zip; fi
2526
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then 7z x openal-soft-1.19.0-bin.zip -o/c/Users/travis/openal-soft-1.19.0-bin; fi
2627

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func runLoop(vid *video.Video) {
6262
}
6363

6464
func main() {
65+
var GLVersion uint
6566
flag.StringVar(&state.Global.CorePath, "L", "", "Path to the libretro core")
6667
flag.BoolVar(&state.Global.Verbose, "v", false, "Verbose logs")
68+
flag.UintVar(&GLVersion, "glver", 32, "OpenGL version")
6769
flag.Parse()
6870
args := flag.Args()
6971

@@ -91,7 +93,7 @@ func main() {
9193

9294
playlists.LoadPlaylists()
9395

94-
vid := video.Init(settings.Settings.VideoFullscreen)
96+
vid := video.Init(settings.Settings.VideoFullscreen, GLVersion)
9597

9698
m := menu.Init(vid)
9799
m.ContextReset()

menu/menu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func genericDrawHintBar() {
123123
vid.DrawImage(menu.icons["key-z"], stack, float32(h)-70*menu.ratio, 70*menu.ratio, 70*menu.ratio, 1.0, c)
124124
stack += 70 * menu.ratio
125125
stack += 10 * menu.ratio
126-
vid.Font.Printf(370*menu.ratio, float32(h)-23*menu.ratio, 0.5*menu.ratio, "BACK")
126+
vid.Font.Printf(stack, float32(h)-23*menu.ratio, 0.5*menu.ratio, "BACK")
127127
stack += vid.Font.Width(0.5*menu.ratio, "BACK")
128128

129129
stack += 30 * menu.ratio

menu/scene_playlist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (s *screenPlaylist) drawHintBar() {
179179
vid.DrawImage(menu.icons["key-z"], stack, float32(h)-70*menu.ratio, 70*menu.ratio, 70*menu.ratio, 1.0, c)
180180
stack += 70 * menu.ratio
181181
stack += 10 * menu.ratio
182-
vid.Font.Printf(370*menu.ratio, float32(h)-23*menu.ratio, 0.5*menu.ratio, "BACK")
182+
vid.Font.Printf(stack, float32(h)-23*menu.ratio, 0.5*menu.ratio, "BACK")
183183
stack += vid.Font.Width(0.5*menu.ratio, "BACK")
184184

185185
stack += 30 * menu.ratio

menu/thumbnail.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"os"
88
"os/user"
9+
"strings"
910

1011
"github.com/libretro/ludo/video"
1112
)
@@ -42,11 +43,27 @@ func downloadThumbnail(list *entry, i int, url, folderPath, path string) {
4243
io.Copy(out, resp.Body)
4344
}
4445

46+
// Scrub characters that are not cross-platform and/or violate the
47+
// No-Intro filename standard.
48+
func scrubIllegalChars(str string) string {
49+
str = strings.Replace(str, "&", "_", -1)
50+
str = strings.Replace(str, "*", "_", -1)
51+
str = strings.Replace(str, "/", "_", -1)
52+
str = strings.Replace(str, ":", "_", -1)
53+
str = strings.Replace(str, "`", "_", -1)
54+
str = strings.Replace(str, "<", "_", -1)
55+
str = strings.Replace(str, ">", "_", -1)
56+
str = strings.Replace(str, "?", "_", -1)
57+
str = strings.Replace(str, "|", "_", -1)
58+
return str
59+
}
60+
4561
func drawThumbnail(list *entry, i int, system, gameName string, x, y, w, h, scale float32) {
4662
usr, _ := user.Current()
4763
folderPath := usr.HomeDir + "/.ludo/thumbnails/" + system + "/Named_Snaps/"
4864
path := folderPath + gameName + ".png"
49-
url := "http://thumbnails.libretro.com/" + system + "/Named_Snaps/" + gameName + ".png"
65+
legalName := scrubIllegalChars(gameName)
66+
url := "http://thumbnails.libretro.com/" + system + "/Named_Snaps/" + legalName + ".png"
5067

5168
if list.children[i].thumbnail == 0 || list.children[i].thumbnail == menu.icons["img-dl"] {
5269
if _, err := os.Stat(path); !os.IsNotExist(err) {

video/border_frag_shader.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
package video
22

3-
// source of the shader to draw circles
43
var borderFragmentShader = `
5-
#version 330
4+
#if __VERSION__ >= 130
5+
#define COMPAT_VARYING in
6+
#define COMPAT_ATTRIBUTE in
7+
#define COMPAT_TEXTURE texture
8+
#define COMPAT_FRAGCOLOR FragColor
9+
out vec4 COMPAT_FRAGCOLOR;
10+
#else
11+
#define COMPAT_VARYING varying
12+
#define COMPAT_ATTRIBUTE attribute
13+
#define COMPAT_TEXTURE texture2D
14+
#define COMPAT_FRAGCOLOR gl_FragColor
15+
#endif
616
717
uniform float border_width;
818
uniform vec4 color;
919
uniform vec2 size;
1020
11-
in vec2 fragTexCoord;
12-
out vec4 outputColor;
21+
COMPAT_VARYING vec2 fragTexCoord;
1322
1423
void main() {
1524
float ratio = size.x / size.y;
@@ -20,9 +29,9 @@ void main() {
2029
2130
if (fragTexCoord.x < maxX && fragTexCoord.x > minX &&
2231
fragTexCoord.y < maxY && fragTexCoord.y > minY) {
23-
outputColor = vec4(0,0,0,0);
32+
COMPAT_FRAGCOLOR = vec4(0,0,0,0);
2433
} else {
25-
outputColor = color;
34+
COMPAT_FRAGCOLOR = color;
2635
}
2736
}
2837
` + "\x00"

video/circle_frag_shader.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
package video
22

3-
// source of the shader to draw circles
43
var circleFragmentShader = `
5-
#version 330
4+
#if __VERSION__ >= 130
5+
#define COMPAT_VARYING in
6+
#define COMPAT_ATTRIBUTE in
7+
#define COMPAT_TEXTURE texture
8+
#define COMPAT_FRAGCOLOR FragColor
9+
out vec4 COMPAT_FRAGCOLOR;
10+
#else
11+
#define COMPAT_VARYING varying
12+
#define COMPAT_ATTRIBUTE attribute
13+
#define COMPAT_TEXTURE texture2D
14+
#define COMPAT_FRAGCOLOR gl_FragColor
15+
#endif
616
717
uniform sampler2D tex;
818
uniform vec4 color;
919
10-
in vec2 fragTexCoord;
11-
out vec4 outputColor;
20+
COMPAT_VARYING vec2 fragTexCoord;
1221
13-
float circle(in vec2 _st, in float _radius) {
22+
float circle(vec2 _st, float _radius) {
1423
vec2 dist = _st - vec2(0.5);
1524
return 1.-smoothstep(_radius-(_radius*0.05), _radius+(_radius*0.05), dot(dist,dist)*4.0);
1625
}
1726
1827
void main() {
19-
outputColor = vec4(color.rgb, circle(fragTexCoord.xy, 0.125));
28+
COMPAT_FRAGCOLOR = vec4(color.rgb, circle(fragTexCoord.xy, 0.125));
2029
}
2130
` + "\x00"

video/darken_frag_shader.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
package video
22

33
var darkenFragmentShader = `
4-
#version 330
4+
#if __VERSION__ >= 130
5+
#define COMPAT_VARYING in
6+
#define COMPAT_ATTRIBUTE in
7+
#define COMPAT_TEXTURE texture
8+
#define COMPAT_FRAGCOLOR FragColor
9+
out vec4 COMPAT_FRAGCOLOR;
10+
#else
11+
#define COMPAT_VARYING varying
12+
#define COMPAT_ATTRIBUTE attribute
13+
#define COMPAT_TEXTURE texture2D
14+
#define COMPAT_FRAGCOLOR gl_FragColor
15+
#endif
516
617
uniform sampler2D tex;
718
uniform float mask;
819
uniform vec4 texColor;
920
10-
in vec2 fragTexCoord;
21+
COMPAT_VARYING vec2 fragTexCoord;
1122
12-
out vec4 outputColor;
13-
14-
vec4 grayscale(in vec4 c) {
23+
vec4 grayscale(vec4 c) {
1524
float average = (c.r + c.g + c.b) / 3.0;
1625
return vec4(average, average, average, 1.0);
1726
}
1827
19-
vec4 darken(in vec4 c) {
20-
return vec4(c.r/4, c.g/4, c.b/4, 1.0);
28+
vec4 darken(vec4 c) {
29+
return vec4(c.r/4.0, c.g/4.0, c.b/4.0, 1.0);
2130
}
2231
2332
void main() {
24-
vec4 color = texture(tex, fragTexCoord);
25-
outputColor = texColor * mix(color, darken(grayscale(color)), mask);
33+
vec4 color = COMPAT_TEXTURE(tex, fragTexCoord);
34+
COMPAT_FRAGCOLOR = texColor * mix(color, darken(grayscale(color)), mask);
2635
}
2736
` + "\x00"

video/default_vert_shader.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package video
2+
3+
var vertexShader = `
4+
#if __VERSION__ >= 130
5+
#define COMPAT_VARYING out
6+
#define COMPAT_ATTRIBUTE in
7+
#define COMPAT_TEXTURE texture
8+
#define COMPAT_FRAGCOLOR FragColor
9+
out vec4 COMPAT_FRAGCOLOR;
10+
#else
11+
#define COMPAT_VARYING varying
12+
#define COMPAT_ATTRIBUTE attribute
13+
#define COMPAT_TEXTURE texture2D
14+
#define COMPAT_FRAGCOLOR gl_FragColor
15+
#endif
16+
17+
COMPAT_ATTRIBUTE vec2 vert;
18+
COMPAT_ATTRIBUTE vec2 vertTexCoord;
19+
20+
COMPAT_VARYING vec2 fragTexCoord;
21+
22+
void main() {
23+
fragTexCoord = vertTexCoord;
24+
gl_Position = vec4(vert, 0, 1);
25+
}
26+
` + "\x00"

video/demul_frag_shader.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
package video
22

33
var demulFragmentShader = `
4-
#version 330
4+
#if __VERSION__ >= 130
5+
#define COMPAT_VARYING in
6+
#define COMPAT_ATTRIBUTE in
7+
#define COMPAT_TEXTURE texture
8+
#define COMPAT_FRAGCOLOR FragColor
9+
out vec4 COMPAT_FRAGCOLOR;
10+
#else
11+
#define COMPAT_VARYING varying
12+
#define COMPAT_ATTRIBUTE attribute
13+
#define COMPAT_TEXTURE texture2D
14+
#define COMPAT_FRAGCOLOR gl_FragColor
15+
#endif
516
617
uniform sampler2D tex;
718
uniform float mask;
819
uniform vec4 texColor;
920
10-
in vec2 fragTexCoord;
21+
COMPAT_VARYING vec2 fragTexCoord;
1122
12-
out vec4 outputColor;
13-
14-
vec4 demultiply(in vec4 c) {
23+
vec4 demultiply(vec4 c) {
1524
return vec4(c.rgb/c.a, c.a);
1625
}
1726
1827
void main() {
19-
vec4 color = demultiply(texture(tex, fragTexCoord));
20-
outputColor = texColor * color;
28+
vec4 color = demultiply(COMPAT_TEXTURE(tex, fragTexCoord));
29+
COMPAT_FRAGCOLOR = texColor * color;
2130
}
2231
` + "\x00"

0 commit comments

Comments
 (0)