|
From: <edu...@us...> - 2003-11-06 18:47:32
|
Update of /cvsroot/aedgui/aedGUI/test
In directory sc8-pr-cvs1:/tmp/cvs-serv11490/test
Modified Files:
font.h gltest.cpp main.cpp main.h menutest.cpp testsprite.cpp
xmltest.cpp
Log Message:
Wow... indent sure makes a mess :)
Index: font.h
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/font.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** font.h 30 Jul 2003 13:22:58 -0000 1.1
--- font.h 6 Nov 2003 18:46:40 -0000 1.2
***************
*** 1,6594 ****
! unsigned char fontdata[]={0x0,0x1,0x0,0x0,0x0,0x11,0x1,0x0,0x0,0x4,
! 0x0,0x10,0x4f,0x53,0x2f,0x32,0xb4,0x5f,0xf4,0x63,
! 0x0,0x0,0xeb,0x70,0x0,0x0,0x0,0x56,0x50,0x43,
! 0x4c,0x54,0xd1,0x8a,0x5e,0x97,0x0,0x0,0xeb,0xc8,
! 0x0,0x0,0x0,0x36,0x63,0x6d,0x61,0x70,0xa4,0xc3,
! 0xe8,0xa0,0x0,0x0,0xb1,0x6c,0x0,0x0,0x3,0x58,
! 0x63,0x76,0x74,0x20,0xff,0xd3,0x1d,0x39,0x0,0x0,
! 0x1e,0xfc,0x0,0x0,0x1,0xfc,0x66,0x70,0x67,0x6d,
! 0xe7,0xb4,0xf1,0xc4,0x0,0x0,0x26,0x60,0x0,0x0,
! 0x0,0x8b,0x67,0x61,0x73,0x70,0x0,0x7,0x0,0x7,
[...13160 lines suppressed...]
! 0xf, 0xd, 0xd, 0x15, 0x1c, 0x11, 0xf, 0xb, 0x17, 0x12,
! 0x12, 0x17, 0x13, 0x11, 0x11, 0x1c, 0x12, 0x13, 0x13, 0x16,
! 0x1e, 0x1d, 0xe, 0x1c, 0xf, 0xf, 0x9, 0x9, 0x17, 0xe,
! 0x11, 0x11, 0x5, 0x12, 0xb, 0xb, 0x12, 0x12, 0xe, 0x9,
! 0x9, 0xf, 0x26, 0x13, 0x12, 0x13, 0x12, 0x12, 0x8, 0x8,
! 0x8, 0x8, 0x16, 0x16, 0x16, 0x15, 0x15, 0x15, 0x8, 0xe,
! 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0x10,
! 0x8, 0x12, 0xf, 0x13, 0xf, 0x9, 0x16, 0x11, 0x11, 0x11,
! 0x11, 0x12, 0x17, 0x17, 0xb, 0xb, 0xb, 0x1b, 0x1b, 0x1b,
! 0x16, 0x12, 0x8, 0x12, 0xf, 0x14, 0xf, 0x14, 0xf, 0x12,
! 0xa, 0x9, 0x12, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xb,
! 0xe, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x8,
! 0x0, 0x2, 0xff, 0xff, 0x0, 0x3, 0x0, 0x1, 0x0, 0x0,
! 0x0, 0x2, 0x0, 0x0, 0xc, 0x50, 0xa, 0xec, 0x5f, 0xf,
! 0x3c, 0xf5, 0x0, 0x1f, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0,
! 0xba, 0xb9, 0xf0, 0xb8, 0x0, 0x0, 0x0, 0x0, 0xba, 0xc2,
! 0x67, 0x91, 0xfe, 0x89, 0xfe, 0x1d, 0xa, 0x4c, 0x7, 0x6d,
! 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
! 0x0, 0x0, 0x0
! };
Index: gltest.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/gltest.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** gltest.cpp 25 Oct 2003 00:06:43 -0000 1.9
--- gltest.cpp 6 Nov 2003 18:46:40 -0000 1.10
***************
*** 1,2 ****
--- 1,3 ----
+
/*
* This Code Was Created By Jeff Molofee 2000
***************
*** 5,418 ****
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
! */
!
// Ported and rewritten for SDL by Rodrigo Hernandez (2003) for aedGUI
// This is Lesson 7 at nehe.gamedev.net, check Jeff's Site for a lot of
// GREAT tutorials on OpenGL
// You can email me about this hack at rod...@ra...
!
! #include <stdio.h>// Header File For Standard Input/Output
#include "SDL.h"
#include "SDL_opengl.h"
//#include "SDL_image.h"
#include "aedGui.h"
!
! bool keys[256]; // Array Used For The Keyboard Routine
! bool active=true; // Window Active Flag Set To true By Default
! bool fullscreen=true; // Fullscreen Flag Set To Fullscreen Mode By Default
! bool light; // Lighting ON/OFF ( NEW )
! bool lp; // L Pressed? ( NEW )
! bool fp; // F Pressed? ( NEW )
!
! GLfloat xrot; // X Rotation
! GLfloat yrot; // Y Rotation
! GLfloat xspeed; // X Rotation Speed
! GLfloat yspeed; // Y Rotation Speed
! GLfloat z=-5.0f; // Depth Into The Screen
!
! GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
! GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
! GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f };
!
! GLuint filter; // Which Filter To Use
! GLuint texture[3]; // Storage For 3 Textures
! GLuint ScreenTex; // Screen Texture
!
! void XrotationChanged(void *caller, void *data);
! void YrotationChanged(void *caller, void *data);
!
! int LoadGLTextures() // Load Bitmaps And Convert To Textures
! {
! fprintf(stdout,"LoadGLTextures()\n");
! int Status=false;
! SDL_Surface *image = SDL_LoadBMP("Crate.bmp");
! if (image == NULL)
! {
! fprintf(stderr,"Could not load texture\n");
! return Status;
! }
! int bpp;
! Uint8 savedpixel;
! Uint8 *pixel;
! int nTotalPixels = image->w*image->h;
! if (image->format->BitsPerPixel = 24)
! {
! fprintf(stdout,"Image is 24 Bit\n");
! bpp = GL_RGB;
! if(image->format->Rmask>image->format->Bmask)
! {
! pixel = (Uint8 *) image->pixels;
! fprintf(stdout,"We need a little Modification\n");
! for(int i=0;i<nTotalPixels;++i)
! {
! savedpixel = pixel[0];
! pixel[0] = pixel[2];
! pixel[2] = savedpixel;
! pixel+=3;
! }
! fprintf(stdout,"Modified\n");
! }
! }
! else if (image->format->BitsPerPixel = 32)
! {
! fprintf(stdout,"Image is 32 Bit\n");
! bpp = GL_RGBA;
! if(image->format->Rmask>image->format->Bmask)
! {
! pixel = (Uint8 *) image->pixels;
! for(int i=0;i<nTotalPixels;++i)
! {
! savedpixel = pixel[0];
! pixel[0] = pixel[2];
! pixel[2] = savedpixel;
! pixel+=4;
! }
! }
! }
! Status=true;// Set The Status To true
!
! glGenTextures(3, texture); // Create Three Textures
! // Create Nearest Filtered Texture
! glBindTexture(GL_TEXTURE_2D, texture[0]);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
! glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w,image->h, 0, bpp, GL_UNSIGNED_BYTE,image->pixels); // Create Linear Filtered Texture
! glBindTexture(GL_TEXTURE_2D, texture[1]);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
! glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w,image->h, 0, bpp, GL_UNSIGNED_BYTE,image->pixels);
!
! // Create MipMapped Texture
! glBindTexture(GL_TEXTURE_2D, texture[2]);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
! gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, bpp, GL_UNSIGNED_BYTE, image->pixels);
! SDL_FreeSurface(image);
! return Status;
! }
!
! GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
! {
! if (height==0) // Prevent A Divide By Zero By
! {
! height=1; // Making Height Equal One
! }
!
! glViewport(0,0,width,height); // Reset The Current Viewport
!
! glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
! glLoadIdentity(); // Reset The Projection Matrix
!
! // Calculate The Aspect Ratio Of The Window
! gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
!
! glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
! glLoadIdentity(); // Reset The Modelview Matrix
! }
!
! int InitGL(GLvoid)
! {
! if (!LoadGLTextures())
! {
! return false;
! }
! glEnable(GL_TEXTURE_2D);// Enable Texture Mapping
! glShadeModel(GL_SMOOTH);// Enable Smooth Shading
! glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
! glClearDepth(1.0f);// Depth Buffer Setup
! glEnable(GL_DEPTH_TEST);// Enables Depth Testing
! glDepthFunc(GL_LEQUAL);// The Type Of Depth Testing To Do
! glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// Really Nice Perspective Calculations
! glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);// Setup The Ambient Light
! glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);// Setup The Diffuse Light
! glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);// Position The Light
! glEnable(GL_LIGHT1); // Enable Light One
! glBlendFunc(GL_SRC_ALPHA,GL_ONE);
! glEnable(GL_BLEND);
! return true; // Initialization Went OK
! }
!
! int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
! {
! glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
! glLoadIdentity(); // Reset The View
! glTranslatef(0.0f,0.0f,z);
!
! glRotatef(xrot,1.0f,0.0f,0.0f);
! glRotatef(yrot,0.0f,1.0f,0.0f);
!
! glBindTexture(GL_TEXTURE_2D, texture[filter]);
!
! glBegin(GL_QUADS);
! // Front Face
! glNormal3f( 0.0f, 0.0f, 1.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
! // Back Face
! glNormal3f( 0.0f, 0.0f,-1.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
! // Top Face
! glNormal3f( 0.0f, 1.0f, 0.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
! // Bottom Face
! glNormal3f( 0.0f,-1.0f, 0.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
! // Right face
! glNormal3f( 1.0f, 0.0f, 0.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
! // Left Face
! glNormal3f(-1.0f, 0.0f, 0.0f);
! glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
! glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
! glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
! glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
! glEnd();
!
! xrot+=xspeed;
! yrot+=yspeed;
! return true; // Keep Going
! }
!
! void CreateScreenTex()
! {
! /*
! This Function creates our Screen Texture, notice that due
! to the OpenGL limitation of square textures, we have to
! make our texture 1024 x 1024, this works on my video card,
! an nVidia Geforce2, not sure if it will work on others
! */
! int TexSize = 1024 * 1024 * 4;
! unsigned int *pTexture = new unsigned int [TexSize];
! memset(pTexture, 0, TexSize * sizeof(unsigned int));
! glGenTextures(1, &ScreenTex);
! glBindTexture(GL_TEXTURE_2D, ScreenTex);
! glTexImage2D(GL_TEXTURE_2D, 0, 4,800,600, 0,GL_RGBA, GL_UNSIGNED_BYTE,pTexture);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
! delete[]pTexture;
! };
!
! void DrawGUI(SDL_Surface *surface)
! {
! /*
! This Function Draws our aedGUI surface to the screen
! */
! glMatrixMode(GL_PROJECTION);
! glPushMatrix();
! glLoadIdentity();
! glOrtho( 0,800,0,600, 0, 1 );
! glMatrixMode(GL_MODELVIEW);
! glLoadIdentity();
! glBindTexture(GL_TEXTURE_2D, ScreenTex);
! glTexImage2D(GL_TEXTURE_2D, 0, 4,surface->w,surface->h, 0,GL_RGBA, GL_UNSIGNED_BYTE,surface->pixels);
! //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, surface->w,surface->h,GL_RGBA, GL_UNSIGNED_BYTE,surface->pixels);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
! glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
!
! glBegin(GL_QUADS);
! glTexCoord2f(0.0f, 1.0f); glVertex2f(0,-424);
! glTexCoord2f(0.0f, 0.0f); glVertex2f(0,600);
! glTexCoord2f(1.0f, 0.0f); glVertex2f(1024,600);
! glTexCoord2f(1.0f, 1.0f); glVertex2f(1024,-424);
! glEnd();
!
! glMatrixMode( GL_PROJECTION );
! glPopMatrix();
! glMatrixMode( GL_MODELVIEW );
! }
!
! int main(int argc, char *argv[])
! {
! aedApp app;
! app.setDefaultFontName("Vera.ttf");
! SDL_Surface *surface=NULL;
! if(SDL_Init(SDL_INIT_VIDEO)<0)
! {
! /* Failed, exit. */
! fprintf( stderr, "Video initialization failed: %s\n",SDL_GetError());
! }
! SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
! SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
! SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
! SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
! //SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 16);
! SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER,1);
! if( SDL_SetVideoMode(800,600,0,SDL_OPENGL) == 0 )
! {
! fprintf( stderr, "Video mode set failed: %s\n",SDL_GetError());
! SDL_Quit();
! return -1;
! }
!
! SDL_WM_SetCaption("NeHe's Lesson 7 Port for aedGUI by Rodrigo Hernandez", "");
!
! /*
! The Following code creates a Surface to be used as the rendering surface
! for aedGUI.
! */
! Uint32 rmask, gmask, bmask, amask;
!
! /*
! SDL interprets each pixel as a 32-bit number, so our masks must depend
! on the endianness (byte order) of the machine
! */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
! rmask = 0xff000000;
! gmask = 0x00ff0000;
! bmask = 0x0000ff00;
! amask = 0x000000ff;
! #else
! rmask = 0x000000ff;
! gmask = 0x0000ff00;
! bmask = 0x00ff0000;
! amask = 0xff000000;
! #endif
!
! surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 1024, 32,
! rmask, gmask, bmask, amask);
! if(surface == NULL)
! {
! fprintf(stderr, "CreateRGBSurface failed: %s\n", SDL_GetError());
! }
! Uint8 *pixel = (Uint8 *) surface->pixels;
! for(int i=0;i<surface->w*surface->h;++i)
! {
! pixel[0] = 0;
! pixel[1] = 0;
! pixel[2] = 0;
! pixel[3] = 255;
! pixel+=4;
! }
!
! /*
! Now we Initialize aedGUI
! */
!
! aedWidget desktop(800,600, false);
!
! desktop.setBGColor(aedColor(0,0,0,0));
! aedSpinner spnrX;
! aedSpinner spnrY;
! aedStaticText txtXLabel;
! aedStaticText txtYLabel;
! aedStaticText txtAbout;
! spnrX.create(&desktop, aedRect(100, 10, 70, 25));
! spnrY.create(&desktop, aedRect(100, 45, 70, 25));
!
! spnrX.connect(VALUE_CHANGED, aedCallBack(XrotationChanged));
! spnrY.connect(VALUE_CHANGED, aedCallBack(YrotationChanged));
!
! txtYLabel.create(&desktop, aedRect(10,10,90,25), "X Rotation:");
! txtYLabel.setBorder(false);
! txtYLabel.setJustification(AED_JUST_LEFT);
! txtYLabel.setFontSize(12);
! txtYLabel.setTextColor(aedColor(255,255,255,255));
! txtYLabel.setBGColor(aedColor(0,0,0,0));
!
! txtXLabel.create(&desktop, aedRect(10,45,90,25), "Y Rotation:");
! txtXLabel.setBorder(false);
! txtXLabel.setJustification(AED_JUST_LEFT);
! txtXLabel.setFontSize(12);
! txtXLabel.setTextColor(aedColor(255,255,255,255));
! txtXLabel.setBGColor(aedColor(0,0,0,0));
!
! txtAbout.create(&desktop, aedRect(5,575,790,25), "This is a sample program to demonstrate that you CAN mix aedGUI and OpenGL");
! txtAbout.setBorder(false);
! txtAbout.setJustification(AED_JUST_LEFT);
! txtAbout.setFontSize(12);
! txtAbout.setTextColor(aedColor(255,255,255,255));
! txtAbout.setBGColor(aedColor(0,0,0,0));
! aedCursor Cursor;
! SDL_Surface *imgCursor = SDL_LoadBMP("./cursor.bmp");
! SDL_SetColorKey(imgCursor, SDL_SRCCOLORKEY | SDL_RLEACCEL,
! SDL_MapRGB(imgCursor->format, 255, 0, 255));
! Cursor.setImage(imgCursor);
! SDL_ShowCursor(0);
!
! ReSizeGLScene(800,600);
! if(!InitGL())
! {
! fprintf( stderr, "OpenGL Init Failed\n");
! SDL_Quit();
! return -1;
! }
! CreateScreenTex();
! bool bRunning = true;
! SDL_Event event;
! while(bRunning)
! {
! while(desktop.pollEvent(&event))
! {
! switch(event.type)
! {
! case SDL_QUIT:
! bRunning = false;
! break;
! }
! }
! desktop.update();
! desktop.renderAll(surface);
! Cursor.render(surface);
! DrawGLScene();
! DrawGUI(surface);
! SDL_GL_SwapBuffers();
! }
! SDL_Quit();
! }
!
! void XrotationChanged(void *caller, void *data)
! {
! aedSpinner *Spinner = (aedSpinner *) caller;
! xrot = Spinner->getValue();
! if (xrot == 360)
! {
! xrot = 0;
! Spinner->setValue(0);
! }
! }
!
! void YrotationChanged(void *caller, void *data)
! {
! aedSpinner *Spinner = (aedSpinner *) caller;
! yrot = Spinner->getValue();
! if (yrot == 360)
! {
! yrot = 0;
! Spinner->setValue(0);
! }
! }
!
--- 6,475 ----
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
! */
!
// Ported and rewritten for SDL by Rodrigo Hernandez (2003) for aedGUI
// This is Lesson 7 at nehe.gamedev.net, check Jeff's Site for a lot of
// GREAT tutorials on OpenGL
// You can email me about this hack at rod...@ra...
!
! #include <stdio.h> // Header File For Standard Input/Output
#include "SDL.h"
#include "SDL_opengl.h"
//#include "SDL_image.h"
#include "aedGui.h"
!
bool keys[256]; // Array Used For The Keyboard Routine
! bool active = true; // Window Active Flag Set To true By Default
! bool fullscreen = true; // Fullscreen Flag Set To Fullscreen Mode By Default
! bool light; // Lighting ON/OFF ( NEW )
! bool lp; // L Pressed? ( NEW )
! bool fp; // F Pressed? ( NEW )
!
!
GLfloat xrot; // X Rotation
! GLfloat yrot; // Y Rotation
! GLfloat xspeed; // X Rotation Speed
! GLfloat yspeed; // Y Rotation Speed
! GLfloat z = -5.0f; // Depth Into The Screen
!
!
GLfloat LightAmbient[] =
! {
! 0.5f, 0.5f, 0.5f, 1.0f};
!
!
GLfloat LightDiffuse[] =
! {
! 1.0f, 1.0f, 1.0f, 1.0f};
!
!
GLfloat LightPosition[] =
! {
! 0.0f, 0.0f, 2.0f, 1.0f};
!
!
GLuint filter; // Which Filter To Use
! GLuint texture[3]; // Storage For 3 Textures
! GLuint ScreenTex; // Screen Texture
!
void XrotationChanged(void *caller, void *data);
!
void YrotationChanged(void *caller, void *data);
!
int
! LoadGLTextures() // Load Bitmaps And Convert To Textures
! {
!
fprintf(stdout, "LoadGLTextures()\n");
!
int Status = false;
!
!
SDL_Surface * image = SDL_LoadBMP("Crate.bmp");
!
if(image == NULL)
!
! {
!
fprintf(stderr, "Could not load texture\n");
!
return Status;
!
}
!
int bpp;
!
!
Uint8 savedpixel;
!
Uint8 * pixel;
!
int nTotalPixels = image->w * image->h;
!
!
if(image->format->BitsPerPixel = 24)
!
! {
!
fprintf(stdout, "Image is 24 Bit\n");
!
bpp = GL_RGB;
!
if(image->format->Rmask > image->format->Bmask)
!
! {
!
pixel = (Uint8 *) image->pixels;
!
fprintf(stdout, "We need a little Modification\n");
!
for(int i = 0; i < nTotalPixels; ++i)
!
! {
!
savedpixel = pixel[0];
!
pixel[0] = pixel[2];
!
pixel[2] = savedpixel;
!
pixel += 3;
!
}
fprintf(stdout, "Modified\n");
!
}
!
}
!
! else if(image->format->BitsPerPixel = 32)
!
! {
!
fprintf(stdout, "Image is 32 Bit\n");
!
bpp = GL_RGBA;
!
if(image->format->Rmask > image->format->Bmask)
!
! {
!
pixel = (Uint8 *) image->pixels;
!
for(int i = 0; i < nTotalPixels; ++i)
!
! {
!
savedpixel = pixel[0];
!
pixel[0] = pixel[2];
!
pixel[2] = savedpixel;
!
pixel += 4;
!
}
}
!
}
!
Status = true; // Set The Status To true
!
glGenTextures(3, texture); // Create Three Textures
! // Create Nearest Filtered Texture
! glBindTexture(GL_TEXTURE_2D, texture[0]);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
!
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, bpp, GL_UNSIGNED_BYTE, image->pixels); // Create Linear Filtered Texture
! glBindTexture(GL_TEXTURE_2D, texture[1]);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
!
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, bpp,
! GL_UNSIGNED_BYTE, image->pixels);
!
! // Create MipMapped Texture
! glBindTexture(GL_TEXTURE_2D, texture[2]);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
! GL_LINEAR_MIPMAP_NEAREST);
!
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, bpp,
! GL_UNSIGNED_BYTE, image->pixels);
!
SDL_FreeSurface(image);
!
return Status;
!
}
!
!
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
! {
!
if(height == 0) // Prevent A Divide By Zero By
! {
!
height = 1; // Making Height Equal One
! }
!
glViewport(0, 0, width, height); // Reset The Current Viewport
!
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
! glLoadIdentity(); // Reset The Projection Matrix
!
! // Calculate The Aspect Ratio Of The Window
! gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);
!
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
! glLoadIdentity(); // Reset The Modelview Matrix
! }
!
int
! InitGL(GLvoid)
! {
!
if(!LoadGLTextures())
!
! {
!
return false;
!
}
!
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
! glShadeModel(GL_SMOOTH); // Enable Smooth Shading
! glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
! glClearDepth(1.0f); // Depth Buffer Setup
! glEnable(GL_DEPTH_TEST); // Enables Depth Testing
! glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
! glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
! glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
! glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
! glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Position The Light
! glEnable(GL_LIGHT1); // Enable Light One
! glBlendFunc(GL_SRC_ALPHA, GL_ONE);
!
glEnable(GL_BLEND);
!
return true; // Initialization Went OK
! }
!
int
! DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
! {
!
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
! glLoadIdentity(); // Reset The View
! glTranslatef(0.0f, 0.0f, z);
!
glRotatef(xrot, 1.0f, 0.0f, 0.0f);
!
glRotatef(yrot, 0.0f, 1.0f, 0.0f);
!
glBindTexture(GL_TEXTURE_2D, texture[filter]);
!
glBegin(GL_QUADS);
!
! // Front Face
! glNormal3f(0.0f, 0.0f, 1.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(-1.0f, -1.0f, 1.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(1.0f, -1.0f, 1.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(1.0f, 1.0f, 1.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(-1.0f, 1.0f, 1.0f);
!
! // Back Face
! glNormal3f(0.0f, 0.0f, -1.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(-1.0f, -1.0f, -1.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(-1.0f, 1.0f, -1.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(1.0f, 1.0f, -1.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(1.0f, -1.0f, -1.0f);
!
! // Top Face
! glNormal3f(0.0f, 1.0f, 0.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(-1.0f, 1.0f, -1.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(-1.0f, 1.0f, 1.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(1.0f, 1.0f, 1.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(1.0f, 1.0f, -1.0f);
!
! // Bottom Face
! glNormal3f(0.0f, -1.0f, 0.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(-1.0f, -1.0f, -1.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(1.0f, -1.0f, -1.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(1.0f, -1.0f, 1.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(-1.0f, -1.0f, 1.0f);
!
! // Right face
! glNormal3f(1.0f, 0.0f, 0.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(1.0f, -1.0f, -1.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(1.0f, 1.0f, -1.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(1.0f, 1.0f, 1.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(1.0f, -1.0f, 1.0f);
!
! // Left Face
! glNormal3f(-1.0f, 0.0f, 0.0f);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex3f(-1.0f, -1.0f, -1.0f);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex3f(-1.0f, -1.0f, 1.0f);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex3f(-1.0f, 1.0f, 1.0f);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex3f(-1.0f, 1.0f, -1.0f);
!
glEnd();
!
xrot += xspeed;
!
yrot += yspeed;
!
return true; // Keep Going
! }
!
void
! CreateScreenTex()
! {
!
! /*
! This Function creates our Screen Texture, notice that due
! to the OpenGL limitation of square textures, we have to
! make our texture 1024 x 1024, this works on my video card,
! an nVidia Geforce2, not sure if it will work on others
! */
! int TexSize = 1024 * 1024 * 4;
!
unsigned int *pTexture = new unsigned int[TexSize];
!
memset(pTexture, 0, TexSize * sizeof(unsigned int));
!
glGenTextures(1, &ScreenTex);
!
glBindTexture(GL_TEXTURE_2D, ScreenTex);
!
glTexImage2D(GL_TEXTURE_2D, 0, 4, 800, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE,
! pTexture);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
!
delete[]pTexture;
!
};
!
void
! DrawGUI(SDL_Surface * surface)
! {
!
! /*
! This Function Draws our aedGUI surface to the screen
! */
! glMatrixMode(GL_PROJECTION);
!
glPushMatrix();
!
glLoadIdentity();
!
glOrtho(0, 800, 0, 600, 0, 1);
!
glMatrixMode(GL_MODELVIEW);
!
glLoadIdentity();
!
glBindTexture(GL_TEXTURE_2D, ScreenTex);
!
glTexImage2D(GL_TEXTURE_2D, 0, 4, surface->w, surface->h, 0, GL_RGBA,
! GL_UNSIGNED_BYTE, surface->pixels);
!
! //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, surface->w,surface->h,GL_RGBA, GL_UNSIGNED_BYTE,surface->pixels);
! glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
!
glBegin(GL_QUADS);
!
glTexCoord2f(0.0f, 1.0f);
! glVertex2f(0, -424);
!
glTexCoord2f(0.0f, 0.0f);
! glVertex2f(0, 600);
!
glTexCoord2f(1.0f, 0.0f);
! glVertex2f(1024, 600);
!
glTexCoord2f(1.0f, 1.0f);
! glVertex2f(1024, -424);
!
glEnd();
!
glMatrixMode(GL_PROJECTION);
!
glPopMatrix();
!
glMatrixMode(GL_MODELVIEW);
!
}
int
! main(int argc, char *argv[])
! {
!
aedApp app;
!
app.setDefaultFontName("Vera.ttf");
!
SDL_Surface * surface = NULL;
!
if(SDL_Init(SDL_INIT_VIDEO) < 0)
!
! {
!
! /* Failed, exit. */
! fprintf(stderr, "Video initialization failed: %s\n",
! SDL_GetError());
!
}
!
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
!
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
!
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
!
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
!
! //SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 16);
! SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
!
if(SDL_SetVideoMode(800, 600, 0, SDL_OPENGL) == 0)
!
! {
!
fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError());
!
SDL_Quit();
!
return -1;
!
}
!
SDL_WM_SetCaption("NeHe's Lesson 7 Port for aedGUI by Rodrigo Hernandez",
! "");
!
! /*
! The Following code creates a Surface to be used as the rendering surface
! for aedGUI.
! */
! Uint32 rmask, gmask, bmask, amask;
!
! /*
! SDL interprets each pixel as a 32-bit number, so our masks must depend
! on the endianness (byte order) of the machine
! */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
! rmask = 0xff000000;
!
gmask = 0x00ff0000;
!
bmask = 0x0000ff00;
!
amask = 0x000000ff;
!
! #else /*
*/
! rmask = 0x000000ff;
!
gmask = 0x0000ff00;
!
bmask = 0x00ff0000;
!
amask = 0xff000000;
!
! #endif /*
*/
!
surface =
! SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 1024, 32,
rmask, gmask,
! bmask, amask);
!
if(surface == NULL)
!
! {
!
fprintf(stderr, "CreateRGBSurface failed: %s\n", SDL_GetError());
!
}
!
Uint8 * pixel = (Uint8 *) surface->pixels;
!
for(int i = 0; i < surface->w * surface->h; ++i)
!
! {
!
pixel[0] = 0;
!
pixel[1] = 0;
!
pixel[2] = 0;
!
pixel[3] = 255;
!
pixel += 4;
!
}
! /*
! Now we Initialize aedGUI
! */
!
aedWidget desktop(800, 600, false);
!
desktop.setBGColor(aedColor(0, 0, 0, 0));
!
aedSpinner spnrX;
!
aedSpinner spnrY;
!
aedStaticText txtXLabel;
!
aedStaticText txtYLabel;
!
aedStaticText txtAbout;
!
spnrX.create(&desktop, aedRect(100, 10, 70, 25));
!
spnrY.create(&desktop, aedRect(100, 45, 70, 25));
!
spnrX.connect(VALUE_CHANGED, aedCallBack(XrotationChanged));
!
spnrY.connect(VALUE_CHANGED, aedCallBack(YrotationChanged));
!
txtYLabel.create(&desktop, aedRect(10, 10, 90, 25), "X Rotation:");
!
txtYLabel.setBorder(false);
!
txtYLabel.setJustification(AED_JUST_LEFT);
!
txtYLabel.setFontSize(12);
!
txtYLabel.setTextColor(aedColor(255, 255, 255, 255));
!
txtYLabel.setBGColor(aedColor(0, 0, 0, 0));
!
txtXLabel.create(&desktop, aedRect(10, 45, 90, 25), "Y Rotation:");
!
txtXLabel.setBorder(false);
!
txtXLabel.setJustification(AED_JUST_LEFT);
!
txtXLabel.setFontSize(12);
!
txtXLabel.setTextColor(aedColor(255, 255, 255, 255));
!
txtXLabel.setBGColor(aedColor(0, 0, 0, 0));
!
txtAbout.create(&desktop, aedRect(5, 575, 790, 25),
! "This is a sample program to demonstrate that you CAN mix aedGUI and OpenGL");
!
txtAbout.setBorder(false);
!
txtAbout.setJustification(AED_JUST_LEFT);
!
txtAbout.setFontSize(12);
!
txtAbout.setTextColor(aedColor(255, 255, 255, 255));
!
txtAbout.setBGColor(aedColor(0, 0, 0, 0));
!
aedCursor Cursor;
!
SDL_Surface * imgCursor = SDL_LoadBMP("./cursor.bmp");
!
SDL_SetColorKey(imgCursor, SDL_SRCCOLORKEY | SDL_RLEACCEL,
!
SDL_MapRGB(imgCursor->format, 255, 0, 255));
!
Cursor.setImage(imgCursor);
!
SDL_ShowCursor(0);
!
ReSizeGLScene(800, 600);
!
if(!InitGL())
!
! {
!
fprintf(stderr, "OpenGL Init Failed\n");
!
SDL_Quit();
!
return -1;
!
}
!
CreateScreenTex();
!
bool bRunning = true;
!
SDL_Event event;
!
while(bRunning)
!
! {
!
while(desktop.pollEvent(&event))
!
! {
!
switch (event.type)
!
! {
!
case SDL_QUIT:
!
bRunning = false;
!
break;
!
}
!
}
!
desktop.update();
!
desktop.renderAll(surface);
!
Cursor.render(surface);
!
DrawGLScene();
!
DrawGUI(surface);
!
SDL_GL_SwapBuffers();
!
}
!
SDL_Quit();
!
}
!
void
! XrotationChanged(void *caller, void *data)
! {
!
aedSpinner * Spinner = (aedSpinner *) caller;
!
xrot = Spinner->getValue();
!
if(xrot == 360)
!
! {
!
xrot = 0;
!
Spinner->setValue(0);
!
}
!
}
!
void
! YrotationChanged(void *caller, void *data)
! {
!
aedSpinner * Spinner = (aedSpinner *) caller;
!
yrot = Spinner->getValue();
!
if(yrot == 360)
!
! {
!
yrot = 0;
!
Spinner->setValue(0);
!
}
!
}
!
!
Index: main.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/main.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** main.cpp 26 Oct 2003 08:50:59 -0000 1.49
--- main.cpp 6 Nov 2003 18:46:40 -0000 1.50
***************
*** 26,35 ****
aedApp app;
!
app.addMemoryFont("my_font", fontdata, sizeof(fontdata));
app.setDefaultFontName("my_font");
! // aedTheme *t = app.loadTheme("../themes/industrial");
aedWidget desktop(640, 480, false);
// desktop.setTheme(t);
--- 26,36 ----
aedApp app;
!
app.addMemoryFont("my_font", fontdata, sizeof(fontdata));
app.setDefaultFontName("my_font");
! // aedTheme *t = app.loadTheme("../themes/industrial");
aedWidget desktop(640, 480, false);
+
// desktop.setTheme(t);
***************
*** 71,76 ****
st10.create(&desktop, aedRect(400, 10, 150, 25), "<-- justification: left");
! st11.create(&desktop, aedRect(400, 40, 150, 25), "<-- justification: center");
! st12.create(&desktop, aedRect(400, 70, 150, 25), "<-- justification: right");
aedFrame frame1;
--- 72,79 ----
st10.create(&desktop, aedRect(400, 10, 150, 25), "<-- justification: left");
! st11.create(&desktop, aedRect(400, 40, 150, 25),
! "<-- justification: center");
! st12.create(&desktop, aedRect(400, 70, 150, 25),
! "<-- justification: right");
aedFrame frame1;
***************
*** 130,134 ****
toggleButton.create(&desktop, aedRect(200, 330, 80, 30), "Start");
! toggleButton.setToggleMode(true);
//toggleButton.setAlphaValue(128);
toggleButton.connect(STATE_CHANGED,
--- 133,137 ----
toggleButton.create(&desktop, aedRect(200, 330, 80, 30), "Start");
! toggleButton.setToggleMode(true);
//toggleButton.setAlphaValue(128);
toggleButton.connect(STATE_CHANGED,
***************
*** 137,152 ****
//toggleButton.disconnect(STATE_CHANGED);
! aedFrame frame2;
frame2.create(&desktop, aedRect(350, 115, 250, 225), "Some eye-candy!");
! aedBoxSizer boxSizer(&frame2, aedVERTICAL);
aedButton tb1;
tb1.create(&frame2, aedRect(55, 10, 140, 34), "parent is frame2");
tb1.setAlphaValue(160);
tb2 = new aedButton;
! tb2->create(&frame2, aedRect(25, 50, 140, 34),
! "parent is staticImage");
tb2->setAlphaValue(160);
--- 140,156 ----
//toggleButton.disconnect(STATE_CHANGED);
! aedFrame frame2;
!
frame2.create(&desktop, aedRect(350, 115, 250, 225), "Some eye-candy!");
! aedBoxSizer boxSizer(&frame2, aedVERTICAL);
aedButton tb1;
+
tb1.create(&frame2, aedRect(55, 10, 140, 34), "parent is frame2");
tb1.setAlphaValue(160);
tb2 = new aedButton;
! tb2->create(&frame2, aedRect(25, 50, 140, 34), "parent is staticImage");
tb2->setAlphaValue(160);
***************
*** 156,209 ****
/*
! aedFrame frame2;
! frame2.create(&desktop, aedRect(350, 115, 250, 225), "Some eye-candy!");
! SDL_Surface *myImage = SDL_LoadBMP("./test.bmp");
! SDL_SetColorKey(myImage, SDL_SRCCOLORKEY | SDL_RLEACCEL,
! SDL_MapRGB(myImage->format, 255, 255, 255));
! aedStaticImage staticImage;
! staticImage.create(&frame2, aedRect(50, 0, 64, 64));
! staticImage.setImage(aedImage(myImage));
! aedButton tb1;
! tb1.create(&frame2, aedRect(55, 10, 140, 34), "parent is frame2");
! tb1.setAlphaValue(160);
! tb2 = new aedButton;
! tb2->create(&staticImage, aedRect(25, 50, 140, 34),
! "parent is staticImage");
! tb2->setAlphaValue(160);
! staticTxt2 = new aedStaticText;
! staticTxt2->create(&frame2, aedRect(55, 140, 190, 18),
! "Slider value: 11 (alpha = 160)");
! staticTxt2->setBorder(false);
! aedSlider slider1(AED_HORIZONTAL);
! slider1.create(&frame2, aedRect(50, 100, 145, 14));
! slider1.connect(VALUE_CHANGED, aedCallBack(slider_change));
! slider1.setRange(0, 17);
! slider1.setValue(11);
! aedSlider slider2(AED_VERTICAL);
! slider2.create(&frame2, aedRect(4, 75, 14, 125));
! aedScrollBar scroll1(AED_HORIZONTAL);
! scroll1.create(&frame2, aedRect(24, 186, 105, 14));
! aedScrollBar scroll2(AED_VERTICAL);
! scroll2.create(&frame2, aedRect(24, 75, 14, 105));
! */
aedStaticText staticText1;
--- 160,213 ----
/*
! aedFrame frame2;
! frame2.create(&desktop, aedRect(350, 115, 250, 225), "Some eye-candy!");
! SDL_Surface *myImage = SDL_LoadBMP("./test.bmp");
! SDL_SetColorKey(myImage, SDL_SRCCOLORKEY | SDL_RLEACCEL,
! SDL_MapRGB(myImage->format, 255, 255, 255));
! aedStaticImage staticImage;
! staticImage.create(&frame2, aedRect(50, 0, 64, 64));
! staticImage.setImage(aedImage(myImage));
! aedButton tb1;
! tb1.create(&frame2, aedRect(55, 10, 140, 34), "parent is frame2");
! tb1.setAlphaValue(160);
! tb2 = new aedButton;
! tb2->create(&staticImage, aedRect(25, 50, 140, 34),
! "parent is staticImage");
! tb2->setAlphaValue(160);
! staticTxt2 = new aedStaticText;
! staticTxt2->create(&frame2, aedRect(55, 140, 190, 18),
! "Slider value: 11 (alpha = 160)");
! staticTxt2->setBorder(false);
! aedSlider slider1(AED_HORIZONTAL);
! slider1.create(&frame2, aedRect(50, 100, 145, 14));
! slider1.connect(VALUE_CHANGED, aedCallBack(slider_change));
! slider1.setRange(0, 17);
! slider1.setValue(11);
! aedSlider slider2(AED_VERTICAL);
! slider2.create(&frame2, aedRect(4, 75, 14, 125));
! aedScrollBar scroll1(AED_HORIZONTAL);
! scroll1.create(&frame2, aedRect(24, 186, 105, 14));
! aedScrollBar scroll2(AED_VERTICAL);
! scroll2.create(&frame2, aedRect(24, 75, 14, 105));
! */
aedStaticText staticText1;
***************
*** 231,263 ****
aedSpinner s1;
s1.create(&desktop, aedRect(240, 400, 70, 25));
! aedCursor Cursor;
! SDL_Surface *imgCursor = SDL_LoadBMP("./cursor.bmp");
! SDL_SetColorKey(imgCursor, SDL_SRCCOLORKEY | SDL_RLEACCEL,
SDL_MapRGB(imgCursor->format, 255, 0, 255));
! Cursor.setImage(imgCursor);
! // SDL_ShowCursor(0); //Uncomment this line when aedCursor DOES show
// loop
bool bRunning = true;
SDL_Event event;
while(bRunning)
{
! while(desktop.pollEvent(&event))
! {
! switch(event.type)
! {
! case SDL_QUIT:
! bRunning = false;
! break;
! }
! }
! desktop.update();
! boxSizer.calculateSize(); // TEST
! desktop.renderAll();
! Cursor.render();
! SDL_Delay(30);
}
--- 235,270 ----
aedSpinner s1;
+
s1.create(&desktop, aedRect(240, 400, 70, 25));
! aedCursor Cursor;
! SDL_Surface *imgCursor = SDL_LoadBMP("./cursor.bmp");
!
! SDL_SetColorKey(imgCursor, SDL_SRCCOLORKEY | SDL_RLEACCEL,
SDL_MapRGB(imgCursor->format, 255, 0, 255));
! Cursor.setImage(imgCursor);
! // SDL_ShowCursor(0); //Uncomment this line when aedCursor DOES show
// loop
bool bRunning = true;
SDL_Event event;
+
while(bRunning)
{
! while(desktop.pollEvent(&event))
! {
! switch (event.type)
! {
! case SDL_QUIT:
! bRunning = false;
! break;
! }
! }
! desktop.update();
! boxSizer.calculateSize(); // TEST
! desktop.renderAll();
! Cursor.render();
! SDL_Delay(30);
}
***************
*** 266,269 ****
--- 273,277 ----
SDL_FreeSurface(imgCursor);
delete tb2;
+
return (0);
}
***************
*** 289,292 ****
--- 297,301 ----
{
aedRadioButtonGroup *rbg = (aedRadioButtonGroup *) caller;
+
switch (rbg->getSelectedButton())
{
***************
*** 310,313 ****
--- 319,323 ----
{
aedWidget *myCaller = (aedWidget *) caller;
+
myCaller->setCaption("Clicked!");
}
***************
*** 317,320 ****
--- 327,331 ----
{
aedTextBox *myCaller = (aedTextBox *) caller;
+
myCaller->setBlinkInterval(atol(myCaller->getCaption().c_str()));
}
***************
*** 323,327 ****
progressBarTimerAlarm(void *caller, void *data, aedProgressBar * pBar)
{
! static int direction = 4;
if(pBar->getValue() >= 100)
--- 334,338 ----
progressBarTimerAlarm(void *caller, void *data, aedProgressBar * pBar)
{
! static int direction = 4;
if(pBar->getValue() >= 100)
***************
*** 329,339 ****
direction = -4;
}
! else if (pBar->getValue() <= 0)
{
! direction = 4;
}
pBar->setValue(pBar->getValue() + direction);
! pBar->setAlphaValue((255/100)*pBar->getValue());
}
--- 340,350 ----
direction = -4;
}
! else if(pBar->getValue() <= 0)
{
! direction = 4;
}
pBar->setValue(pBar->getValue() + direction);
! pBar->setAlphaValue((255 / 100) * pBar->getValue());
}
***************
*** 343,346 ****
--- 354,358 ----
{
aedButton *btn = (aedButton *) caller;
+
timer->enable(btn->getButtonState());
***************
*** 356,359 ****
--- 368,372 ----
{
aedCheckBox *chkBox = (aedCheckBox *) caller;
+
txtBox->setReadOnly(!chkBox->getState());
}
***************
*** 363,366 ****
--- 376,380 ----
{
aedCheckBox *chkBox = (aedCheckBox *) caller;
+
txtBox->setPasswordMode(chkBox->getState());
}
Index: main.h
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/main.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** main.h 1 Aug 2003 08:51:40 -0000 1.7
--- main.h 6 Nov 2003 18:46:40 -0000 1.8
***************
*** 12,20 ****
void buttonPressed(void *caller, void *data);
void changeBlinkInterval(void *caller, void *data);
! void toggleEditableState(void *caller, void *data, aedTextBox *txtBox);
! void togglePasswordMode(void *caller, void *data, aedTextBox *txtBox);
! void progressBarTimerAlarm(void *caller, void *data, aedProgressBar *pBar);
! void startProgressBarTimer(void *caller, void *data, aedTimer *timer);
! void rbgChanged(void *caller, void *data, aedTextBox *txtBox);
void slider_change(void *caller, void *data);
--- 12,20 ----
void buttonPressed(void *caller, void *data);
void changeBlinkInterval(void *caller, void *data);
! void toggleEditableState(void *caller, void *data, aedTextBox * txtBox);
! void togglePasswordMode(void *caller, void *data, aedTextBox * txtBox);
! void progressBarTimerAlarm(void *caller, void *data, aedProgressBar * pBar);
! void startProgressBarTimer(void *caller, void *data, aedTimer * timer);
! void rbgChanged(void *caller, void *data, aedTextBox * txtBox);
void slider_change(void *caller, void *data);
Index: menutest.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/menutest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** menutest.cpp 25 Oct 2003 00:06:43 -0000 1.3
--- menutest.cpp 6 Nov 2003 18:46:41 -0000 1.4
***************
*** 3,7 ****
#include "aedMenuBar.h"
! int main(int argc, char *argv[])
{
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
--- 3,8 ----
#include "aedMenuBar.h"
! int
! main(int argc, char *argv[])
{
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
Index: testsprite.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/testsprite.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** testsprite.cpp 26 Oct 2003 08:50:59 -0000 1.14
--- testsprite.cpp 6 Nov 2003 18:46:41 -0000 1.15
***************
*** 90,98 ****
aedApp app;
app.setDefaultFontName("Vera.ttf");
aedWidget win(640, 480, true);
!
! pDemo = new class SpriteDemo;
win.setBGColor(aedColor(238, 238, 230, 255));
--- 90,99 ----
aedApp app;
+
app.setDefaultFontName("Vera.ttf");
aedWidget win(640, 480, true);
!
! pDemo = new class SpriteDemo;
win.setBGColor(aedColor(238, 238, 230, 255));
***************
*** 116,132 ****
//bool bRunning = true;
SDL_Event event;
while(!pDemo->quit)
{
! while(win.pollEvent(&event)); // empty loop
! int rc = 0;
! if(!pDemo->chkBox.getState())
{
! if(pDemo->initialize)
! pDemo->InitializeSprites();
! pDemo->MoveSprites();
! pDemo->BlitSprites();
}
! win.update();
! win.renderAll();
}
pDemo->Destroy();
--- 117,135 ----
//bool bRunning = true;
SDL_Event event;
+
while(!pDemo->quit)
{
! while(win.pollEvent(&event)); // empty loop
! int rc = 0;
!
! if(!pDemo->chkBox.getState())
{
! if(pDemo->initialize)
! pDemo->InitializeSprites();
! pDemo->MoveSprites();
! pDemo->BlitSprites();
}
! win.update();
! win.renderAll();
}
pDemo->Destroy();
Index: xmltest.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/test/xmltest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** xmltest.cpp 25 Oct 2003 00:06:43 -0000 1.4
--- xmltest.cpp 6 Nov 2003 18:46:41 -0000 1.5
***************
*** 3,59 ****
#include "aedXmlFile.h"
#include "font.h"
- int main(int argc, char *argv[])
- {
- if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
- {
- std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << std::endl;
- return (1);
- }
- atexit(SDL_Quit);
-
- if(SDL_SetVideoMode(640, 480, 16, SDL_RESIZABLE) == NULL)
- {
- std::cerr << "Couldn't set video mode:" << SDL_GetError() << std::endl;
- return (1);
- }
-
- SDL_WM_SetCaption("aedXmlGUI Test", "");
-
- aedApp app;
-
- app.addMemoryFont("my_font", fontdata, sizeof(fontdata));
- app.setDefaultFontName("my_font");
-
- aedWidget desktop(640, 480, false);
- desktop.setBGColor(aedColor(100, 100, 100, 255));
-
- aedXmlFile xml;
- if (xml.loadFromFile("test1.xml", &desktop) == false)
- {
- // error, file did not load
- }
-
- // loop
- bool bRunning = true;
- SDL_Event event;
-
- while(bRunning)
- {
- while(desktop.pollEvent(&event))
- {
- switch (event.type)
- {
- case SDL_QUIT:
- bRunning = false;
- break;
- }
- }
-
- desktop.update();
- desktop.renderAll();
- SDL_Delay(30);
- }
-
- return 0;
- }
--- 3,60 ----
#include "aedXmlFile.h"
#include "font.h"
+
int
+ main(int argc, char *argv[])
+ {
+
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
+
+ {
+
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << std::
+ endl;
+
return (1);
+
}
+
atexit(SDL_Quit);
+
if(SDL_SetVideoMode(640, 480, 16, SDL_RESIZABLE) == NULL)
+
+ {
+
std::cerr << "Couldn't set video mode:" << SDL_GetError() << std::endl;
+
return (1);
+
}
+
SDL_WM_SetCaption("aedXmlGUI Test", "");
+
aedApp app;
+
app.addMemoryFont("my_font", fontdata, sizeof(fontdata));
+
app.setDefaultFontName("my_font");
+
aedWidget desktop(640, 480, false);
+
desktop.setBGColor(aedColor(100, 100, 100, 255));
+
aedXmlFile xml;
+
if(xml.loadFromFile("test1.xml", &desktop) == false)
+
+ {
+
+ // error, file did not load
+ }
+
+ // loop
+ bool bRunning = true;
+
SDL_Event event;
+
while(bRunning)
+
+ {
+
while(desktop.pollEvent(&event))
+
+ {
+
switch (event.type)
+
+ {
+
case SDL_QUIT:
+
bRunning = false;
+
break;
+
}
+
}
+
desktop.update();
+
desktop.renderAll();
+
SDL_Delay(30);
+
}
+
return 0;
+
}
+
|