add missing SDL/gles* files

This commit is contained in:
Mathieu Virbel 2012-07-07 22:35:16 +02:00
parent 3ec83695da
commit 06d30e79d5
7 changed files with 559 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,7 +2,6 @@
*.swp
Python-*
freetype-*
SDL_*
build/*
src/SDL/Xcode-iPhoneOS/SDL/build/
tmp/*

View file

@ -1,5 +1,5 @@
6098 c781fe3628a1d9ebfe5beb62dabf551fcef053aa a1616a61e966c1b1136d6ca57a0e7165441d603a
6087 185f8588deaa9c9790cb91730eb6e59dd9a27392
6309 f4e14c811fd52e34ee70aaebdd812965c17cb192 a1616a61e966c1b1136d6ca57a0e7165441d603a
6308 2b923729fd01d34b3913bd4ac8458c7121825f78 bb426bf40cac1882c852d81a696d72abf05ee755
5551 b95bb58b703af987349d3603a7d008e11a061d7a a1616a61e966c1b1136d6ca57a0e7165441d603a
5079 f2d8e0b59ccac6688e7a5c89399f7c842507968e a1616a61e966c1b1136d6ca57a0e7165441d603a
4416 06be4b33029d9e4012380084dd37dc1730062921
@ -29,3 +29,4 @@ bb051fa871aa0b53ea57df56a446cec3bb85924c release-1.2.2
4867f7f7dd3426d1dbbeef48b3f3b3aa19590cc4 release-1.2.12
7c2589fb8d4df54c6faabd3faebd0c0e73f67879 release-1.2.13
f14cf9d71233934811774f941d0de121d5f96ccf release-1.2.14
fba40d9f4a733e0cbf9197a0b1d19f9cff138f99 release-1.2.15

Binary file not shown.

View file

@ -0,0 +1,315 @@
/*
* Note: The Nintendo DS port to SDL uses excerpts from the libGL2D,
* with permission of the original author. The following is mostly his
* code/comments.
*
*
* Easy GL2D
*
* Relminator 2010
* Richard Eric M. Lope BSN RN
*
* http://rel.betterwebber.com
*
* A very small and simple DS rendering lib using the 3d core to render 2D stuff
*/
#include "SDL_config.h"
#if SDL_VIDEO_RENDER_NDS
#include "SDL_libgl2D.h"
/*
* Our static global variable used for Depth values since we cannot
* disable depth testing in the DS hardware This value is incremented
* for every draw call. */
v16 g_depth;
int gCurrentTexture;
/*
* !!! PRIVATE !!! Set orthographic projection at 1:1 correspondence
* to screen coords glOrtho expects f32 values but if we use the
* standard f32 values, we need to rescale either every vert or the
* modelview matrix by the same amount to make it work. That's gonna
* give us lots of overflows and headaches. So we "scale down" and
* use an all integer value.
*/
void SetOrtho(void)
{
glMatrixMode(GL_PROJECTION); // set matrixmode to projection
glLoadIdentity(); // reset
glOrthof32(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1 << 12, 1 << 12); // downscale projection matrix
}
/*
* Initializes GL in 2D mode Also initializes GL in 3d mode so that we
* could combine 2D and 3D later Almost a direct copy from the DS
* example files
*/
void glScreen2D(void)
{
// initialize gl
glInit();
// enable textures
glEnable(GL_TEXTURE_2D);
// enable antialiasing
glEnable(GL_ANTIALIAS);
// setup the rear plane
glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work
glClearPolyID(63); // BG must have a unique polygon ID for AA to work
glClearDepth(GL_MAX_DEPTH);
// this should work the same as the normal gl call
glViewport(0,0,255,191);
// any floating point gl call is being converted to fixed prior to being implemented
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, 256.0 / 192.0, 1, 200);
gluLookAt( 0.0, 0.0, 1.0, //camera possition
0.0, 0.0, 0.0, //look at
0.0, 1.0, 0.0); //up
glMaterialf(GL_AMBIENT, RGB15(31,31,31));
glMaterialf(GL_DIFFUSE, RGB15(31,31,31));
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(31,31,31));
glMaterialf(GL_EMISSION, RGB15(31,31,31));
// ds uses a table for shinyness..this generates a half-ass one
glMaterialShinyness();
// not a real gl function and will likely change
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK);
}
/*
* Sets up OpenGL for 2d rendering Call this before drawing any of
* GL2D's drawing or sprite functions.
*/
void glBegin2D(void)
{
// save 3d perpective projection matrix
glMatrixMode(GL_PROJECTION);
glPushMatrix();
// save 3d modelview matrix for safety
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
// what?!! No glDisable(GL_DEPTH_TEST)?!!!!!!
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glDisable(GL_ANTIALIAS); // disable AA
glDisable(GL_OUTLINE); // disable edge-marking
glColor(0x7FFF); // max color
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); // no culling
SetOrtho();
glMatrixMode(GL_TEXTURE); // reset texture matrix just in case we did some funky stuff with it
glLoadIdentity();
glMatrixMode(GL_MODELVIEW); // reset modelview matrix. No need to scale up by << 12
glLoadIdentity();
gCurrentTexture = 0; // set current texture to 0
g_depth = 0; // set depth to 0. We need this var since we cannot disable depth testing
}
/*
* Issue this after drawing 2d so that we don't mess the matrix stack.
* The complement of glBegin2D.
*/
void glEnd2D(void)
{
// restore 3d matrices and set current matrix to modelview
glMatrixMode(GL_PROJECTION);
glPopMatrix(1);
glMatrixMode(GL_MODELVIEW);
glPopMatrix(1);
}
/*
* Draws a pixel
* Parameters:
* x,y -> First coordinate of the line
* color -> RGB15/ARGB16 color
*/
void glPutPixel(int x, int y, int color)
{
glBindTexture(0, 0);
glColor(color);
glBegin(GL_TRIANGLES);
gxVertex3i(x, y, g_depth);
gxVertex2i(x, y);
gxVertex2i(x, y);
glEnd();
glColor(0x7FFF);
g_depth++;
gCurrentTexture = 0;
}
/*
* Draws a line
* Parameters:
* x1,y1 -> First coordinate of the line
* x2,y2 -> Second coordinate of the line
* color -> RGB15/ARGB16 color
*/
void glLine(int x1, int y1, int x2, int y2, int color)
{
x2++;
y2++;
glBindTexture(0, 0);
glColor(color);
glBegin(GL_TRIANGLES);
gxVertex3i(x1, y1, g_depth);
gxVertex2i(x2, y2);
gxVertex2i(x2, y2);
glEnd();
glColor(0x7FFF);
g_depth++;
gCurrentTexture = 0;
}
/*
* Draws a Filled Box
* Parameters:
* x1,y1 -> Top-left corner of the box
* x2,y2 -> Bottom-Right corner of the box
* color -> RGB15/ARGB16 color
*/
void glBoxFilled(int x1, int y1, int x2, int y2, int color)
{
x2++;
y2++;
glBindTexture(0, 0);
glColor(color);
glBegin(GL_QUADS);
gxVertex3i(x1, y1, g_depth); // use 3i for first vertex so that we increment HW depth
gxVertex2i(x1, y2); // no need for 3 vertices as 2i would share last depth call
gxVertex2i(x2, y2);
gxVertex2i(x2, y1);
glEnd();
glColor(0x7FFF);
g_depth++;
gCurrentTexture = 0;
}
/*
*
* Create a tile.
* Very rigid and prone to human error.
*
* Parameters:
* *sprite -> pointer to a glImage
* texture_width -> width/height of the texture;
* texture_height -> valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d)
* sprite_width
* sprite_height -> width/height of the picture in the texture.
* type -> The format of the texture (see glTexImage2d)
* param -> parameters for the texture (see glTexImage2d)
*/
int glLoadTile(glImage *sprite,
int texture_width,
int texture_height,
int sprite_width,
int sprite_height,
GL_TEXTURE_TYPE_ENUM type,
int param,
int pallette_width,
const u16 *palette,
const uint8 *texture)
{
int textureID;
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, type, texture_width, texture_height, 0, param, texture);
glColorTableEXT(0, 0, pallette_width, 0, 0, palette);
sprite->width = sprite_width;
sprite->height = sprite_height;
sprite->textureID = textureID;
return textureID;
}
/*
* I made this since the scale wrappers are either the vectorized mode
* or does not permit you to scale only the axis you want to
* scale. Needed for sprite scaling.
*/
static inline void gxScalef32(s32 x, s32 y, s32 z)
{
MATRIX_SCALE = x;
MATRIX_SCALE = y;
MATRIX_SCALE = z;
}
/*
* I this made for future naming conflicts.
*/
static inline void gxTranslate3f32(int32 x, int32 y, int32 z)
{
MATRIX_TRANSLATE = x;
MATRIX_TRANSLATE = y;
MATRIX_TRANSLATE = z;
}
/*
* Draws an axis exclusive scaled sprite
* Parameters:
* x -> x position of the sprite
* y -> y position of the sprite
* scaleX -> 20.12 FP X axis scale value (1 << 12 is normal)
* scaleY -> 20.12 FP Y axis scale value (1 << 12 is normal)
* flipmode -> mode for flipping (see GL_FLIP_MODE enum)
* *spr -> pointer to a glImage
*/
void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr)
{
const int x1 = 0;
const int y1 = 0;
const int x2 = spr->width;
const int y2 = spr->height;
const int u1 = ((flipmode & GL_FLIP_H) ? spr->width-1 : 0);
const int u2 = ((flipmode & GL_FLIP_H) ? 0 : spr->width-1);
const int v1 = ((flipmode & GL_FLIP_V) ? spr->height-1 : 0);
const int v2 = ((flipmode & GL_FLIP_V) ? 0 : spr->height-1);
if (spr->textureID != gCurrentTexture)
{
glBindTexture(GL_TEXTURE_2D, spr->textureID);
gCurrentTexture = spr->textureID;
}
glPushMatrix();
gxTranslate3f32(x, y, 0);
gxScalef32(scaleX, scaleY, 1 << 12);
glBegin(GL_QUADS);
gxTexcoord2i(u1, v1); gxVertex3i(x1, y1, g_depth);
gxTexcoord2i(u1, v2); gxVertex2i(x1, y2);
gxTexcoord2i(u2, v2); gxVertex2i(x2, y2);
gxTexcoord2i(u2, v1); gxVertex2i(x2, y1);
glEnd();
glPopMatrix(1);
g_depth++;
}
#endif /* SDL_VIDEO_RENDER_NDS */

View file

@ -0,0 +1,154 @@
/*
* Note: The Nintendo DS port to SDL uses excerpts from the libGL2D,
* with permission of the original author. The following is mostly his
* code/comments.
*
*
* Easy GL2D
*
* Relminator 2010
* Richard Eric M. Lope BSN RN
*
* http://rel.betterwebber.com
*
* A very small and simple DS rendering lib using the 3d core to render 2D stuff
*/
#include "SDL_config.h"
#if SDL_VIDEO_RENDER_NDS
#include <nds/arm9/videoGL.h>
/* LibGL extension(s) */
static inline void gxTexcoord2i(t16 u, t16 v)
{
GFX_TEX_COORD = (v << 20) | ((u << 4) & 0xFFFF);
}
static inline void gxVertex3i(v16 x, v16 y, v16 z)
{
GFX_VERTEX16 = (y << 16) | (x & 0xFFFF);
GFX_VERTEX16 = ((uint32)(uint16)z);
}
static inline void gxVertex2i(v16 x, v16 y)
{
GFX_VERTEX_XY = (y << 16) | (x & 0xFFFF);
}
/*
* Enums selecting flipping mode.
*
* These enums are bits for flipping the sprites.
* You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip
* both ways.
*/
typedef enum
{
GL_FLIP_NONE = (1 << 0), /* No flipping */
GL_FLIP_V = (1 << 1), /* Sprite is rendered vertically flipped */
GL_FLIP_H = (1 << 2), /* Sprite is rendered horizontally flipped */
} GL_FLIP_MODE;
/* Struct for out GL-Based Images. */
typedef struct
{
int width; /* Width of the Sprite */
int height; /* Height of the Sprite */
int textureID; /* Texture handle (used in glDeleteTextures())
The texture handle in VRAM (returned by glGenTextures())
ie. This references the actual texture stored in VRAM. */
} glImage;
extern v16 g_depth;
extern int gCurrentTexture;
/*
* Draws an Axis Exclusive Scaled Sprite
* Parameters:
* x X position of the sprite.
* y Y position of the sprite.
* scaleX 20.12 fixed-point X-Axis scale value (1 << 12 is normal).
* scaleY 20.12 fixed-point Y-Axis scale value (1 << 12 is normal).
* flipmode mode for flipping (see GL_FLIP_MODE enum).
* *spr pointer to a glImage.
*/
void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr);
/* Initializes our Tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files.
* Can only be used when tiles in a tilset are of the same dimensions.
* Parameters:
* *sprite Pointer to an array of glImage.
* tile_wid Width of each tile in the texture.
* tile_hei Height of each tile in the texture.
* bmp_wid Width of of the texture or tileset.
* bmp_hei height of of the texture or tileset.
* type The format of the texture (see glTexImage2d()).
* sizeX The horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()).
* sizeY The vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()).
* param parameters for the texture (see glTexImage2d()).
* pallette_width Length of the palette. Valid values are <b>4, 16, 32, 256</b> (if <b>0</b>, then palette is removed from currently bound texture).
* *palette Pointer to the palette data to load (if NULL, then palette is removed from currently bound texture).
* *texture Pointer to the texture data to load.
*/
int glLoadTile(glImage *sprite,
int texture_width,
int texture_height,
int sprite_width,
int sprite_height,
GL_TEXTURE_TYPE_ENUM type,
int param,
int pallette_width,
const u16 *palette,
const uint8 *texture);
/* Initializes GL in 2D mode */
void glScreen2D(void);
/*
* Sets up OpenGL for 2d rendering.
*
* Call this before drawing any of GL2D's drawing or sprite functions.
*/
void glBegin2D(void);
/*
* Issue this after drawing 2d so that we don't mess the matrix stack.
*
* The complement of glBegin2D().
*/
void glEnd2D(void);
/*
* Draws a Pixel
* x X position of the pixel.
* y Y position of the pixel.
* color RGB15/ARGB16 color.
*/
void glPutPixel(int x, int y, int color);
/*
* Draws a Line
* x1,y1 Top-Left coordinate of the line.
* x2,y2 Bottom-Right coordinate of the line.
* color RGB15/ARGB16 color.
*/
void glLine(int x1, int y1, int x2, int y2, int color);
/*
* Draws a Box
* x1,y1 Top-Left coordinate of the box.
* x2,y2 Bottom-Right coordinate of the box.
* color RGB15/ARGB16 color.
*/
void glBox(int x1, int y1, int x2, int y2, int color);
/*
* Draws a Filled Box
* x1,y1 Top-Left coordinate of the box.
* x2,y2 Bottom-Right coordinate of the box.
* color RGB15/ARGB16 color.
*/
void glBoxFilled(int x1, int y1, int x2, int y2, int color);
#endif /* SDL_VIDEO_RENDER_NDS */

View file

@ -0,0 +1,40 @@
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
SDL_PROC(void, glClear, (GLbitfield))
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
SDL_PROC(void, glDisable, (GLenum))
SDL_PROC(void, glDisableClientState, (GLenum array))
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
SDL_PROC(void, glDrawTexiOES, (GLint, GLint, GLint, GLint, GLint))
SDL_PROC(void, glEnable, (GLenum))
SDL_PROC(void, glEnableClientState, (GLenum))
SDL_PROC(void, glFinish, (void))
SDL_PROC(void, glGenFramebuffersOES, (GLsizei, GLuint *))
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
SDL_PROC(GLenum, glGetError, (void))
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
SDL_PROC(void, glLoadIdentity, (void))
SDL_PROC(void, glMatrixMode, (GLenum))
SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *))
SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat))
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *))
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *))
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
SDL_PROC(void, glBindFramebufferOES, (GLenum, GLuint))
SDL_PROC(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint))
SDL_PROC(GLenum, glCheckFramebufferStatusOES, (GLenum))
SDL_PROC(void, glPushMatrix, (void))
SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glPopMatrix, (void))
SDL_PROC(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*))
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,47 @@
SDL_PROC(void, glActiveTexture, (GLenum))
SDL_PROC(void, glAttachShader, (GLuint, GLuint))
SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
SDL_PROC(void, glClear, (GLbitfield))
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
SDL_PROC(void, glCompileShader, (GLuint))
SDL_PROC(GLuint, glCreateProgram, (void))
SDL_PROC(GLuint, glCreateShader, (GLenum))
SDL_PROC(void, glDeleteProgram, (GLuint))
SDL_PROC(void, glDeleteShader, (GLuint))
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
SDL_PROC(void, glDisable, (GLenum))
SDL_PROC(void, glDisableVertexAttribArray, (GLuint))
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
SDL_PROC(void, glEnable, (GLenum))
SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
SDL_PROC(void, glFinish, (void))
SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
SDL_PROC(const GLubyte *, glGetString, (GLenum))
SDL_PROC(GLenum, glGetError, (void))
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *))
SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *))
SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
SDL_PROC(void, glLinkProgram, (GLuint))
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const char **, const GLint *))
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
SDL_PROC(void, glUniform1i, (GLint, GLint))
SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *))
SDL_PROC(void, glUseProgram, (GLuint))
SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint))
SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))