Added an option to show the logo at the cursor position for debugging
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40934
This commit is contained in:
parent
ce19d347ff
commit
0ef2a5d6b7
1 changed files with 70 additions and 4 deletions
|
@ -23,6 +23,7 @@ static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
|
||||||
|
|
||||||
static SDL_Surface *global_image = NULL;
|
static SDL_Surface *global_image = NULL;
|
||||||
static GLuint global_texture = 0;
|
static GLuint global_texture = 0;
|
||||||
|
static GLuint cursor_texture = 0;
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
@ -237,6 +238,61 @@ GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord)
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawLogoCursor(void)
|
||||||
|
{
|
||||||
|
static GLfloat texMinX, texMinY;
|
||||||
|
static GLfloat texMaxX, texMaxY;
|
||||||
|
static int w, h;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
SDL_Surface *screen = SDL_GetVideoSurface();
|
||||||
|
|
||||||
|
if ( ! cursor_texture ) {
|
||||||
|
SDL_Surface *image;
|
||||||
|
GLfloat texcoord[4];
|
||||||
|
|
||||||
|
/* Load the image (could use SDL_image library here) */
|
||||||
|
image = SDL_LoadBMP(LOGO_FILE);
|
||||||
|
if ( image == NULL ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
w = image->w;
|
||||||
|
h = image->h;
|
||||||
|
|
||||||
|
/* Convert the image into an OpenGL texture */
|
||||||
|
cursor_texture = SDL_GL_LoadTexture(image, texcoord);
|
||||||
|
|
||||||
|
/* Make texture coordinates easy to understand */
|
||||||
|
texMinX = texcoord[0];
|
||||||
|
texMinY = texcoord[1];
|
||||||
|
texMaxX = texcoord[2];
|
||||||
|
texMaxY = texcoord[3];
|
||||||
|
|
||||||
|
/* We don't need the original image anymore */
|
||||||
|
SDL_FreeSurface(image);
|
||||||
|
|
||||||
|
/* Make sure that the texture conversion is okay */
|
||||||
|
if ( ! cursor_texture ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move the image around */
|
||||||
|
SDL_GetMouseState(&x, &y);
|
||||||
|
x -= w/2;
|
||||||
|
y -= h/2;
|
||||||
|
|
||||||
|
/* Show the image on the screen */
|
||||||
|
SDL_GL_Enter2DMode();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, cursor_texture);
|
||||||
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
glTexCoord2f(texMinX, texMinY); glVertex2i(x, y );
|
||||||
|
glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y );
|
||||||
|
glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h);
|
||||||
|
glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
|
||||||
|
glEnd();
|
||||||
|
SDL_GL_Leave2DMode();
|
||||||
|
}
|
||||||
|
|
||||||
void DrawLogoTexture(void)
|
void DrawLogoTexture(void)
|
||||||
{
|
{
|
||||||
|
@ -393,7 +449,7 @@ void DrawLogoBlit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int RunGLTest( int argc, char* argv[],
|
int RunGLTest( int argc, char* argv[],
|
||||||
int logo, int slowly, int bpp, float gamma, int noframe, int fsaa )
|
int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int rgb_size[3];
|
int rgb_size[3];
|
||||||
|
@ -652,6 +708,9 @@ int RunGLTest( int argc, char* argv[],
|
||||||
DrawLogoTexture();
|
DrawLogoTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( logocursor ) {
|
||||||
|
DrawLogoCursor();
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapBuffers( );
|
SDL_GL_SwapBuffers( );
|
||||||
|
|
||||||
|
@ -696,6 +755,10 @@ int RunGLTest( int argc, char* argv[],
|
||||||
glDeleteTextures( 1, &global_texture );
|
glDeleteTextures( 1, &global_texture );
|
||||||
global_texture = 0;
|
global_texture = 0;
|
||||||
}
|
}
|
||||||
|
if ( cursor_texture ) {
|
||||||
|
glDeleteTextures( 1, &cursor_texture );
|
||||||
|
cursor_texture = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Destroy our GL context, etc. */
|
/* Destroy our GL context, etc. */
|
||||||
SDL_Quit( );
|
SDL_Quit( );
|
||||||
|
@ -704,7 +767,7 @@ int RunGLTest( int argc, char* argv[],
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, logo;
|
int i, logo, logocursor;
|
||||||
int numtests;
|
int numtests;
|
||||||
int bpp = 0;
|
int bpp = 0;
|
||||||
int slowly;
|
int slowly;
|
||||||
|
@ -727,6 +790,9 @@ int main(int argc, char *argv[])
|
||||||
logo = 1;
|
logo = 1;
|
||||||
USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
|
USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
if ( strcmp(argv[i], "-logocursor") == 0 ) {
|
||||||
|
logocursor = 1;
|
||||||
|
}
|
||||||
if ( strcmp(argv[i], "-slow") == 0 ) {
|
if ( strcmp(argv[i], "-slow") == 0 ) {
|
||||||
slowly = 1;
|
slowly = 1;
|
||||||
}
|
}
|
||||||
|
@ -744,13 +810,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if ( strncmp(argv[i], "-h", 2) == 0 ) {
|
if ( strncmp(argv[i], "-h", 2) == 0 ) {
|
||||||
printf(
|
printf(
|
||||||
"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
|
"Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( i=0; i<numtests; ++i ) {
|
for ( i=0; i<numtests; ++i ) {
|
||||||
RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe, fsaa);
|
RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue