int main( int argc, char **argv ) //=================================== { char cmd[128+1]; #ifndef __WATCOMC__ _argc = argc; _argv = argv; #else argc = argc; argv = argv; #endif ProcArgs( getcmd( cmd ) ); if( Initialize() != 0 ) { return( 1 ); } printf( "Building Lists...\n" ); BuildLists(); printf( "Finding Phrases...\n" ); FindPhrases(); printf( "Sorting...\n" ); SortByRef(); printf( "ReNumbering...\n" ); ReNumber(); printf( "Dumping Msgs...\n" ); DumpMsg(); printf( "Dumping GroupTable...\n" ); DumpGroupTable(); printf( "Dumping ErrWords...\n" ); DumpErrWord(); Finalize(); return( 0 ); }
int main() { //============== char cmd[128+1]; ProcArgs( getcmd( cmd ) ); if( Initialize() != 0 ) { return( 1 ); } printf( "Building Lists...\n" ); BuildLists(); printf( "Finding Phrases...\n" ); FindPhrases(); printf( "Sorting...\n" ); SortByRef(); printf( "ReNumbering...\n" ); ReNumber(); printf( "Dumping Header...\n" ); DumpHeader(); printf( "Dumping Msgs...\n" ); DumpMsg(); printf( "Dumping GroupTable...\n" ); DumpGroupTable(); printf( "Dumping ErrWords...\n" ); DumpErrWord(); Finalize(); return( 0 ); }
bool initGL() { bool success = true; GLenum error = GL_NO_ERROR; if(!loadGLTextures()){ return false; } BuildLists(); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); //glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); //glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); //glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); //glEnable(GL_LIGHT1); // //glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glEnable(GL_BLEND); for(int i = 0; i < num; i++){ stars[i].dist = (float(i)/num)*5.0f; stars[i].r = rand()%256; stars[i].g = rand()%256; stars[i].b = rand()%256; } glPolygonMode(GL_BACK, GL_FILL); glPolygonMode(GL_FRONT, GL_LINE); for(int x=0; x < lenx; x++){ for(int y=0; y < leny; y++){ points[x][y][0] = float((x/(lenx/9.0f))-4.5f); points[x][y][1] = float((y/(leny/9.0f))-4.5f); points[x][y][2] = float(sin((((x/(lenx/9.0f))*40.0f)/360.0f)*3.14*2.0f)); } } return success; }
bool ResourceFont::Load() { if ( LoadFontFile( GetFilename().GetFullPath() ) ) { BuildLists(); m_State = ResourceState::Loaded; return true; } else { return false; } }
int Example8::InitGL(GLvoid) { if (!LoadGLTextures()) { return FALSE; } glEnable(GL_TEXTURE_2D); BuildLists(); glEnable(GL_LIGHT0); // 使用默认的0号灯 glEnable(GL_LIGHTING); // 使用灯光 glEnable(GL_COLOR_MATERIAL); // 使用颜色材质 glFrontFace(GL_CCW); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); return ExampleBase::InitGL(); }
const std::vector<std::string>& TypeRegistry::GetChain(std::string x) const { BuildLists(); std::map<std::string,std::vector<std::string> >::const_iterator iter = DeductionChains.find(x); if (iter == DeductionChains.end()) throw(" bad type "+x); for (unsigned long i=0; i < iter->second.size(); i++) { IncludeRegistry::Instance().UseArg(iter->second[i]); } return iter->second; }
int InitGL(GLvoid) { // Все настройки OpenGL начинаются здесь if (!LoadGLTextures()) { // Переход к процедуре загрузки текстуры return FALSE; // Если текстура не загружена возращает FALSE } BuildLists(); // Переход к коду, который создает наши списки отображения glEnable(GL_TEXTURE_2D); // Включение нанесения текстур glShadeModel(GL_SMOOTH); // Включение гладкой закраски (smooth shading) glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Черный фон glClearDepth(1.0f); // Установка буфера глубины glEnable(GL_DEPTH_TEST); // Включение проверки глубины glDepthFunc(GL_LEQUAL); // Тип выполняемой проверки глубины glEnable(GL_LIGHT0); // Быстрое черновое освещение (устанавливает в качестве источника освещения Light0) glEnable(GL_LIGHTING); // Включает освещение glEnable(GL_COLOR_MATERIAL); // Включает раскрашивание материала glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Изящная коррекция перспективы return TRUE; // Инициализация прошла OK }
int InitGL(GLvoid) // All Setup For OpenGL Goes Here { srand(GetTickCount()); glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glDepthFunc(GL_LESS); // The Type Of Depth Testing To Do glEnable(GL_DEPTH_TEST); // Enables Depth Testing glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, lightposition); glEnable(GL_LIGHT1); glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations glEnable(GL_COLOR_MATERIAL); BuildLists(); Build_City(); return TRUE; // Initialization Went OK }
static void Init(void) { doSphere = GL_FALSE; xRotation = 0.0; yRotation = 0.0; zTranslate = -3.125; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); if (multTex && texObj) { int i; glGenTexturesEXT(NUM_TEXTURES, texNames); for (i = 1; i < NUM_TEXTURES; i++) { glBindTextureEXT(GL_TEXTURE_2D, texNames[i]); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, images[i]->sizeX, images[i]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, images[i]->data); } glBindTextureEXT(GL_TEXTURE_2D, texNames[0]); glPrioritizeTexturesEXT(NUM_TEXTURES, texNames, texPriorities); } gluBuild2DMipmaps(GL_TEXTURE_2D, 3, images[0]->sizeX, images[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, images[0]->data); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); glEnable(GL_TEXTURE_2D); glFrontFace(GL_CCW); glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); BuildLists(); glClearColor(0.0, 0.0, 0.0, 0.0); magFilter = nr; minFilter = nr; sWrapMode = repeat; tWrapMode = repeat; }
static void Init(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, image->data); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); glEnable(GL_TEXTURE_2D); glFrontFace(GL_CCW); glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); BuildLists(); glClearColor(0.0, 0.0, 0.0, 0.0); magFilter = nr; minFilter = nr; sWrapMode = repeat; tWrapMode = repeat; }
int InitGL(GLvoid) // 此处开始对OpenGL进行所有设置 { if (!LoadGLTextures()) // 调用纹理载入子例程 { return FALSE; // 如果未能载入,返回FALSE } glEnable(GL_TEXTURE_2D); // 启用纹理映射 glShadeModel(GL_SMOOTH); // 启用阴影平滑 glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // 黑色背景 glClearDepth(1.0f); // 设置深度缓存 glEnable(GL_DEPTH_TEST); // 启用深度测试 glDepthFunc(GL_LEQUAL); // 所作深度测试的类型 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // 真正精细的透视修正 BuildLists(); // 创建显示列表 glEnable(GL_LIGHT0); // 使用默认的0号灯 glEnable(GL_LIGHTING); // 使用灯光 glEnable(GL_COLOR_MATERIAL); // 使用颜色材质 return TRUE; // 初始化 OK }
void Terrain::GenerateHeightMap(int Iterations, double Height, double HDecay) { HeightMap.calculate(Iterations, Height, HDecay); int Select = 1 + rand() % (4 - 1 + 1); // Load .3DS file into model structure if(Select == 1) { GenerateTerrainObjects(50, 2 , 40, 10); g_Load3ds.Import3DS(&g_3DModel, "Textures/Tilesets/Desert/Models/PILLAR.3DS"); double Ratio = 0.25; O1Offset = 0.0f; BuildLists(Ratio, 1, g_3DModel); for(int i = 0; i < g_3DModel.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel.pObject[i].pFaces; delete [] g_3DModel.pObject[i].pNormals; delete [] g_3DModel.pObject[i].pVerts; delete [] g_3DModel.pObject[i].pTexVerts; } g_Load3ds.Import3DS(&g_3DModel1, "Textures/Tilesets/Desert/Models/STATUE.3DS"); Ratio = 0.25; O1Offset = 0.0f; BuildLists(Ratio, 2, g_3DModel1); // Go through all the objects in the scene for(int i = 0; i < g_3DModel1.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel1.pObject[i].pFaces; delete [] g_3DModel1.pObject[i].pNormals; delete [] g_3DModel1.pObject[i].pVerts; delete [] g_3DModel1.pObject[i].pTexVerts; } } else if(Select == 2) { GenerateTerrainObjects(100, 2 , 50, 50); g_Load3ds.Import3DS(&g_3DModel, "Textures/Tilesets/Mountains/Models/PINE.3DS"); double Ratio = 0.25; O1Offset = 15.5f; BuildLists(Ratio, 1, g_3DModel); for(int i = 0; i < g_3DModel.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel.pObject[i].pFaces; delete [] g_3DModel.pObject[i].pNormals; delete [] g_3DModel.pObject[i].pVerts; delete [] g_3DModel.pObject[i].pTexVerts; } g_Load3ds.Import3DS(&g_3DModel1, "Textures/Tilesets/Mountains/Models/MAPLE.3DS"); Ratio = 5.0; O2Offset = 0.0f; BuildLists(Ratio, 2, g_3DModel1); // Go through all the objects in the scene for(int i = 0; i < g_3DModel1.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel1.pObject[i].pFaces; delete [] g_3DModel1.pObject[i].pNormals; delete [] g_3DModel1.pObject[i].pVerts; delete [] g_3DModel1.pObject[i].pTexVerts; } } else if(Select == 3) { GenerateTerrainObjects(100, 2 , 50, 50); g_Load3ds.Import3DS(&g_3DModel, "Textures/Tilesets/Tropics/Models/TREE3.3DS"); double Ratio = 0.5; O1Offset = 0.0f; BuildLists(Ratio, 1, g_3DModel); for(int i = 0; i < g_3DModel.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel.pObject[i].pFaces; delete [] g_3DModel.pObject[i].pNormals; delete [] g_3DModel.pObject[i].pVerts; delete [] g_3DModel.pObject[i].pTexVerts; } g_Load3ds.Import3DS(&g_3DModel1, "Textures/Tilesets/Tropics/Models/PALM.3DS"); Ratio = 0.75; O2Offset = 10.0f; BuildLists(Ratio, 2, g_3DModel1); // Go through all the objects in the scene for(int i = 0; i < g_3DModel1.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel1.pObject[i].pFaces; delete [] g_3DModel1.pObject[i].pNormals; delete [] g_3DModel1.pObject[i].pVerts; delete [] g_3DModel1.pObject[i].pTexVerts; } } else if(Select == 4) { GenerateTerrainObjects(100, 2 , 75, 15); g_Load3ds.Import3DS(&g_3DModel, "Textures/Tilesets/Volcanic/Models/DEADTREE.3DS"); double Ratio = 0.1; O1Offset = -1.0f; BuildLists(Ratio, 1, g_3DModel); for(int i = 0; i < g_3DModel.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel.pObject[i].pFaces; delete [] g_3DModel.pObject[i].pNormals; delete [] g_3DModel.pObject[i].pVerts; delete [] g_3DModel.pObject[i].pTexVerts; } g_Load3ds.Import3DS(&g_3DModel1, "Textures/Tilesets/Volcanic/Models/TREE1.3DS"); Ratio = 0.15; O2Offset = 2.0f; BuildLists(Ratio, 2, g_3DModel1); // Go through all the objects in the scene for(int i = 0; i < g_3DModel1.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel1.pObject[i].pFaces; delete [] g_3DModel1.pObject[i].pNormals; delete [] g_3DModel1.pObject[i].pVerts; delete [] g_3DModel1.pObject[i].pTexVerts; } } SurfaceCreator s1 = SurfaceCreator(HeightMap.Height_Map, HeightMap.getTerrainSize() - 1, static_cast<float>(Height), Select); multitextureSupported = initMultitexture(); TriangleTree.ExpandNode(TriangleTree.root); Node* Current = TriangleTree.root; //Create Triangle t1 Vector Apex = Vector(0, 0, HeightMap.Height_Map[0][0]); Vector Left = Vector(0, static_cast<float>(HeightMap.getTerrainSize() - 1), HeightMap.Height_Map[0][HeightMap.getTerrainSize() - 1]); Vector Right = Vector(static_cast<float>(HeightMap.getTerrainSize() - 1), 0,HeightMap.Height_Map[HeightMap.getTerrainSize() - 1][0] ); Triangle t = Triangle(Apex, Left, Right); for(int i = 0; i < 100; i++) { if(PointInTriangle(Vector(Forests[i].x, Forests[i].y), Apex, Left, Right)) { t.Tree.push_back(Forests[i]); } } double E = CalculateError(Left, Right); Current->LeftChild->BaseNeighbour = Current->RightChild; TriangleTree.InsertAtNode(Current->LeftChild, t, E); // Create Triangle t2 Apex.set(static_cast<float>(HeightMap.getTerrainSize() - 1) , static_cast<float>(HeightMap.getTerrainSize() - 1), HeightMap.Height_Map[HeightMap.getTerrainSize() - 1][HeightMap.getTerrainSize() - 1]); Left.set(static_cast<float>(HeightMap.getTerrainSize() - 1), 0, HeightMap.Height_Map[HeightMap.getTerrainSize() - 1][0]); Right.set(0, static_cast<float>(HeightMap.getTerrainSize() - 1), HeightMap.Height_Map[0][HeightMap.getTerrainSize() - 1]); Triangle t2 = Triangle(Apex, Left, Right); for(int i = 0; i < 100; i++) { if(PointInTriangle(Vector(Forests[i].x, Forests[i].y), Apex, Left, Right)) { t2.Tree.push_back(Forests[i]); } } Current->RightChild->BaseNeighbour = Current->LeftChild; TriangleTree.InsertAtNode(Current->RightChild, t2, E); LoadTGA(&SkyBoxTexture, "SkyBox/CLOUDS.tga"); LoadGLTextures(&WaterTexture, "Textures/WATER1.bmp"); LoadGLTextures(&SurfaceTexture , "Data/Surface.bmp"); LoadGLTextures(&ShadowTexture , "Data/Shadows.bmp"); }
void MsnWepDlg::SetupControls() { ShipDesign* design = (ShipDesign*) elem->GetDesign(); if (lbl_element) lbl_element->SetText(elem->Name()); if (lbl_type) lbl_type->SetText(design->name); BuildLists(); for (int i = 0; i < 8; i++) { if (!lbl_desc[i]) continue; if (designs[i]) { lbl_desc[i]->Show(); lbl_desc[i]->SetText(designs[i]->group + " " + designs[i]->name); for (int n = 0; n < 8; n++) { if (mounts[i][n]) { btn_load[i][n]->Show(); btn_load[i][n]->SetPicture((loads[n]==i) ? led_on : led_off); } else { btn_load[i][n]->Hide(); } } } else { lbl_desc[i]->Hide(); for (int n = 0; n < 8; n++) { btn_load[i][n]->Hide(); } } } double loaded_mass = 0; char weight[32]; if (loadout_list) { loadout_list->ClearItems(); if (design) { ListIter<ShipLoad> sl = (List<ShipLoad>&) design->loadouts; while (++sl) { ShipLoad* load = sl.value(); int item = loadout_list->AddItem(load->name) - 1; sprintf_s(weight, "%d kg", (int) ((design->mass + load->mass) * 1000)); loadout_list->SetItemText(item, 1, weight); loadout_list->SetItemData(item, 1, (DWORD) (load->mass * 1000)); if (elem->Loadouts().size() > 0 && elem->Loadouts().at(0)->GetName() == load->name) { loadout_list->SetSelected(item, true); loaded_mass = design->mass + load->mass; } } } } if (lbl_weight) { if (loaded_mass < 1) loaded_mass = design->mass; sprintf_s(weight, "%d kg", (int) (loaded_mass * 1000)); lbl_weight->SetText(weight); } if (beauty && design) { beauty->SetPicture(design->beauty); } if (player_desc && design) { char txt[256]; if (design->type <= Ship::ATTACK) sprintf_s(txt, "%s %s", design->abrv, design->display_name); else sprintf_s(txt, "%s %s", design->abrv, elem->Name().data()); player_desc->SetText(txt); } }
static void Init(void) { static float ambient[] = {0.1, 0.1, 0.1, 1.0}; static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; static float position[] = {90.0, 90.0, 150.0, 0.0}; static float front_mat_shininess[] = {30.0}; static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; static float back_mat_shininess[] = {50.0}; static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; static float lmodel_twoside[] = {GL_TRUE}; glClearColor(0.0, 0.0, 0.0, 0.0); glFrontFace(GL_CW); glEnable(GL_DEPTH_TEST); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); glEnable(GL_CLIP_PLANE0); if (rgb) { glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest); glTexImage2D(GL_TEXTURE_2D, 0, 3, CHECKIMAGEWIDTH, CHECKIMAGEHEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)checkImage); glEnable(GL_TEXTURE_2D); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); } else { SetGreyRamp(); /* commented out by BrianP because it's the wrong way to handle a 4-bit visual! if (doubleBuffer) { colorIndexes[1] = 10; colorIndexes[2] = 15; } */ glMaterialiv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, colorIndexes); } BuildLists(); dithering = GL_TRUE; shade = GL_TRUE; doStipple = GL_FALSE; polyMode = GL_BACK; }
static void Init(void) { float ambient[] = {0.0, 0.0, 0.0, 1.0}; float diffuse[] = {1.0, 1.0, 1.0, 1.0}; float specular[] = {1.0, 1.0, 1.0, 1.0}; float position[] = {0.0, 0.0, 4.0, 0.0}; float fog_color[] = {0.0, 0.0, 0.0, 1.0}; float mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; float mat_shininess[] = {90.0}; float mat_specular[] = {1.0, 1.0, 1.0, 1.0}; float mat_diffuse[] = {0.8, 0.8, 0.8, 1.0}; float lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0}; float lmodel_twoside[] = {GL_TRUE}; int w, h; GLenum format; GLubyte *image; printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); SetDefaultSettings(); image = LoadRGBImage(imageFileName, &w, &h, &format); if (!image) { printf("Error: couldn't load %s\n", imageFileName); exit(1); } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, format, w, h, GL_RGB, GL_UNSIGNED_BYTE, image); free(image); glFogf(GL_FOG_DENSITY, 0.125); glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_START, 4.0); glFogf(GL_FOG_END, 8.5); glFogfv(GL_FOG_COLOR, fog_color); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHT0); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); glShadeModel(GL_SMOOTH); glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); glFrontFace(GL_CW); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glTexGeniv(GL_S, GL_TEXTURE_GEN_MODE, sphereMap); glTexGeniv(GL_T, GL_TEXTURE_GEN_MODE, sphereMap); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, sWrapMode); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tWrapMode); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment); BuildLists(); }
void Init(void) { float ambient[] = {0.0, 0.0, 0.0, 1.0}; float diffuse[] = {0.0, 1.0, 0.0, 1.0}; float specular[] = {1.0, 1.0, 1.0, 1.0}; float position[] = {2.0, 2.0, 0.0, 1.0}; float fog_color[] = {0.0, 0.0, 0.0, 1.0}; float mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; float mat_shininess[] = {90.0}; float mat_specular[] = {1.0, 1.0, 1.0, 1.0}; float mat_diffuse[] = {1.0, 1.0, 1.0, 1.0}; float lmodel_ambient[] = {0.0, 0.0, 0.0, 1.0}; float lmodel_twoside[] = {GL_TRUE}; float lmodel_local_viewer[] = {GL_FALSE}; SetDeepestColor(); SetDefaultSettings(); if (numComponents == 4) { image->data = AlphaPadImage(image->sizeX*image->sizeY, image->data, 128); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, numComponents, image->sizeX, image->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, image->data); } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, numComponents, image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, image->data); } glFogf(GL_FOG_DENSITY, 0.125); glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_START, 4.0); glFogf(GL_FOG_END, 9.0); glFogfv(GL_FOG_COLOR, fog_color); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glLightfv(GL_LIGHT0, GL_POSITION, position); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glClearColor(0.0, 0.0, 0.0, 0.0); glViewport(0, 0, W, H); glEnable(GL_DEPTH_TEST); glFrontFace(GL_CW); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glEnable(GL_TEXTURE_2D); glTexGeniv(GL_S, GL_TEXTURE_GEN_MODE, sphereMap); glTexGeniv(GL_T, GL_TEXTURE_GEN_MODE, sphereMap); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, sWrapMode); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tWrapMode); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment); BuildLists(); }
int main(int argc,char **argv) { f32 yscale; u32 xfbHeight; u32 fb = 0; u32 first_frame = 1; GXTexObj texture; Mtx view; // view and perspective matrices Mtx44 perspective; void *gpfifo = NULL; GXColor background = {0x00, 0x00, 0x00, 0xFF}; guVector cam = {0.0F, 0.0F, 0.0F}, up = {0.0F, 1.0F, 0.0F}, look = {0.0F, 0.0F, -1.0F}; TPLFile cubeTPL; VIDEO_Init(); PAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); // allocate the fifo buffer gpfifo = memalign(32,DEFAULT_FIFO_SIZE); memset(gpfifo,0,DEFAULT_FIFO_SIZE); // allocate 2 framebuffers for double buffering frameBuffer[0] = SYS_AllocateFramebuffer(rmode); frameBuffer[1] = SYS_AllocateFramebuffer(rmode); // configure video VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(frameBuffer[fb]); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); fb ^= 1; // init the flipper GX_Init(gpfifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(background,0x00FFFFFF); // other gx setup GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1); yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopyDst(rmode->fbWidth,xfbHeight); GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter); GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (rmode->aa) { GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); } else { GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); } GX_SetCullMode(GX_CULL_NONE); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); // setup the vertex attribute table // describes the data // args: vat location 0-7, type of data, data format, size, scale // so for ex. in the first call we are sending position data with // 3 values X,Y,Z of size F32. scale sets the number of fractional // bits for non float data. GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGB, GX_RGB8, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); // set number of rasterized color channels GX_SetNumChans(1); //set number of textures to generate GX_SetNumTexGens(1); GX_InvVtxCache(); GX_InvalidateTexAll(); TPL_OpenTPLFromMemory(&cubeTPL, (void *)Cube_tpl,Cube_tpl_size); TPL_GetTexture(&cubeTPL,cube,&texture); // setup our camera at the origin // looking down the -z axis with y up guLookAt(view, &cam, &up, &look); // setup our projection matrix // this creates a perspective matrix with a view angle of 90, // and aspect ratio based on the display resolution f32 w = rmode->viWidth; f32 h = rmode->viHeight; guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F); GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE); if (BuildLists(texture)) { // Build the display lists exit(1); // Exit if failed. } while(1) { PAD_ScanPads(); if ( PAD_ButtonsDown(0) & PAD_BUTTON_START) { exit(0); } u16 directions = PAD_ButtonsHeld(0); if ( directions & PAD_BUTTON_LEFT ) yrot += 0.5f; if ( directions & PAD_BUTTON_RIGHT ) yrot -= 0.5f; if ( yrot > 360.f ) yrot -= 360.f; if ( yrot < 0 ) yrot += 360.f; if ( directions & PAD_BUTTON_UP ) xrot -= 0.5f; if ( directions & PAD_BUTTON_DOWN ) xrot += 0.5f; if ( xrot > 360.f ) xrot -= 360.f; if ( xrot < 0 ) xrot += 360.f; if(first_frame) { first_frame = 0; VIDEO_SetBlack(FALSE); } // draw things DrawScene(view); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_DrawDone(); VIDEO_SetNextFramebuffer(frameBuffer[fb]); VIDEO_Flush(); VIDEO_WaitVSync(); fb ^= 1; } }