#include "InterfaceManager.h" static GLint LoadTexture(int Num) { PicHandle Picture; Rect PictureSize; GWorldPtr World; PixMapHandle ThePixMap; Ptr BaseAddr; Ptr Pixels; int RowBytes; int Row; int Col; int w4; long x; char a, r, g, b; GLuint Texture; Picture = GetPicture(Num); PictureSize = (**Picture).picFrame; NewGWorld(&World, 32, &PictureSize, 0, NULL, 0); SetGWorld(World, NULL); DrawPicture(Picture, &PictureSize); ThePixMap = GetGWorldPixMap(World); BaseAddr = GetPixBaseAddr(ThePixMap); RowBytes = (**ThePixMap).rowBytes & 0x3FFF; w4 = PictureSize.right * 4; x = PictureSize.right * PictureSize.bottom * 4; Pixels = NewPtrClear(x); for(Row = 0; Row < PictureSize.bottom - 1; Row++) for(Col = 0; Col < PictureSize.right - 1; Col++) { /* Get the pixels in ARGB */ //BlockMove(BaseAddr + (Row * RowBytes) + 0 + (Col * 4), &a, 1); BlockMove(BaseAddr + (Row * RowBytes) + 1 + (Col * 4), &r, 1); BlockMove(BaseAddr + (Row * RowBytes) + 2 + (Col * 4), &g, 1); BlockMove(BaseAddr + (Row * RowBytes) + 3 + (Col * 4), &b, 1); a = 255; /* Store them in RGBA */ BlockMove(&r, Pixels + (Row * w4) + 0 + (Col * 4), 1); BlockMove(&g, Pixels + (Row * w4) + 1 + (Col * 4), 1); BlockMove(&b, Pixels + (Row * w4) + 2 + (Col * 4), 1); BlockMove(&a, Pixels + (Row * w4) + 3 + (Col * 4), 1); } glGenTextures(1, &Texture); glBindTexture(GL_TEXTURE_2D, Texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, PictureSize.right, PictureSize.bottom, GL_RGBA, GL_UNSIGNED_BYTE, Pixels); DisposePtr(Pixels); DisposeGWorld(World); return Texture; } void InitInterface(VInterface * i, VWindow * w) { i->w = w; i->SplashTexture = LoadTexture(128); i->SplashDisp = glGenLists(1); i->SplashAlpha = 0; i->SplashUp = true; i->TitleAlpha = 0; i->TitleMovement = 0; i->Title = "VECTORIZED"; i->TitleDone = false; i->TitleOver.Play = false; i->TitleOver.Prefs = false; i->TitleOver.Quit = false; glNewList(i->SplashDisp, GL_COMPILE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, i->SplashTexture); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_QUADS); glTexCoord3i(0, 0, 0); glVertex2i(0, 512); glTexCoord3i(1, 0, 0); glVertex2i(512, 512); glTexCoord3i(1, 1, 0); glVertex2i(512, 0); glTexCoord3i(0, 1, 0); glVertex2i(0, 0); glEnd(); glDisable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEndList(); } void DrawInterface(VInterface * i) { Rect TheSize; TheSize = WindowSize(i->w); OffsetRect(&TheSize, -TheSize.left, -TheSize.top); if(i->SplashAlpha) { glColor4f(1, 1, 1, i->SplashAlpha); glPushMatrix(); glTranslatef((TheSize.right/2) - 256, TheSize.bottom/2 - 256, 0); glCallList(i->SplashDisp); glPopMatrix(); } if(i->TitleAlpha) { glEnable(GL_LINE_SMOOTH); glColor4f(1, 0.25, 0, i->TitleAlpha); glPushMatrix(); glLineWidth(5); glScalef(5325, 7000, 1); glTranslatef(0.01, 0.027, 0); DrawCStringWithVectorFont(i->Title); glPopMatrix(); glPushMatrix(); glLineWidth(2); glScalef(1000, 1000, 1); if(i->TitleOver.Prefs) glColor4f(1, 0, 0, 1); else glColor4f(0, 0.8, 0, 1); glPushMatrix(); glTranslatef(-0.05 + i->TitleMovement, 0.05, 0); DrawCStringWithVectorFont("PREFS"); glPopMatrix(); if(i->TitleOver.Quit) glColor4f(1, 0, 0, 1); else glColor4f(0, 0.8, 0, 1); glPushMatrix(); glTranslatef(0.7 - i->TitleMovement, 0.01, 0); DrawCStringWithVectorFont("QUIT"); glPopMatrix(); if(i->TitleOver.Play) glColor4f(1, 0, 0, 1); else glColor4f(0, 0.8, 0, 1); glPushMatrix(); glTranslatef(0.7 - i->TitleMovement, 0.09, 0); DrawCStringWithVectorFont("PLAY"); glPopMatrix(); glLineWidth(1); glPopMatrix(); glDisable(GL_LINE_SMOOTH); } } void RunInterface(VInterface * i) { if(i->SplashUp) { i->SplashAlpha += FADESPEED1; if(i->SplashAlpha >= 1) i->SplashUp = false; } else { if(i->SplashAlpha < 0) i->SplashAlpha = 0; else i->SplashAlpha -= FADESPEED2; if(i->TitleAlpha < 1 - 0.00001) i->TitleAlpha += FADESPEED3; else if(i->TitleAlpha > 1 + 0.00001) i->TitleAlpha = 1; if(i->TitleMovement < TITLEMOVE - 0.00001) i->TitleMovement += 0.0015; else { if(i->TitleMovement != TITLEMOVE) i->TitleMovement = TITLEMOVE; if(!i->TitleDone) i->TitleDone = true; } } }