ruby2d 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  // OpenGL 2.1
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
  #if !GLES
6
6
 
@@ -8,7 +8,7 @@
8
8
  /*
9
9
  * Applies the projection matrix
10
10
  */
11
- void S2D_GL2_ApplyProjection(int w, int h) {
11
+ void R2D_GL2_ApplyProjection(int w, int h) {
12
12
 
13
13
  // Initialize the projection matrix
14
14
  glMatrixMode(GL_PROJECTION);
@@ -26,7 +26,7 @@ void S2D_GL2_ApplyProjection(int w, int h) {
26
26
  /*
27
27
  * Initalize OpenGL
28
28
  */
29
- int S2D_GL2_Init() {
29
+ int R2D_GL2_Init() {
30
30
 
31
31
  GLenum error = GL_NO_ERROR;
32
32
 
@@ -37,7 +37,7 @@ int S2D_GL2_Init() {
37
37
  // Check for errors
38
38
  error = glGetError();
39
39
  if (error != GL_NO_ERROR) {
40
- S2D_GL_PrintError("OpenGL initialization failed");
40
+ R2D_GL_PrintError("OpenGL initialization failed");
41
41
  return 1;
42
42
  } else {
43
43
  return 0;
@@ -48,7 +48,7 @@ int S2D_GL2_Init() {
48
48
  /*
49
49
  * Draw triangle
50
50
  */
51
- void S2D_GL2_DrawTriangle(GLfloat x1, GLfloat y1,
51
+ void R2D_GL2_DrawTriangle(GLfloat x1, GLfloat y1,
52
52
  GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
53
53
  GLfloat x2, GLfloat y2,
54
54
  GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
@@ -66,24 +66,24 @@ void S2D_GL2_DrawTriangle(GLfloat x1, GLfloat y1,
66
66
  /*
67
67
  * Draw texture
68
68
  */
69
- static void S2D_GL2_DrawTexture(int x, int y, int w, int h,
69
+ static void R2D_GL2_DrawTexture(int x, int y, int w, int h,
70
70
  GLfloat angle, GLfloat rx, GLfloat ry,
71
71
  GLfloat r, GLfloat g, GLfloat b, GLfloat a,
72
72
  GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
73
73
  GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4,
74
74
  GLuint texture_id) {
75
75
 
76
- S2D_GL_Point v1 = { .x = x, .y = y };
77
- S2D_GL_Point v2 = { .x = x + w, .y = y };
78
- S2D_GL_Point v3 = { .x = x + w, .y = y + h };
79
- S2D_GL_Point v4 = { .x = x, .y = y + h };
76
+ R2D_GL_Point v1 = { .x = x, .y = y };
77
+ R2D_GL_Point v2 = { .x = x + w, .y = y };
78
+ R2D_GL_Point v3 = { .x = x + w, .y = y + h };
79
+ R2D_GL_Point v4 = { .x = x, .y = y + h };
80
80
 
81
81
  // Rotate vertices
82
82
  if (angle != 0) {
83
- v1 = S2D_RotatePoint(v1, angle, rx, ry);
84
- v2 = S2D_RotatePoint(v2, angle, rx, ry);
85
- v3 = S2D_RotatePoint(v3, angle, rx, ry);
86
- v4 = S2D_RotatePoint(v4, angle, rx, ry);
83
+ v1 = R2D_RotatePoint(v1, angle, rx, ry);
84
+ v2 = R2D_RotatePoint(v2, angle, rx, ry);
85
+ v3 = R2D_RotatePoint(v3, angle, rx, ry);
86
+ v4 = R2D_RotatePoint(v4, angle, rx, ry);
87
87
  }
88
88
 
89
89
  glEnable(GL_TEXTURE_2D);
@@ -105,8 +105,8 @@ static void S2D_GL2_DrawTexture(int x, int y, int w, int h,
105
105
  /*
106
106
  * Draw image
107
107
  */
108
- void S2D_GL2_DrawImage(S2D_Image *img) {
109
- S2D_GL2_DrawTexture(
108
+ void R2D_GL2_DrawImage(R2D_Image *img) {
109
+ R2D_GL2_DrawTexture(
110
110
  img->x, img->y, img->width, img->height,
111
111
  img->rotate, img->rx, img->ry,
112
112
  img->color.r, img->color.g, img->color.b, img->color.a,
@@ -119,8 +119,8 @@ void S2D_GL2_DrawImage(S2D_Image *img) {
119
119
  /*
120
120
  * Draw sprite
121
121
  */
122
- void S2D_GL2_DrawSprite(S2D_Sprite *spr) {
123
- S2D_GL2_DrawTexture(
122
+ void R2D_GL2_DrawSprite(R2D_Sprite *spr) {
123
+ R2D_GL2_DrawTexture(
124
124
  spr->x, spr->y, spr->width, spr->height,
125
125
  spr->rotate, spr->rx, spr->ry,
126
126
  spr->color.r, spr->color.g, spr->color.b, spr->color.a,
@@ -133,8 +133,8 @@ void S2D_GL2_DrawSprite(S2D_Sprite *spr) {
133
133
  /*
134
134
  * Draw text
135
135
  */
136
- void S2D_GL2_DrawText(S2D_Text *txt) {
137
- S2D_GL2_DrawTexture(
136
+ void R2D_GL2_DrawText(R2D_Text *txt) {
137
+ R2D_GL2_DrawTexture(
138
138
  txt->x, txt->y, txt->width, txt->height,
139
139
  txt->rotate, txt->rx, txt->ry,
140
140
  txt->color.r, txt->color.g, txt->color.b, txt->color.a,
@@ -1,6 +1,6 @@
1
1
  // OpenGL 3.3+
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
  // Skip this file if OpenGL ES
6
6
  #if !GLES
@@ -21,7 +21,7 @@ static GLuint indices[] = // indices for rendering textured quads
21
21
  /*
22
22
  * Applies the projection matrix
23
23
  */
24
- void S2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]) {
24
+ void R2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]) {
25
25
 
26
26
  // Use the program object
27
27
  glUseProgram(shaderProgram);
@@ -46,7 +46,7 @@ void S2D_GL3_ApplyProjection(GLfloat orthoMatrix[16]) {
46
46
  /*
47
47
  * Initalize OpenGL
48
48
  */
49
- int S2D_GL3_Init() {
49
+ int R2D_GL3_Init() {
50
50
 
51
51
  // Enable transparency
52
52
  glEnable(GL_BLEND);
@@ -116,9 +116,9 @@ int S2D_GL3_Init() {
116
116
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
117
117
 
118
118
  // Load the vertex and fragment shaders
119
- GLuint vertexShader = S2D_GL_LoadShader( GL_VERTEX_SHADER, vertexSource, "GL3 Vertex");
120
- GLuint fragmentShader = S2D_GL_LoadShader(GL_FRAGMENT_SHADER, fragmentSource, "GL3 Fragment");
121
- GLuint texFragmentShader = S2D_GL_LoadShader(GL_FRAGMENT_SHADER, texFragmentSource, "GL3 Texture Fragment");
119
+ GLuint vertexShader = R2D_GL_LoadShader( GL_VERTEX_SHADER, vertexSource, "GL3 Vertex");
120
+ GLuint fragmentShader = R2D_GL_LoadShader(GL_FRAGMENT_SHADER, fragmentSource, "GL3 Fragment");
121
+ GLuint texFragmentShader = R2D_GL_LoadShader(GL_FRAGMENT_SHADER, texFragmentSource, "GL3 Texture Fragment");
122
122
 
123
123
  // Triangle Shader //
124
124
 
@@ -127,7 +127,7 @@ int S2D_GL3_Init() {
127
127
 
128
128
  // Check if program was created successfully
129
129
  if (shaderProgram == 0) {
130
- S2D_GL_PrintError("Failed to create shader program");
130
+ R2D_GL_PrintError("Failed to create shader program");
131
131
  return GL_FALSE;
132
132
  }
133
133
 
@@ -142,7 +142,7 @@ int S2D_GL3_Init() {
142
142
  glLinkProgram(shaderProgram);
143
143
 
144
144
  // Check if linked
145
- S2D_GL_CheckLinked(shaderProgram, "GL3 shader");
145
+ R2D_GL_CheckLinked(shaderProgram, "GL3 shader");
146
146
 
147
147
  // Specify the layout of the position vertex data...
148
148
  GLint posAttrib = glGetAttribLocation(shaderProgram, "position");
@@ -161,7 +161,7 @@ int S2D_GL3_Init() {
161
161
 
162
162
  // Check if program was created successfully
163
163
  if (texShaderProgram == 0) {
164
- S2D_GL_PrintError("Failed to create shader program");
164
+ R2D_GL_PrintError("Failed to create shader program");
165
165
  return GL_FALSE;
166
166
  }
167
167
 
@@ -176,7 +176,7 @@ int S2D_GL3_Init() {
176
176
  glLinkProgram(texShaderProgram);
177
177
 
178
178
  // Check if linked
179
- S2D_GL_CheckLinked(texShaderProgram, "GL3 texture shader");
179
+ R2D_GL_CheckLinked(texShaderProgram, "GL3 texture shader");
180
180
 
181
181
  // Specify the layout of the position vertex data...
182
182
  posAttrib = glGetAttribLocation(texShaderProgram, "position");
@@ -206,7 +206,7 @@ int S2D_GL3_Init() {
206
206
  /*
207
207
  * Render the vertex buffer and reset it
208
208
  */
209
- void S2D_GL3_FlushBuffers() {
209
+ void R2D_GL3_FlushBuffers() {
210
210
 
211
211
  // Use the triangle shader program
212
212
  glUseProgram(shaderProgram);
@@ -228,7 +228,7 @@ void S2D_GL3_FlushBuffers() {
228
228
  /*
229
229
  * Draw triangle
230
230
  */
231
- void S2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
231
+ void R2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
232
232
  GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
233
233
  GLfloat x2, GLfloat y2,
234
234
  GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
@@ -236,7 +236,7 @@ void S2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
236
236
  GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3) {
237
237
 
238
238
  // If buffer is full, flush it
239
- if (vboDataIndex >= vboObjCapacity) S2D_GL3_FlushBuffers();
239
+ if (vboDataIndex >= vboObjCapacity) R2D_GL3_FlushBuffers();
240
240
 
241
241
  // Set the triangle data into a formatted array
242
242
  GLfloat vertices[] =
@@ -256,7 +256,7 @@ void S2D_GL3_DrawTriangle(GLfloat x1, GLfloat y1,
256
256
  /*
257
257
  * Draw a texture
258
258
  */
259
- static void S2D_GL3_DrawTexture(int x, int y, int w, int h,
259
+ static void R2D_GL3_DrawTexture(int x, int y, int w, int h,
260
260
  GLfloat angle, GLfloat rx, GLfloat ry,
261
261
  GLfloat r, GLfloat g, GLfloat b, GLfloat a,
262
262
  GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
@@ -265,20 +265,20 @@ static void S2D_GL3_DrawTexture(int x, int y, int w, int h,
265
265
 
266
266
  // Currently, textures are not buffered, so we have to flush all buffers so
267
267
  // textures get rendered in the correct Z order
268
- S2D_GL3_FlushBuffers();
268
+ R2D_GL3_FlushBuffers();
269
269
 
270
270
  // Set up the vertex points
271
- S2D_GL_Point v1 = { .x = x, .y = y };
272
- S2D_GL_Point v2 = { .x = x + w, .y = y };
273
- S2D_GL_Point v3 = { .x = x + w, .y = y + h };
274
- S2D_GL_Point v4 = { .x = x, .y = y + h };
271
+ R2D_GL_Point v1 = { .x = x, .y = y };
272
+ R2D_GL_Point v2 = { .x = x + w, .y = y };
273
+ R2D_GL_Point v3 = { .x = x + w, .y = y + h };
274
+ R2D_GL_Point v4 = { .x = x, .y = y + h };
275
275
 
276
276
  // Rotate vertices
277
277
  if (angle != 0) {
278
- v1 = S2D_RotatePoint(v1, angle, rx, ry);
279
- v2 = S2D_RotatePoint(v2, angle, rx, ry);
280
- v3 = S2D_RotatePoint(v3, angle, rx, ry);
281
- v4 = S2D_RotatePoint(v4, angle, rx, ry);
278
+ v1 = R2D_RotatePoint(v1, angle, rx, ry);
279
+ v2 = R2D_RotatePoint(v2, angle, rx, ry);
280
+ v3 = R2D_RotatePoint(v3, angle, rx, ry);
281
+ v4 = R2D_RotatePoint(v4, angle, rx, ry);
282
282
  }
283
283
 
284
284
  // Set the textured quad data into a formatted array
@@ -307,8 +307,8 @@ static void S2D_GL3_DrawTexture(int x, int y, int w, int h,
307
307
  /*
308
308
  * Draw image
309
309
  */
310
- void S2D_GL3_DrawImage(S2D_Image *img) {
311
- S2D_GL3_DrawTexture(
310
+ void R2D_GL3_DrawImage(R2D_Image *img) {
311
+ R2D_GL3_DrawTexture(
312
312
  img->x, img->y, img->width, img->height,
313
313
  img->rotate, img->rx, img->ry,
314
314
  img->color.r, img->color.g, img->color.b, img->color.a,
@@ -321,8 +321,8 @@ void S2D_GL3_DrawImage(S2D_Image *img) {
321
321
  /*
322
322
  * Draw sprite
323
323
  */
324
- void S2D_GL3_DrawSprite(S2D_Sprite *spr) {
325
- S2D_GL3_DrawTexture(
324
+ void R2D_GL3_DrawSprite(R2D_Sprite *spr) {
325
+ R2D_GL3_DrawTexture(
326
326
  spr->x, spr->y, spr->width, spr->height,
327
327
  spr->rotate, spr->rx, spr->ry,
328
328
  spr->color.r, spr->color.g, spr->color.b, spr->color.a,
@@ -335,8 +335,8 @@ void S2D_GL3_DrawSprite(S2D_Sprite *spr) {
335
335
  /*
336
336
  * Draw text
337
337
  */
338
- void S2D_GL3_DrawText(S2D_Text *txt) {
339
- S2D_GL3_DrawTexture(
338
+ void R2D_GL3_DrawText(R2D_Text *txt) {
339
+ R2D_GL3_DrawTexture(
340
340
  txt->x, txt->y, txt->width, txt->height,
341
341
  txt->rotate, txt->rx, txt->ry,
342
342
  txt->color.r, txt->color.g, txt->color.b, txt->color.a,
@@ -1,6 +1,6 @@
1
1
  // OpenGL ES 2.0
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
  #if GLES
6
6
 
@@ -24,7 +24,7 @@ static GLushort indices[] =
24
24
  /*
25
25
  * Applies the projection matrix
26
26
  */
27
- void S2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
27
+ void R2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
28
28
 
29
29
  // Use the program object
30
30
  glUseProgram(shaderProgram);
@@ -47,7 +47,7 @@ void S2D_GLES_ApplyProjection(GLfloat orthoMatrix[16]) {
47
47
  /*
48
48
  * Initalize OpenGL ES
49
49
  */
50
- int S2D_GLES_Init() {
50
+ int R2D_GLES_Init() {
51
51
 
52
52
  // Enable transparency
53
53
  glEnable(GL_BLEND);
@@ -99,9 +99,9 @@ int S2D_GLES_Init() {
99
99
  "}";
100
100
 
101
101
  // Load the vertex and fragment shaders
102
- GLuint vertexShader = S2D_GL_LoadShader( GL_VERTEX_SHADER, vertexSource, "GLES Vertex");
103
- GLuint fragmentShader = S2D_GL_LoadShader(GL_FRAGMENT_SHADER, fragmentSource, "GLES Fragment");
104
- GLuint texFragmentShader = S2D_GL_LoadShader(GL_FRAGMENT_SHADER, texFragmentSource, "GLES Texture Fragment");
102
+ GLuint vertexShader = R2D_GL_LoadShader( GL_VERTEX_SHADER, vertexSource, "GLES Vertex");
103
+ GLuint fragmentShader = R2D_GL_LoadShader(GL_FRAGMENT_SHADER, fragmentSource, "GLES Fragment");
104
+ GLuint texFragmentShader = R2D_GL_LoadShader(GL_FRAGMENT_SHADER, texFragmentSource, "GLES Texture Fragment");
105
105
 
106
106
  // Triangle Shader //
107
107
 
@@ -110,7 +110,7 @@ int S2D_GLES_Init() {
110
110
 
111
111
  // Check if program was created successfully
112
112
  if (shaderProgram == 0) {
113
- S2D_GL_PrintError("Failed to create shader program");
113
+ R2D_GL_PrintError("Failed to create shader program");
114
114
  return GL_FALSE;
115
115
  }
116
116
 
@@ -122,7 +122,7 @@ int S2D_GLES_Init() {
122
122
  glLinkProgram(shaderProgram);
123
123
 
124
124
  // Check if linked
125
- S2D_GL_CheckLinked(shaderProgram, "GLES shader");
125
+ R2D_GL_CheckLinked(shaderProgram, "GLES shader");
126
126
 
127
127
  // Get the attribute locations
128
128
  positionLocation = glGetAttribLocation(shaderProgram, "a_position");
@@ -135,7 +135,7 @@ int S2D_GLES_Init() {
135
135
 
136
136
  // Check if program was created successfully
137
137
  if (texShaderProgram == 0) {
138
- S2D_GL_PrintError("Failed to create shader program");
138
+ R2D_GL_PrintError("Failed to create shader program");
139
139
  return GL_FALSE;
140
140
  }
141
141
 
@@ -147,7 +147,7 @@ int S2D_GLES_Init() {
147
147
  glLinkProgram(texShaderProgram);
148
148
 
149
149
  // Check if linked
150
- S2D_GL_CheckLinked(texShaderProgram, "GLES texture shader");
150
+ R2D_GL_CheckLinked(texShaderProgram, "GLES texture shader");
151
151
 
152
152
  // Get the attribute locations
153
153
  texPositionLocation = glGetAttribLocation(texShaderProgram, "a_position");
@@ -169,7 +169,7 @@ int S2D_GLES_Init() {
169
169
  /*
170
170
  * Draw triangle
171
171
  */
172
- void S2D_GLES_DrawTriangle(GLfloat x1, GLfloat y1,
172
+ void R2D_GLES_DrawTriangle(GLfloat x1, GLfloat y1,
173
173
  GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1,
174
174
  GLfloat x2, GLfloat y2,
175
175
  GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2,
@@ -204,24 +204,24 @@ void S2D_GLES_DrawTriangle(GLfloat x1, GLfloat y1,
204
204
  /*
205
205
  * Draw a texture
206
206
  */
207
- static void S2D_GLES_DrawTexture(int x, int y, int w, int h,
207
+ static void R2D_GLES_DrawTexture(int x, int y, int w, int h,
208
208
  GLfloat angle, GLfloat rx, GLfloat ry,
209
209
  GLfloat r, GLfloat g, GLfloat b, GLfloat a,
210
210
  GLfloat tx1, GLfloat ty1, GLfloat tx2, GLfloat ty2,
211
211
  GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4,
212
212
  GLuint texture_id) {
213
213
 
214
- S2D_GL_Point v1 = { .x = x, .y = y };
215
- S2D_GL_Point v2 = { .x = x + w, .y = y };
216
- S2D_GL_Point v3 = { .x = x + w, .y = y + h };
217
- S2D_GL_Point v4 = { .x = x, .y = y + h };
214
+ R2D_GL_Point v1 = { .x = x, .y = y };
215
+ R2D_GL_Point v2 = { .x = x + w, .y = y };
216
+ R2D_GL_Point v3 = { .x = x + w, .y = y + h };
217
+ R2D_GL_Point v4 = { .x = x, .y = y + h };
218
218
 
219
219
  // Rotate vertices
220
220
  if (angle != 0) {
221
- v1 = S2D_RotatePoint(v1, angle, rx, ry);
222
- v2 = S2D_RotatePoint(v2, angle, rx, ry);
223
- v3 = S2D_RotatePoint(v3, angle, rx, ry);
224
- v4 = S2D_RotatePoint(v4, angle, rx, ry);
221
+ v1 = R2D_RotatePoint(v1, angle, rx, ry);
222
+ v2 = R2D_RotatePoint(v2, angle, rx, ry);
223
+ v3 = R2D_RotatePoint(v3, angle, rx, ry);
224
+ v4 = R2D_RotatePoint(v4, angle, rx, ry);
225
225
  }
226
226
 
227
227
  GLfloat vertices[] =
@@ -267,8 +267,8 @@ static void S2D_GLES_DrawTexture(int x, int y, int w, int h,
267
267
  /*
268
268
  * Draw image
269
269
  */
270
- void S2D_GLES_DrawImage(S2D_Image *img) {
271
- S2D_GLES_DrawTexture(
270
+ void R2D_GLES_DrawImage(R2D_Image *img) {
271
+ R2D_GLES_DrawTexture(
272
272
  img->x, img->y, img->width, img->height,
273
273
  img->rotate, img->rx, img->ry,
274
274
  img->color.r, img->color.g, img->color.b, img->color.a,
@@ -281,8 +281,8 @@ void S2D_GLES_DrawImage(S2D_Image *img) {
281
281
  /*
282
282
  * Draw sprite
283
283
  */
284
- void S2D_GLES_DrawSprite(S2D_Sprite *spr) {
285
- S2D_GLES_DrawTexture(
284
+ void R2D_GLES_DrawSprite(R2D_Sprite *spr) {
285
+ R2D_GLES_DrawTexture(
286
286
  spr->x, spr->y, spr->width, spr->height,
287
287
  spr->rotate, spr->rx, spr->ry,
288
288
  spr->color.r, spr->color.g, spr->color.b, spr->color.a,
@@ -295,8 +295,8 @@ void S2D_GLES_DrawSprite(S2D_Sprite *spr) {
295
295
  /*
296
296
  * Draw text
297
297
  */
298
- void S2D_GLES_DrawText(S2D_Text *txt) {
299
- S2D_GLES_DrawTexture(
298
+ void R2D_GLES_DrawText(R2D_Text *txt) {
299
+ R2D_GLES_DrawTexture(
300
300
  txt->x, txt->y, txt->width, txt->height,
301
301
  txt->rotate, txt->rx, txt->ry,
302
302
  txt->color.r, txt->color.g, txt->color.b, txt->color.a,
@@ -1,31 +1,31 @@
1
1
  // image.c
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
 
6
6
  /*
7
7
  * Create an image, given a file path
8
8
  */
9
- S2D_Image *S2D_CreateImage(const char *path) {
10
- S2D_Init();
9
+ R2D_Image *R2D_CreateImage(const char *path) {
10
+ R2D_Init();
11
11
 
12
12
  // Check if image file exists
13
- if (!S2D_FileExists(path)) {
14
- S2D_Error("S2D_CreateImage", "Image file `%s` not found", path);
13
+ if (!R2D_FileExists(path)) {
14
+ R2D_Error("R2D_CreateImage", "Image file `%s` not found", path);
15
15
  return NULL;
16
16
  }
17
17
 
18
18
  // Allocate the image structure
19
- S2D_Image *img = (S2D_Image *) malloc(sizeof(S2D_Image));
19
+ R2D_Image *img = (R2D_Image *) malloc(sizeof(R2D_Image));
20
20
  if (!img) {
21
- S2D_Error("S2D_CreateImage", "Out of memory!");
21
+ R2D_Error("R2D_CreateImage", "Out of memory!");
22
22
  return NULL;
23
23
  }
24
24
 
25
25
  // Load image from file as SDL_Surface
26
26
  img->surface = IMG_Load(path);
27
27
  if (!img->surface) {
28
- S2D_Error("IMG_Load", IMG_GetError());
28
+ R2D_Error("IMG_Load", IMG_GetError());
29
29
  free(img);
30
30
  return NULL;
31
31
  }
@@ -35,7 +35,7 @@ S2D_Image *S2D_CreateImage(const char *path) {
35
35
  img->surface->format->BitsPerPixel / 4;
36
36
 
37
37
  if (bits_per_color < 8) {
38
- S2D_Log(S2D_WARN, "`%s` has less than 8 bits per color and will likely not render correctly", path, bits_per_color);
38
+ R2D_Log(R2D_WARN, "`%s` has less than 8 bits per color and will likely not render correctly", path, bits_per_color);
39
39
  }
40
40
 
41
41
  // Initialize values
@@ -99,9 +99,9 @@ S2D_Image *S2D_CreateImage(const char *path) {
99
99
  /*
100
100
  * Rotate an image
101
101
  */
102
- void S2D_RotateImage(S2D_Image *img, GLfloat angle, int position) {
102
+ void R2D_RotateImage(R2D_Image *img, GLfloat angle, int position) {
103
103
 
104
- S2D_GL_Point p = S2D_GetRectRotationPoint(
104
+ R2D_GL_Point p = R2D_GetRectRotationPoint(
105
105
  img->x, img->y, img->width, img->height, position
106
106
  );
107
107
 
@@ -114,25 +114,25 @@ void S2D_RotateImage(S2D_Image *img, GLfloat angle, int position) {
114
114
  /*
115
115
  * Draw an image
116
116
  */
117
- void S2D_DrawImage(S2D_Image *img) {
117
+ void R2D_DrawImage(R2D_Image *img) {
118
118
  if (!img) return;
119
119
 
120
120
  if (img->texture_id == 0) {
121
- S2D_GL_CreateTexture(&img->texture_id, img->format,
121
+ R2D_GL_CreateTexture(&img->texture_id, img->format,
122
122
  img->orig_width, img->orig_height,
123
123
  img->surface->pixels, GL_NEAREST);
124
124
  SDL_FreeSurface(img->surface);
125
125
  }
126
126
 
127
- S2D_GL_DrawImage(img);
127
+ R2D_GL_DrawImage(img);
128
128
  }
129
129
 
130
130
 
131
131
  /*
132
132
  * Free an image
133
133
  */
134
- void S2D_FreeImage(S2D_Image *img) {
134
+ void R2D_FreeImage(R2D_Image *img) {
135
135
  if (!img) return;
136
- S2D_GL_FreeTexture(&img->texture_id);
136
+ R2D_GL_FreeTexture(&img->texture_id);
137
137
  free(img);
138
138
  }