//按钮 bool CShader::AddGUIButton(int guiID,int guiControlID,int x,int y, char *fileName_Up,char *fileName_Over,char *fileName_Down) { if(guiID<0||guiID>m_iGUISystemListLength) return false; int surfaceID_Up=-1,surfaceID_Over=-1,surfaceID_Down=-1; //加载按钮纹理 AddSurface(&surfaceID_Up,fileName_Up,false); AddSurface(&surfaceID_Over,fileName_Over,false); AddSurface(&surfaceID_Down,fileName_Down,false); int w=m_surfaceList[surfaceID_Up].w; int h=m_surfaceList[surfaceID_Up].h; m_guiSystemList[guiID].AddButton(guiControlID,x,y,w,h,surfaceID_Up,surfaceID_Over,surfaceID_Down); return true; }
CBSurface* CBSurfaceStorage::AddSurface(char * Filename, bool default_ck, BYTE ck_red, BYTE ck_green, BYTE ck_blue, int LifeTime, bool KeepLoaded, bool KeepSurfaceCached) { for(int i=0; i<m_Surfaces.GetSize(); i++) { if(CBPlatform::stricmp(m_Surfaces[i]->m_Filename, Filename)==0) { m_Surfaces[i]->m_ReferenceCount++; return m_Surfaces[i]; } } CBFile* File = Game->m_FileManager->OpenFile(Filename); if(!File) { if(Filename) Game->LOG(0, "Missing image: '%s'", Filename); if(Game->m_DEBUG_DebugMode) return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); } else Game->m_FileManager->CloseFile(File); CBSurface* surface; surface = new CBSurfaceSDL(Game); if(!surface) return NULL; if(FAILED(surface->Create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded,KeepSurfaceCached))) { delete surface; return NULL; } else { surface->m_ReferenceCount = 1; m_Surfaces.Add(surface); return surface; } }
/** * @brief Create a new surface with owner this. */ Surface *GraphicsManager::CreateSurface() { #ifndef SHADER_COMPATIBLE Surface *surface = new PCSurface(this); #else Surface *surface = new PCShaderSurface(this); #endif AddSurface(surface); return surface; }
//背景 bool CShader::AddGUIBackdrop(int guiID,char *fileName) { if(guiID<0||guiID>m_iGUISystemListLength) return false; int surfaceID=-1; AddSurface(&surfaceID,fileName,false); int w=m_surfaceList[surfaceID].w; int h=m_surfaceList[surfaceID].h; m_guiSystemList[guiID].AddBackdrop(surfaceID); return true; }
int MeshComposer::Next(int index) { static Surface S; const int count = counter++; int n; switch (mode) { case GL_TRIANGLES: n = count % 3; S.points[n] = index; if (n == 2) { return AddSurface(S); } break; case GL_TRIANGLE_FAN: if (count > 2) { S.points[1] = S.points[2]; S.points[2] = index; return AddSurface(S); } else { S.points[count] = index; if (count == 2) { return AddSurface(S); } } break; case GL_TRIANGLE_STRIP: case GL_QUAD_STRIP: if (count > 2) { S.points[0] = S.points[1]; S.points[1] = S.points[2]; S.points[2] = index; return AddSurface(S); } else { S.points[count] = index; if (count == 2) { return AddSurface(S); } } break; case GL_QUADS: n = count % 4; if (n > 2) { S.points[1] = index; index = S.points[0]; S.points[0] = S.points[2]; S.points[2] = index; return AddSurface(S); } else { S.points[n] = index; if (n == 2) { return AddSurface(S); } } break; } return Knot; }