ruby2d 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d097c7865d0f9920bccf154e7e7652bb4fac02767f0874b5adcf74b248ab5eb
4
- data.tar.gz: fd6e9a7b221f850b9e6f71ba0d46a86e28f474d055d355a1c45f07078e2207de
3
+ metadata.gz: 694ff325167fe7d6ff8b61d8717fe4237d06da7d37c44d2df377c92651742537
4
+ data.tar.gz: 8985f19ff3d888286bbbb1dc6ec167c5b59f0eaa98ab2f628c3960c90ba978e0
5
5
  SHA512:
6
- metadata.gz: 932f5623ab4abd18521f721b2921a9c7e64f81c446345949904613d7e059286ed85788e88b3c181c6e435a104692a7a093edb20cbc49847b925e16bf09d1a8cc
7
- data.tar.gz: 3660bd43e97441b715513dd4236aaf36263d503f92af052fd961c1cb08e27d497a4598e9ca23b301c28a79ca0e8f8d1deed8107b98f54fb94d97255e036b02ef
6
+ metadata.gz: b3c772f6781eaf972ddf4213e9454c8333471a127b5787da0ffd8e7b1c04f62fc091eb10c0ad1c558786ff1842b2d3b1b3c7797de8c17dfc7e84b5ab4e12c371
7
+ data.tar.gz: 4b082fecf24c7a4e6269d41701f9ec13589fca93155487fd336ce8818f07eeeb251a3425f9ca9688d2be1a0fc9326280da1752750c2a198cddaec9be148df926
data/bin/ruby2d CHANGED
@@ -115,6 +115,7 @@ when 'launch'
115
115
  else
116
116
  puts usage_launch
117
117
  end
118
+ # TODO: Need add this functionality to the gem
118
119
  when 'simulator'
119
120
  case ARGV[1]
120
121
  when '--list'
@@ -1,11 +1,11 @@
1
- // Simple 2D Shared functions and data
1
+ // Ruby 2D Shared functions and data
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
- // Initalize S2D shared data
6
- bool S2D_diagnostics = false;
5
+ // Initalize shared data
6
+ bool R2D_diagnostics = false;
7
7
 
8
- // S2D initialization status
8
+ // Initialization status
9
9
  static bool initted = false;
10
10
 
11
11
 
@@ -30,7 +30,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
30
30
  /*
31
31
  * Checks if a file exists and can be accessed
32
32
  */
33
- bool S2D_FileExists(const char *path) {
33
+ bool R2D_FileExists(const char *path) {
34
34
  if (!path) return false;
35
35
 
36
36
  if (access(path, F_OK) != -1) {
@@ -44,22 +44,22 @@ bool S2D_FileExists(const char *path) {
44
44
  /*
45
45
  * Logs standard messages to the console
46
46
  */
47
- void S2D_Log(int type, const char *msg, ...) {
47
+ void R2D_Log(int type, const char *msg, ...) {
48
48
 
49
49
  // Always log if diagnostics set, or if a warning or error message
50
- if (S2D_diagnostics || type != S2D_INFO) {
50
+ if (R2D_diagnostics || type != R2D_INFO) {
51
51
 
52
52
  va_list args;
53
53
  va_start(args, msg);
54
54
 
55
55
  switch (type) {
56
- case S2D_INFO:
56
+ case R2D_INFO:
57
57
  printf("\033[1;36mInfo:\033[0m ");
58
58
  break;
59
- case S2D_WARN:
59
+ case R2D_WARN:
60
60
  printf("\033[1;33mWarning:\033[0m ");
61
61
  break;
62
- case S2D_ERROR:
62
+ case R2D_ERROR:
63
63
  printf("\033[1;31mError:\033[0m ");
64
64
  break;
65
65
  }
@@ -72,14 +72,14 @@ void S2D_Log(int type, const char *msg, ...) {
72
72
 
73
73
 
74
74
  /*
75
- * Logs Simple 2D errors to the console, with caller and message body
75
+ * Logs Ruby 2D errors to the console, with caller and message body
76
76
  */
77
- void S2D_Error(const char *caller, const char *msg, ...) {
77
+ void R2D_Error(const char *caller, const char *msg, ...) {
78
78
  va_list args;
79
79
  va_start(args, msg);
80
80
  char *fmsg;
81
81
  vasprintf(&fmsg, msg, args);
82
- S2D_Log(S2D_ERROR, "(%s) %s", caller, fmsg);
82
+ R2D_Log(R2D_ERROR, "(%s) %s", caller, fmsg);
83
83
  free(fmsg);
84
84
  va_end(args);
85
85
  }
@@ -88,15 +88,15 @@ void S2D_Error(const char *caller, const char *msg, ...) {
88
88
  /*
89
89
  * Enable/disable logging of diagnostics
90
90
  */
91
- void S2D_Diagnostics(bool status) {
92
- S2D_diagnostics = status;
91
+ void R2D_Diagnostics(bool status) {
92
+ R2D_diagnostics = status;
93
93
  }
94
94
 
95
95
 
96
96
  /*
97
97
  * Enable terminal colors in Windows
98
98
  */
99
- void S2D_Windows_EnableTerminalColors() {
99
+ void R2D_Windows_EnableTerminalColors() {
100
100
  #if WINDOWS
101
101
  HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
102
102
  DWORD dwMode = 0;
@@ -108,25 +108,25 @@ void S2D_Windows_EnableTerminalColors() {
108
108
 
109
109
 
110
110
  /*
111
- * Initialize Simple 2D subsystems
111
+ * Initialize Ruby 2D subsystems
112
112
  */
113
- bool S2D_Init() {
113
+ bool R2D_Init() {
114
114
  if (initted) return true;
115
115
 
116
116
  // Enable terminal colors in Windows
117
- S2D_Windows_EnableTerminalColors();
117
+ R2D_Windows_EnableTerminalColors();
118
118
 
119
- S2D_Log(S2D_INFO, "Initializing Simple 2D");
119
+ R2D_Log(R2D_INFO, "Initializing Ruby 2D");
120
120
 
121
121
  // Initialize SDL
122
122
  if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
123
- S2D_Error("SDL_Init", SDL_GetError());
123
+ R2D_Error("SDL_Init", SDL_GetError());
124
124
  return false;
125
125
  }
126
126
 
127
127
  // Initialize SDL_ttf
128
128
  if (TTF_Init() != 0) {
129
- S2D_Error("TTF_Init", TTF_GetError());
129
+ R2D_Error("TTF_Init", TTF_GetError());
130
130
  return false;
131
131
  }
132
132
 
@@ -142,17 +142,17 @@ bool S2D_Init() {
142
142
  // It's version 2.0.2, don't check for Mix_Init errors
143
143
  } else {
144
144
  if ((mix_initted&mix_flags) != mix_flags) {
145
- S2D_Error("Mix_Init", Mix_GetError());
145
+ R2D_Error("Mix_Init", Mix_GetError());
146
146
  }
147
147
  }
148
148
 
149
149
  if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) != 0) {
150
- S2D_Error("Mix_OpenAudio", Mix_GetError());
150
+ R2D_Error("Mix_OpenAudio", Mix_GetError());
151
151
  return false;
152
152
  }
153
153
 
154
- // Call `S2D_Quit` at program exit
155
- atexit(S2D_Quit);
154
+ // Call `R2D_Quit` at program exit
155
+ atexit(R2D_Quit);
156
156
 
157
157
  // All subsystems initted
158
158
  initted = true;
@@ -161,10 +161,10 @@ bool S2D_Init() {
161
161
 
162
162
 
163
163
  /*
164
- * Gets the primary display's dimentions
164
+ * Gets the primary display's dimensions
165
165
  */
166
- void S2D_GetDisplayDimensions(int *w, int *h) {
167
- S2D_Init();
166
+ void R2D_GetDisplayDimensions(int *w, int *h) {
167
+ R2D_Init();
168
168
  SDL_DisplayMode dm;
169
169
  SDL_GetCurrentDisplayMode(0, &dm);
170
170
  *w = dm.w;
@@ -173,9 +173,9 @@ void S2D_GetDisplayDimensions(int *w, int *h) {
173
173
 
174
174
 
175
175
  /*
176
- * Quits Simple 2D subsystems
176
+ * Quits Ruby 2D subsystems
177
177
  */
178
- void S2D_Quit() {
178
+ void R2D_Quit() {
179
179
  IMG_Quit();
180
180
  Mix_CloseAudio();
181
181
  Mix_Quit();
@@ -1,6 +1,6 @@
1
1
  // controllers.c
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
  // Stores the last joystick instance ID seen by the system. These instance IDs
6
6
  // are unique and increment with each new joystick connected.
@@ -10,7 +10,7 @@ static int last_intance_id = -1;
10
10
  /*
11
11
  * Add controller mapping from string
12
12
  */
13
- void S2D_AddControllerMapping(const char *map) {
13
+ void R2D_AddControllerMapping(const char *map) {
14
14
  int result = SDL_GameControllerAddMapping(map);
15
15
 
16
16
  char guid[33];
@@ -18,13 +18,13 @@ void S2D_AddControllerMapping(const char *map) {
18
18
 
19
19
  switch (result) {
20
20
  case 1:
21
- S2D_Log(S2D_INFO, "Mapping added for GUID: %s", guid);
21
+ R2D_Log(R2D_INFO, "Mapping added for GUID: %s", guid);
22
22
  break;
23
23
  case 0:
24
- S2D_Log(S2D_INFO, "Mapping updated for GUID: %s", guid);
24
+ R2D_Log(R2D_INFO, "Mapping updated for GUID: %s", guid);
25
25
  break;
26
26
  case -1:
27
- S2D_Error("SDL_GameControllerAddMapping", SDL_GetError());
27
+ R2D_Error("SDL_GameControllerAddMapping", SDL_GetError());
28
28
  break;
29
29
  }
30
30
  }
@@ -33,17 +33,17 @@ void S2D_AddControllerMapping(const char *map) {
33
33
  /*
34
34
  * Add controller mappings from the specified file
35
35
  */
36
- void S2D_AddControllerMappingsFromFile(const char *path) {
37
- if (!S2D_FileExists(path)) {
38
- S2D_Log(S2D_WARN, "Controller mappings file not found: %s", path);
36
+ void R2D_AddControllerMappingsFromFile(const char *path) {
37
+ if (!R2D_FileExists(path)) {
38
+ R2D_Log(R2D_WARN, "Controller mappings file not found: %s", path);
39
39
  return;
40
40
  }
41
41
 
42
42
  int mappings_added = SDL_GameControllerAddMappingsFromFile(path);
43
43
  if (mappings_added == -1) {
44
- S2D_Error("SDL_GameControllerAddMappingsFromFile", SDL_GetError());
44
+ R2D_Error("SDL_GameControllerAddMappingsFromFile", SDL_GetError());
45
45
  } else {
46
- S2D_Log(S2D_INFO, "Added %i controller mapping(s)", mappings_added);
46
+ R2D_Log(R2D_INFO, "Added %i controller mapping(s)", mappings_added);
47
47
  }
48
48
  }
49
49
 
@@ -51,7 +51,7 @@ void S2D_AddControllerMappingsFromFile(const char *path) {
51
51
  /*
52
52
  * Check if joystick is a controller
53
53
  */
54
- bool S2D_IsController(SDL_JoystickID id) {
54
+ bool R2D_IsController(SDL_JoystickID id) {
55
55
  return SDL_GameControllerFromInstanceID(id) == NULL ? false : true;
56
56
  }
57
57
 
@@ -59,7 +59,7 @@ bool S2D_IsController(SDL_JoystickID id) {
59
59
  /*
60
60
  * Open controllers and joysticks
61
61
  */
62
- void S2D_OpenControllers() {
62
+ void R2D_OpenControllers() {
63
63
 
64
64
  char guid_str[33];
65
65
 
@@ -78,9 +78,9 @@ void S2D_OpenControllers() {
78
78
 
79
79
  if (intance_id > last_intance_id) {
80
80
  if (controller) {
81
- S2D_Log(S2D_INFO, "Controller #%i: %s\n GUID: %s", intance_id, SDL_GameControllerName(controller), guid_str);
81
+ R2D_Log(R2D_INFO, "Controller #%i: %s\n GUID: %s", intance_id, SDL_GameControllerName(controller), guid_str);
82
82
  } else {
83
- S2D_Log(S2D_ERROR, "Could not open controller #%i: %s", intance_id, SDL_GetError());
83
+ R2D_Log(R2D_ERROR, "Could not open controller #%i: %s", intance_id, SDL_GetError());
84
84
  }
85
85
  last_intance_id = intance_id;
86
86
  }
@@ -91,18 +91,18 @@ void S2D_OpenControllers() {
91
91
  SDL_JoystickID intance_id = SDL_JoystickInstanceID(joy);
92
92
 
93
93
  if (!joy) {
94
- S2D_Log(S2D_ERROR, "Could not open controller");
94
+ R2D_Log(R2D_ERROR, "Could not open controller");
95
95
  } else if(intance_id > last_intance_id) {
96
96
  SDL_JoystickGetGUIDString(
97
97
  SDL_JoystickGetGUID(joy),
98
98
  guid_str, 33
99
99
  );
100
- S2D_Log(S2D_INFO,
100
+ R2D_Log(R2D_INFO,
101
101
  "Controller #%i: %s\n GUID: %s\n Axes: %d\n Buttons: %d\n Balls: %d",
102
102
  intance_id, SDL_JoystickName(joy), guid_str, SDL_JoystickNumAxes(joy),
103
103
  SDL_JoystickNumButtons(joy), SDL_JoystickNumBalls(joy)
104
104
  );
105
- S2D_Log(S2D_WARN, "Controller #%i does not have a mapping available", intance_id);
105
+ R2D_Log(R2D_WARN, "Controller #%i does not have a mapping available", intance_id);
106
106
  last_intance_id = intance_id;
107
107
  }
108
108
  }
@@ -1,7 +1,6 @@
1
1
  require 'mkmf'
2
2
  require_relative '../../lib/ruby2d/cli/colorize'
3
3
 
4
- S2D_VERSION = '1.2.0' # Simple 2D minimum version required
5
4
  $errors = [] # Holds errors
6
5
 
7
6
  # Set the OS platform
@@ -31,27 +30,6 @@ def print_errors
31
30
  end
32
31
 
33
32
 
34
- # Check that Simple 2D is installed and meets minimum version requirements
35
- def check_s2d
36
-
37
- # Simple 2D not installed
38
- if `which simple2d`.empty?
39
- $errors << "Ruby 2D uses a native library called Simple 2D, which was not found." <<
40
- "To install, follow the instructions at #{"ruby2d.com".bold}"
41
- print_errors; exit
42
-
43
- # Simple 2D installed, checking version
44
- else
45
- unless Gem::Version.new(`bash simple2d --version`) >= Gem::Version.new(S2D_VERSION)
46
- $errors << "Simple 2D needs to be updated for this version of Ruby 2D." <<
47
- "Run the following, then try reinstalling this gem:\n" <<
48
- " simple2d update".bold
49
- print_errors; exit
50
- end
51
- end
52
- end
53
-
54
-
55
33
  # Add compiler and linker flags
56
34
  def add_flags(type, flags)
57
35
  case type
@@ -106,14 +84,11 @@ def set_rpi_flags
106
84
  end
107
85
 
108
86
 
109
- # Use the Simple 2D, SDL, and other libraries installed by the user (not those bundled with the gem)
87
+ # Use SDL and other libraries installed by the user (not those bundled with the gem)
110
88
  def use_usr_libs
111
- check_s2d
112
-
113
89
  # Add flags
114
90
  set_rpi_flags
115
91
  add_flags(:c, '-I/usr/local/include')
116
- add_flags(:ld, `bash simple2d --libs`)
117
92
  end
118
93
 
119
94
 
@@ -134,7 +109,6 @@ else
134
109
  add_flags(:c, '-I../../assets/include')
135
110
  ldir = "#{Dir.pwd}/../../assets/macos/lib"
136
111
 
137
- add_flags(:ld, "#{ldir}/libsimple2d.a")
138
112
  add_flags(:ld, "#{ldir}/libSDL2.a #{ldir}/libSDL2_image.a #{ldir}/libSDL2_mixer.a #{ldir}/libSDL2_ttf.a")
139
113
  add_flags(:ld, "#{ldir}/libjpeg.a #{ldir}/libpng16.a #{ldir}/libtiff.a #{ldir}/libwebp.a")
140
114
  add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libogg.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a #{ldir}/libvorbisfile.a")
@@ -143,18 +117,14 @@ else
143
117
 
144
118
  when :linux, :linux_rpi
145
119
  check_sdl_linux
146
- simple2d_dir = "#{Dir.pwd}/../../assets/linux/simple2d"
147
-
148
- `(cd #{simple2d_dir} && make)`
149
120
 
150
121
  set_rpi_flags
151
- add_flags(:c, "-I#{simple2d_dir}/include")
152
- add_flags(:ld, "#{simple2d_dir}/build/libsimple2d.a -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm")
122
+ add_flags(:ld, "-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm")
153
123
  if $platform == :linux then add_flags(:ld, '-lGL') end
154
124
 
155
125
  when :windows
156
126
  add_flags(:c, '-I../../assets/include')
157
- add_flags(:ld, '-L../../assets/mingw/lib -lsimple2d -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
127
+ add_flags(:ld, '-L../../assets/mingw/lib -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
158
128
  add_flags(:ld, '-lmingw32 -lopengl32 -lglew32')
159
129
 
160
130
  # If can't detect the platform, use libraries installed by the user
@@ -165,5 +135,5 @@ end
165
135
 
166
136
  $LDFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they can cause problems
167
137
 
168
- # Create the Makefile
138
+ # Create Makefile
169
139
  create_makefile('ruby2d/ruby2d')
@@ -1,15 +1,15 @@
1
- // Simple 2D OpenGL Functions
1
+ // Ruby 2D OpenGL Functions
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
  // Set to `true` to force OpenGL 2.1 (for testing)
6
6
  static bool FORCE_GL2 = false;
7
7
 
8
8
  // Flag set if using OpenGL 2.1
9
- static bool S2D_GL2 = false;
9
+ static bool R2D_GL2 = false;
10
10
 
11
11
  // The orthographic projection matrix for 2D rendering.
12
- // Elements 0 and 5 are set in S2D_GL_SetViewport.
12
+ // Elements 0 and 5 are set in R2D_GL_SetViewport.
13
13
  static GLfloat orthoMatrix[16] =
14
14
  { 0, 0, 0, 0,
15
15
  0, 0, 0, 0,
@@ -20,25 +20,25 @@ static GLfloat orthoMatrix[16] =
20
20
  /*
21
21
  * Prints current GL error
22
22
  */
23
- void S2D_GL_PrintError(char *error) {
24
- S2D_Log(S2D_ERROR, "%s (%d)", error, glGetError());
23
+ void R2D_GL_PrintError(char *error) {
24
+ R2D_Log(R2D_ERROR, "%s (%d)", error, glGetError());
25
25
  }
26
26
 
27
27
 
28
28
  /*
29
29
  * Print info about the current OpenGL context
30
30
  */
31
- void S2D_GL_PrintContextInfo(S2D_Window *window) {
32
- S2D_Log(S2D_INFO,
31
+ void R2D_GL_PrintContextInfo(R2D_Window *window) {
32
+ R2D_Log(R2D_INFO,
33
33
  "OpenGL Context\n"
34
34
  " GL_VENDOR: %s\n"
35
35
  " GL_RENDERER: %s\n"
36
36
  " GL_VERSION: %s\n"
37
37
  " GL_SHADING_LANGUAGE_VERSION: %s",
38
- window->S2D_GL_VENDOR,
39
- window->S2D_GL_RENDERER,
40
- window->S2D_GL_VERSION,
41
- window->S2D_GL_SHADING_LANGUAGE_VERSION
38
+ window->R2D_GL_VENDOR,
39
+ window->R2D_GL_RENDERER,
40
+ window->R2D_GL_VERSION,
41
+ window->R2D_GL_SHADING_LANGUAGE_VERSION
42
42
  );
43
43
  }
44
44
 
@@ -46,22 +46,22 @@ void S2D_GL_PrintContextInfo(S2D_Window *window) {
46
46
  /*
47
47
  * Store info about the current OpenGL context
48
48
  */
49
- void S2D_GL_StoreContextInfo(S2D_Window *window) {
49
+ void R2D_GL_StoreContextInfo(R2D_Window *window) {
50
50
 
51
- window->S2D_GL_VENDOR = glGetString(GL_VENDOR);
52
- window->S2D_GL_RENDERER = glGetString(GL_RENDERER);
53
- window->S2D_GL_VERSION = glGetString(GL_VERSION);
51
+ window->R2D_GL_VENDOR = glGetString(GL_VENDOR);
52
+ window->R2D_GL_RENDERER = glGetString(GL_RENDERER);
53
+ window->R2D_GL_VERSION = glGetString(GL_VERSION);
54
54
 
55
55
  // These are not defined in GLES
56
56
  #if GLES
57
- window->S2D_GL_MAJOR_VERSION = 0;
58
- window->S2D_GL_MINOR_VERSION = 0;
57
+ window->R2D_GL_MAJOR_VERSION = 0;
58
+ window->R2D_GL_MINOR_VERSION = 0;
59
59
  #else
60
- glGetIntegerv(GL_MAJOR_VERSION, &window->S2D_GL_MAJOR_VERSION);
61
- glGetIntegerv(GL_MINOR_VERSION, &window->S2D_GL_MINOR_VERSION);
60
+ glGetIntegerv(GL_MAJOR_VERSION, &window->R2D_GL_MAJOR_VERSION);
61
+ glGetIntegerv(GL_MINOR_VERSION, &window->R2D_GL_MINOR_VERSION);
62
62
  #endif
63
63
 
64
- window->S2D_GL_SHADING_LANGUAGE_VERSION = glGetString(GL_SHADING_LANGUAGE_VERSION);
64
+ window->R2D_GL_SHADING_LANGUAGE_VERSION = glGetString(GL_SHADING_LANGUAGE_VERSION);
65
65
  };
66
66
 
67
67
 
@@ -69,13 +69,13 @@ void S2D_GL_StoreContextInfo(S2D_Window *window) {
69
69
  * Creates a shader object, loads shader string, and compiles.
70
70
  * Returns 0 if shader could not be compiled.
71
71
  */
72
- GLuint S2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName) {
72
+ GLuint R2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName) {
73
73
 
74
74
  // Create the shader object
75
75
  GLuint shader = glCreateShader(type);
76
76
 
77
77
  if (shader == 0) {
78
- S2D_GL_PrintError("Failed to create shader program");
78
+ R2D_GL_PrintError("Failed to create shader program");
79
79
  return 0;
80
80
  }
81
81
 
@@ -111,7 +111,7 @@ GLuint S2D_GL_LoadShader(GLenum type, const GLchar *shaderSrc, char *shaderName)
111
111
  /*
112
112
  * Check if shader program was linked
113
113
  */
114
- int S2D_GL_CheckLinked(GLuint program, char *name) {
114
+ int R2D_GL_CheckLinked(GLuint program, char *name) {
115
115
 
116
116
  GLint linked;
117
117
  glGetProgramiv(program, GL_LINK_STATUS, &linked);
@@ -138,7 +138,7 @@ int S2D_GL_CheckLinked(GLuint program, char *name) {
138
138
  /*
139
139
  * Calculate the viewport's scaled width and height
140
140
  */
141
- void S2D_GL_GetViewportScale(S2D_Window *window, int *w, int *h, double *scale) {
141
+ void R2D_GL_GetViewportScale(R2D_Window *window, int *w, int *h, double *scale) {
142
142
 
143
143
  double s = fmin(
144
144
  window->width / (double)window->viewport.width,
@@ -155,7 +155,7 @@ void S2D_GL_GetViewportScale(S2D_Window *window, int *w, int *h, double *scale)
155
155
  /*
156
156
  * Sets the viewport and matrix projection
157
157
  */
158
- void S2D_GL_SetViewport(S2D_Window *window) {
158
+ void R2D_GL_SetViewport(R2D_Window *window) {
159
159
 
160
160
  int ortho_w = window->viewport.width;
161
161
  int ortho_h = window->viewport.height;
@@ -165,25 +165,25 @@ void S2D_GL_SetViewport(S2D_Window *window) {
165
165
 
166
166
  switch (window->viewport.mode) {
167
167
 
168
- case S2D_FIXED:
168
+ case R2D_FIXED:
169
169
  w = window->orig_width;
170
170
  h = window->orig_height;
171
171
  y = window->height - h;
172
172
  break;
173
173
 
174
- case S2D_EXPAND:
174
+ case R2D_EXPAND:
175
175
  ortho_w = w;
176
176
  ortho_h = h;
177
177
  break;
178
178
 
179
- case S2D_SCALE:
180
- S2D_GL_GetViewportScale(window, &w, &h, NULL);
179
+ case R2D_SCALE:
180
+ R2D_GL_GetViewportScale(window, &w, &h, NULL);
181
181
  // Center the viewport
182
182
  x = window->width / 2.0 - w/2.0;
183
183
  y = window->height / 2.0 - h/2.0;
184
184
  break;
185
185
 
186
- case S2D_STRETCH:
186
+ case R2D_STRETCH:
187
187
  break;
188
188
  }
189
189
 
@@ -194,12 +194,12 @@ void S2D_GL_SetViewport(S2D_Window *window) {
194
194
  orthoMatrix[5] = -2.0f / (GLfloat)ortho_h;
195
195
 
196
196
  #if GLES
197
- S2D_GLES_ApplyProjection(orthoMatrix);
197
+ R2D_GLES_ApplyProjection(orthoMatrix);
198
198
  #else
199
- if (S2D_GL2) {
200
- S2D_GL2_ApplyProjection(ortho_w, ortho_h);
199
+ if (R2D_GL2) {
200
+ R2D_GL2_ApplyProjection(ortho_w, ortho_h);
201
201
  } else {
202
- S2D_GL3_ApplyProjection(orthoMatrix);
202
+ R2D_GL3_ApplyProjection(orthoMatrix);
203
203
  }
204
204
  #endif
205
205
  }
@@ -208,7 +208,7 @@ void S2D_GL_SetViewport(S2D_Window *window) {
208
208
  /*
209
209
  * Initialize OpenGL
210
210
  */
211
- int S2D_GL_Init(S2D_Window *window) {
211
+ int R2D_GL_Init(R2D_Window *window) {
212
212
 
213
213
  // Specify OpenGL contexts and set attributes
214
214
  #if GLES
@@ -244,25 +244,25 @@ int S2D_GL_Init(S2D_Window *window) {
244
244
 
245
245
  // Initialize OpenGL ES 2.0
246
246
  #if GLES
247
- S2D_GLES_Init();
248
- S2D_GL_SetViewport(window);
247
+ R2D_GLES_Init();
248
+ R2D_GL_SetViewport(window);
249
249
 
250
250
  // Initialize OpenGL 3.3+
251
251
  #else
252
252
  // Initialize GLEW on Windows
253
253
  #if WINDOWS
254
254
  GLenum err = glewInit();
255
- if (GLEW_OK != err) S2D_Error("GLEW", glewGetErrorString(err));
255
+ if (GLEW_OK != err) R2D_Error("GLEW", glewGetErrorString(err));
256
256
  #endif
257
- S2D_GL3_Init();
258
- S2D_GL_SetViewport(window);
257
+ R2D_GL3_Init();
258
+ R2D_GL_SetViewport(window);
259
259
  #endif
260
260
 
261
261
  // Context could not be created
262
262
  } else {
263
263
 
264
264
  #if GLES
265
- S2D_Error("GLES / SDL_GL_CreateContext", SDL_GetError());
265
+ R2D_Error("GLES / SDL_GL_CreateContext", SDL_GetError());
266
266
 
267
267
  #else
268
268
  // Try to fallback using an OpenGL 2.1 context
@@ -275,22 +275,22 @@ int S2D_GL_Init(S2D_Window *window) {
275
275
  // Check if this context was created
276
276
  if (window->glcontext) {
277
277
  // Valid context found
278
- S2D_GL2 = true;
279
- S2D_GL2_Init();
280
- S2D_GL_SetViewport(window);
278
+ R2D_GL2 = true;
279
+ R2D_GL2_Init();
280
+ R2D_GL_SetViewport(window);
281
281
 
282
282
  // Could not create any OpenGL contexts, hard failure
283
283
  } else {
284
- S2D_Error("GL2 / SDL_GL_CreateContext", SDL_GetError());
285
- S2D_Log(S2D_ERROR, "An OpenGL context could not be created");
284
+ R2D_Error("GL2 / SDL_GL_CreateContext", SDL_GetError());
285
+ R2D_Log(R2D_ERROR, "An OpenGL context could not be created");
286
286
  return -1;
287
287
  }
288
288
  #endif
289
289
  }
290
290
 
291
291
  // Store the context and print it if diagnostics is enabled
292
- S2D_GL_StoreContextInfo(window);
293
- if (S2D_diagnostics) S2D_GL_PrintContextInfo(window);
292
+ R2D_GL_StoreContextInfo(window);
293
+ if (R2D_diagnostics) R2D_GL_PrintContextInfo(window);
294
294
 
295
295
  return 0;
296
296
  }
@@ -299,7 +299,7 @@ int S2D_GL_Init(S2D_Window *window) {
299
299
  /*
300
300
  * Creates a texture for rendering
301
301
  */
302
- void S2D_GL_CreateTexture(GLuint *id, GLint format,
302
+ void R2D_GL_CreateTexture(GLuint *id, GLint format,
303
303
  int w, int h,
304
304
  const GLvoid *data, GLint filter) {
305
305
 
@@ -324,7 +324,7 @@ void S2D_GL_CreateTexture(GLuint *id, GLint format,
324
324
  /*
325
325
  * Free a texture
326
326
  */
327
- void S2D_GL_FreeTexture(GLuint *id) {
327
+ void R2D_GL_FreeTexture(GLuint *id) {
328
328
  if (*id != 0) {
329
329
  glDeleteTextures(1, id);
330
330
  *id = 0;
@@ -335,7 +335,7 @@ void S2D_GL_FreeTexture(GLuint *id) {
335
335
  /*
336
336
  * Draw a triangle
337
337
  */
338
- void S2D_GL_DrawTriangle(GLfloat x1, GLfloat y1,
338
+ void R2D_GL_DrawTriangle(GLfloat x1, GLfloat y1,
339
339
  GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
340
340
  GLfloat x2, GLfloat y2,
341
341
  GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
@@ -343,16 +343,16 @@ void S2D_GL_DrawTriangle(GLfloat x1, GLfloat y1,
343
343
  GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3) {
344
344
 
345
345
  #if GLES
346
- S2D_GLES_DrawTriangle(x1, y1, r1, g1, b1, a1,
346
+ R2D_GLES_DrawTriangle(x1, y1, r1, g1, b1, a1,
347
347
  x2, y2, r2, g2, b2, a2,
348
348
  x3, y3, r3, g3, b3, a3);
349
349
  #else
350
- if (S2D_GL2) {
351
- S2D_GL2_DrawTriangle(x1, y1, r1, g1, b1, a1,
350
+ if (R2D_GL2) {
351
+ R2D_GL2_DrawTriangle(x1, y1, r1, g1, b1, a1,
352
352
  x2, y2, r2, g2, b2, a2,
353
353
  x3, y3, r3, g3, b3, a3);
354
354
  } else {
355
- S2D_GL3_DrawTriangle(x1, y1, r1, g1, b1, a1,
355
+ R2D_GL3_DrawTriangle(x1, y1, r1, g1, b1, a1,
356
356
  x2, y2, r2, g2, b2, a2,
357
357
  x3, y3, r3, g3, b3, a3);
358
358
  }
@@ -363,14 +363,14 @@ void S2D_GL_DrawTriangle(GLfloat x1, GLfloat y1,
363
363
  /*
364
364
  * Draw an image
365
365
  */
366
- void S2D_GL_DrawImage(S2D_Image *img) {
366
+ void R2D_GL_DrawImage(R2D_Image *img) {
367
367
  #if GLES
368
- S2D_GLES_DrawImage(img);
368
+ R2D_GLES_DrawImage(img);
369
369
  #else
370
- if (S2D_GL2) {
371
- S2D_GL2_DrawImage(img);
370
+ if (R2D_GL2) {
371
+ R2D_GL2_DrawImage(img);
372
372
  } else {
373
- S2D_GL3_DrawImage(img);
373
+ R2D_GL3_DrawImage(img);
374
374
  }
375
375
  #endif
376
376
  }
@@ -379,14 +379,14 @@ void S2D_GL_DrawImage(S2D_Image *img) {
379
379
  /*
380
380
  * Draw sprite
381
381
  */
382
- void S2D_GL_DrawSprite(S2D_Sprite *spr) {
382
+ void R2D_GL_DrawSprite(R2D_Sprite *spr) {
383
383
  #if GLES
384
- S2D_GLES_DrawSprite(spr);
384
+ R2D_GLES_DrawSprite(spr);
385
385
  #else
386
- if (S2D_GL2) {
387
- S2D_GL2_DrawSprite(spr);
386
+ if (R2D_GL2) {
387
+ R2D_GL2_DrawSprite(spr);
388
388
  } else {
389
- S2D_GL3_DrawSprite(spr);
389
+ R2D_GL3_DrawSprite(spr);
390
390
  }
391
391
  #endif
392
392
  }
@@ -395,14 +395,14 @@ void S2D_GL_DrawSprite(S2D_Sprite *spr) {
395
395
  /*
396
396
  * Draw text
397
397
  */
398
- void S2D_GL_DrawText(S2D_Text *txt) {
398
+ void R2D_GL_DrawText(R2D_Text *txt) {
399
399
  #if GLES
400
- S2D_GLES_DrawText(txt);
400
+ R2D_GLES_DrawText(txt);
401
401
  #else
402
- if (S2D_GL2) {
403
- S2D_GL2_DrawText(txt);
402
+ if (R2D_GL2) {
403
+ R2D_GL2_DrawText(txt);
404
404
  } else {
405
- S2D_GL3_DrawText(txt);
405
+ R2D_GL3_DrawText(txt);
406
406
  }
407
407
  #endif
408
408
  }
@@ -411,12 +411,12 @@ void S2D_GL_DrawText(S2D_Text *txt) {
411
411
  /*
412
412
  * Render and flush OpenGL buffers
413
413
  */
414
- void S2D_GL_FlushBuffers() {
414
+ void R2D_GL_FlushBuffers() {
415
415
  // Only implemented in our OpenGL 3.3+ and ES 2.0 renderers
416
416
  #if GLES
417
- // TODO: S2D_GLES_FlushBuffers();
417
+ // TODO: R2D_GLES_FlushBuffers();
418
418
  #else
419
- if (!S2D_GL2) S2D_GL3_FlushBuffers();
419
+ if (!R2D_GL2) R2D_GL3_FlushBuffers();
420
420
  #endif
421
421
  }
422
422
 
@@ -424,7 +424,7 @@ void S2D_GL_FlushBuffers() {
424
424
  /*
425
425
  * Clear buffers to given color values
426
426
  */
427
- void S2D_GL_Clear(S2D_Color clr) {
427
+ void R2D_GL_Clear(R2D_Color clr) {
428
428
  glClearColor(clr.r, clr.g, clr.b, clr.a);
429
429
  glClear(GL_COLOR_BUFFER_BIT);
430
430
  }