void dik_BuildSphereChainWithPowerUp(GLfloat factorR, GLfloat factorG, GLfloat factorB, char* outerTexture) { // Supreme Blast sphere. accumulator = 0.0f; SetEnvironmentSpotlight(); for(counter = 0; counter < CHAINMAXLENGTH; counter++) if(ASphere[counter] == NULL) { ASphere[counter] = gluNewQuadric(); if(ASphere[counter] == NULL) // If it's still not allocated. { MessageBox(NULL, "Memory allocation failed for chain.", "Error: Chain", MB_OK); break; } } glEnable(GL_TEXTURE_2D); sphereTexture = LoadBitmapFile("standard.bmp", &textureInfo[0]); BindTexturesAndSetMipmaps(); quadSphereTexture = LoadBitmapFile(outerTexture, &textureInfo[1]); BindTexturesAndSetMipmapsForPowerUp(); FixBackdropTexture(); }
clToolBar *QMakePlugin::CreateToolBar(wxWindow *parent) { // Create the toolbar to be used by the plugin clToolBar *tb(NULL); // You can use the below code a snippet: // First, check that CodeLite allows plugin to register plugins if (m_mgr->AllowToolbar()) { // Support both toolbars icon size int size = m_mgr->GetToolbarIconSize(); // Allocate new toolbar, which will be freed later by CodeLite tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE); // Set the toolbar size tb->SetToolBitmapSize(wxSize(size, size)); // Add tools to the plugins toolbar. You must provide 2 sets of icons: 24x24 and 16x16 if (size == 24) { tb->AddTool(XRCID("qmake_settings"), _("Configure qmake"), LoadBitmapFile(wxT("qt24_preferences.png")), _("Configure qmake")); tb->AddTool(XRCID("new_qmake_project"), _("Create new qmake based project"), LoadBitmapFile(wxT("qt24_new.png")), _("Create new qmake based project")); } else { tb->AddTool(XRCID("qmake_settings"), _("Configure qmake"), LoadBitmapFile(wxT("qt16_preferences.png")), _("Configure qmake")); tb->AddTool(XRCID("new_qmake_project"), _("Create new qmake based project"), LoadBitmapFile(wxT("qt16_new.png")), _("Create new qmake based project")); } // And finally, we must call 'Realize()' tb->Realize(); } // return the toolbar, it can be NULL if CodeLite does not allow plugins to register toolbars // or in case the plugin simply does not require toolbar return tb; }
void Textures::loadBMP(const char * path){ image = LoadBitmapFile(path, &bmpinfo); //image = LoadPixelBitmapFile(imgFile, &bmpinfo); width = bmpinfo.bmiHeader.biWidth; height = bmpinfo.bmiHeader.biHeight; assert(image); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //GL_REPEAT, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_LINEAR, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); int res=gluBuild2DMipmaps(GL_TEXTURE_2D,3,width,height,GL_RGB,GL_UNSIGNED_BYTE,image); if(res!=0){ //std::cerr<<"Texture build failed\n" // <<gluErrorString(res)<<endl; //exit(1); } /*image = loadBitmapFile(path, &bmpinfo); width = bmpinfo.bmiHeader.biWidth; height = bmpinfo.bmiHeader.biHeight; //check not a null assert(image); glGenTextures(1,&texture_ID); //glPrioritizeTextures( 6, textures, priorities); glBindTexture(GL_TEXTURE_2D,texture_ID); //材質控制 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 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,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,image); //使用多材質 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); int res=gluBuild2DMipmaps(GL_TEXTURE_2D,3,width,height,GL_RGB,GL_UNSIGNED_BYTE,image); if(res!=0){ std::cerr<<"Texture build failed\n" <<gluErrorString(res)<<endl; //exit(1); } */ /* glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, image); glEnable(GL_TEXTURE_2D); // 啟動貼圖運算 // 控制材質影像 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //GL_REPEAT or GL_CLAMP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //GL_REPEAT or GL_CLAMP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_LINEAR or GL_NEAREST glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // GL_LINEAR or GL_NEAREST */ }
int main(int argc, char *argv[]){ if(argc != 3) { fprintf(stderr, "./gen <image> <multiplication_factor>\n"); return -1; } char *file; char *aux; char out_file[100]; int n = atoi(argv[2]); BitmapFileHeader bfileHeader; BitmapInfoHeader binfoHeader; Pixel** image; image = LoadBitmapFile(argv[1], &binfoHeader, &bfileHeader); file = aux = argv[1]; aux = strrchr(aux, '/'); if(aux != NULL){ file = aux + 1; } file = strtok(file, "."); sprintf(out_file, "%s_x%d.bmp", file, n); SaveBitmapFileNTimes(out_file, &binfoHeader, &bfileHeader, image, n); PrintBitmapInfo(&binfoHeader, &bfileHeader); return 0; }
void dik_BuildStandardSphereChain() { // The standard sphere chain. accumulator = 0.0f; SetEnvironmentSpotlight(); factorR = 0.0f; factorG = INITIALTRANSFORMATIONCOLOURS; factorB = 0.0f; for(counter = 0; counter < CHAINMAXLENGTH; counter++) if(ASphere[counter] == NULL) { ASphere[counter] = gluNewQuadric(); if(ASphere[counter] == NULL) // If it's still not allocated. { MessageBox(NULL, "Memory allocation failed for chain.", "Error: Chain", MB_OK); break; } } glEnable(GL_TEXTURE_2D); sphereTexture = LoadBitmapFile("standard.bmp", &textureInfo[0]); BindTexturesAndSetMipmaps(); FixBackdropTexture(); }
CppCheckPlugin::CppCheckPlugin(IManager* manager) : IPlugin(manager) , m_cppcheckProcess(NULL) , m_canRestart(true) , m_explorerSepItem(NULL) , m_workspaceSepItem(NULL) , m_projectSepItem(NULL) , m_view(NULL) , m_analysisInProgress(false) , m_fileCount(0) , m_fileProcessed(1) { FileExtManager::Init(); m_longName = _("CppCheck integration for CodeLite IDE"); m_shortName = wxT("CppCheck"); // Load settings m_mgr->GetConfigTool()->ReadObject("CppCheck", &m_settings); // Now set default suppressions if none have been serialised m_settings.SetDefaultSuppressedWarnings(); // NB we can't load any project-specific settings here, as the workspace won't yet have loaded. We do it just before // they're used // Connect events m_mgr->GetTheApp()->Connect(XRCID("cppcheck_settings_item"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CppCheckPlugin::OnSettingsItem), NULL, (wxEvtHandler*)this); m_mgr->GetTheApp()->Connect(XRCID("cppcheck_settings_item_project"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CppCheckPlugin::OnSettingsItemProject), NULL, (wxEvtHandler*)this); m_mgr->GetTheApp()->Connect(XRCID("cppcheck_fileexplorer_item"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CppCheckPlugin::OnCheckFileExplorerItem), NULL, (wxEvtHandler*)this); m_mgr->GetTheApp()->Connect(XRCID("cppcheck_workspace_item"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CppCheckPlugin::OnCheckWorkspaceItem), NULL, (wxEvtHandler*)this); m_mgr->GetTheApp()->Connect(XRCID("cppcheck_project_item"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CppCheckPlugin::OnCheckProjectItem), NULL, (wxEvtHandler*)this); EventNotifier::Get()->Connect( wxEVT_WORKSPACE_CLOSED, wxCommandEventHandler(CppCheckPlugin::OnWorkspaceClosed), NULL, this); m_view = new CppCheckReportPage(m_mgr->GetOutputPaneNotebook(), m_mgr, this); // wxBookCtrlBase *book = m_mgr->GetOutputPaneNotebook(); m_mgr->GetOutputPaneNotebook()->AddPage(m_view, wxT("CppCheck"), false, LoadBitmapFile(wxT("cppcheck.png"))); }
int main(void) { int err = 0; BITMAPFILEHEADER bitmapFileHeader; BITMAPINFOHEADER bitmapInfoHeader; unsigned char* bitmapData; printf("Applying brightness\n"); bitmapData = LoadBitmapFile("ubuntu.bmp",&bitmapFileHeader, &bitmapInfoHeader); // Apply image brightness to image adjustImageBrightness(bitmapData, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, false, 70); err = SaveBitmapFile("out_brightness.bmp", &bitmapFileHeader, &bitmapInfoHeader, bitmapData); if (err) { printf("Error trying to save bitmap\n"); } free(bitmapData); printf("Applying dark image\n"); bitmapData = LoadBitmapFile("ubuntu.bmp",&bitmapFileHeader, &bitmapInfoHeader); darkenImage(bitmapData, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight); err = SaveBitmapFile("out_dark.bmp", &bitmapFileHeader, &bitmapInfoHeader, bitmapData); if (err) { printf("Error trying to save bitmap\n"); } free(bitmapData); printf("Applying effect\n"); bitmapData = LoadBitmapFile("ubuntu.bmp",&bitmapFileHeader, &bitmapInfoHeader); effect(bitmapData, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight); err = SaveBitmapFile("out_bw.bmp", &bitmapFileHeader, &bitmapInfoHeader, bitmapData); if (err) { printf("Error trying to save bitmap\n"); } free(bitmapData); return EXIT_SUCCESS; }
void dik_BuildPowerUp(char *bitmapName) { SetSphereSpotlight(); texturedSphere = gluNewQuadric(); // Create new quadric. gluQuadricTexture(texturedSphere, GL_TRUE); // Allow sphere to be texture mapped. glEnable(GL_TEXTURE_2D); sphereTexture = LoadBitmapFile(bitmapName, &textureInfo[0]); BindTexturesAndSetMipmaps(); FixBackdropTexture(); }
bool LoadBmp(int image_id,char *name,int lim,...) { unsigned char r = 0,g = 0,b = 0; unsigned char *buffer; BITMAPINFOHEADER bitmapInfoHeader; glGenTextures(1, &texture[image_id]); // Typical Texture Generation Using Data From The Bitmap glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, texture[image_id]); if(lim == 0) { buffer= LoadBitmapFile(name, &bitmapInfoHeader); if(buffer == NULL) return false; glTexImage2D(GL_TEXTURE_2D, 0, 3, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer); } else { va_list ap; va_start(ap, lim); r =va_arg(ap, unsigned char); g =va_arg(ap, unsigned char); b =va_arg(ap, unsigned char); va_end(ap); buffer= LoadBitmapFileWithAlpha(name, &bitmapInfoHeader,r,g,b); if(buffer == NULL) return false; glTexImage2D(GL_TEXTURE_2D, 0, 4, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); free(buffer); return true; }
void Heightfield::load( char* filename ) { clear(); defaults(); #if 0 _header = new BITMAPINFOHEADER(); _imageData = LoadBitmapFile( filename, _header ); #else _imageData = read_ppm( filename ); #endif if( _imageData ) { initializeTerrain( _imageData ); } }
// Initialize // desc: initializes OpenGL void Initialize() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // clear to black glShadeModel(GL_SMOOTH); // use smooth shading glEnable(GL_DEPTH_TEST); // hidden surface removal glEnable(GL_CULL_FACE); // do not calculate inside of poly's glFrontFace(GL_CCW); // counter clock-wise polygons are out glEnable(GL_TEXTURE_2D); // enable 2D texturing imageData = LoadBitmapFile("terrain2.bmp", &bitmapInfoHeader); // initialize the terrain data and load the textures InitializeTerrain(); LoadTextures(); }
void AbbreviationPlugin::OnAbbreviations(wxCommandEvent& e) { IEditor *editor = m_mgr->GetActiveEditor(); if (!editor) { return; } AbbreviationJSONEntry jsonData; if ( !m_config.ReadItem( &jsonData ) ) { // merge the data from the old configuration AbbreviationEntry data; m_mgr->GetConfigTool()->ReadObject(wxT("AbbreviationsData"), &data); jsonData.SetAutoInsert( data.GetAutoInsert() ); jsonData.SetEntries( data.GetEntries() ); m_config.WriteItem( &jsonData ); } wxString wordAtCaret = editor->GetWordAtCaret(); bool autoInsert = (jsonData.IsAutoInsert() && wordAtCaret.IsEmpty() == false); if ( autoInsert ){ autoInsert = InsertExpansion(wordAtCaret); } if ( !autoInsert ) { static wxBitmap bmp = LoadBitmapFile(wxT("abbrev.png")) ; if (bmp.IsOk()) { editor->RegisterImageForKind(wxT("Abbreviation"), bmp); std::vector<TagEntryPtr> tags; // search for the old item const JSONElement::wxStringMap_t& entries = jsonData.GetEntries(); JSONElement::wxStringMap_t::const_iterator iter = entries.begin(); for (; iter != entries.end(); ++iter) { TagEntryPtr t(new TagEntry()); t->SetName(iter->first); t->SetKind(wxT("Abbreviation")); tags.push_back(t); } editor->ShowCompletionBox(tags, editor->GetWordAtCaret(), false, this); } } }
void AbbreviationPlugin::OnAbbreviations(wxCommandEvent& e) { IEditor* editor = m_mgr->GetActiveEditor(); if(!editor) { return; } AbbreviationJSONEntry jsonData; if(!m_config.ReadItem(&jsonData)) { // merge the data from the old configuration AbbreviationEntry data; m_mgr->GetConfigTool()->ReadObject(wxT("AbbreviationsData"), &data); jsonData.SetAutoInsert(data.GetAutoInsert()); jsonData.SetEntries(data.GetEntries()); m_config.WriteItem(&jsonData); } wxString wordAtCaret = editor->GetWordAtCaret(); bool autoInsert = (jsonData.IsAutoInsert() && wordAtCaret.IsEmpty() == false); if(autoInsert) { autoInsert = InsertExpansion(wordAtCaret); } if(!autoInsert) { static wxBitmap bmp = LoadBitmapFile(wxT("abbrev.png")); if(bmp.IsOk()) { wxCodeCompletionBoxEntry::Vec_t ccEntries; wxCodeCompletionBox::BmpVec_t bitmaps; bitmaps.push_back(bmp); // search for the old item const JSONElement::wxStringMap_t& entries = jsonData.GetEntries(); JSONElement::wxStringMap_t::const_iterator iter = entries.begin(); for(; iter != entries.end(); ++iter) { ccEntries.push_back(wxCodeCompletionBoxEntry::New(iter->first, 0)); } wxCodeCompletionBoxManager::Get().ShowCompletionBox( editor->GetCtrl(), ccEntries, bitmaps, wxCodeCompletionBox::kNone, wxNOT_FOUND, this); } } }
void CDocObj::texload(const char *filename) { BITMAPINFOHEADER bitmapInfoHeader; // bitmap信息头 m_bitmapData = LoadBitmapFile(filename, &bitmapInfoHeader); glBindTexture(GL_TEXTURE_2D, m_texture); // 指定当前纹理的放大/缩小过滤方式 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, //mipmap层次(通常为,表示最上层) GL_RGB, //我们希望该纹理有红、绿、蓝数据 bitmapInfoHeader.biWidth, //纹理宽带,必须是n,若有边框+2 bitmapInfoHeader.biHeight, //纹理高度,必须是n,若有边框+2 0, //边框(0=无边框, 1=有边框) GL_RGB, //bitmap数据的格式 GL_UNSIGNED_BYTE, //每个颜色数据的类型 m_bitmapData); //bitmap数据指针 }
void LoadTexture(int i, char *filename) { BITMAPINFOHEADER bitmapInfoHeader; unsigned char* bitmapData; bitmapData = LoadBitmapFile(filename, &bitmapInfoHeader); glBindTexture(GL_TEXTURE_2D, texture[i]); 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, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData ); }
/***************************************************************************** LoadBitmapFileWithAlpha Loads a bitmap file normally, and then adds an alpha component to use for blending *****************************************************************************/ unsigned char * baiscobj::LoadBitmapFileWithAlpha(char *filename, BITMAPINFOHEADER *bitmapInfoHeader) { unsigned char *bitmapImage = LoadBitmapFile(filename, bitmapInfoHeader); unsigned char *bitmapWithAlpha = (unsigned char *)malloc(bitmapInfoHeader->biSizeImage * 4 / 3); if (bitmapImage == NULL || bitmapWithAlpha == NULL) return NULL; // loop through the bitmap data for (unsigned int src = 0, dst = 0; src < bitmapInfoHeader->biSizeImage; src +=3, dst +=4) { // if the pixel is black, set the alpha to 0. Otherwise, set it to 255. if (bitmapImage[src] == 0 && bitmapImage[src+1] == 0 && bitmapImage[src+2] == 0) bitmapWithAlpha[dst+3] = 0; else bitmapWithAlpha[dst+3] = 0xFF; // copy pixel data over /*bitmapWithAlpha[dst] = bitmapImage[src]; bitmapWithAlpha[dst+1] = bitmapImage[src+1]; bitmapWithAlpha[dst+2] = bitmapImage[src+2];*/ if (isBlack) { bitmapWithAlpha[dst] = 0; bitmapWithAlpha[dst+1] = 0; bitmapWithAlpha[dst+2] = 0; } else { bitmapWithAlpha[dst] = bitmapImage[src]; bitmapWithAlpha[dst+1] = bitmapImage[src+1]; bitmapWithAlpha[dst+2] = bitmapImage[src+2]; } } free(bitmapImage); //delete bitmapImage; return bitmapWithAlpha; } // end LoadBitmapFileWithAlpha()
//加载纹理的函数: void LoadBMP(TextureImage *texture, const char *filename) { BITMAPINFOHEADER bitmapInfoHeader; // bitmap信息头 glGenTextures(1, &texture[0].texID); texture[0].imageData = LoadBitmapFile(filename, &bitmapInfoHeader); glBindTexture(GL_TEXTURE_2D, texture[0].texID); // 指定当前纹理的放大/缩小过滤方式 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); texture->height = bitmapInfoHeader.biHeight; texture->width = bitmapInfoHeader.biWidth; glTexImage2D(GL_TEXTURE_2D, 0, //bipmap层次(通常为,表示最上层) GL_RGB, //我们希望该纹理有红、绿、蓝数据 bitmapInfoHeader.biWidth, //纹理宽度,必须是n,若有边框+2 bitmapInfoHeader.biHeight, //纹理高度,必须是n,若有边框+2 0, //边框(0=无边框, 1=有边框) GL_RGB, //bitmap数据的格式 GL_UNSIGNED_BYTE, //每个颜色数据的类型 texture[0].imageData); //bitmap数据指针 }
/***************************************************************************** LoadBitmapFileWithAlpha Loads a bitmap file normally, and then adds an alpha component to use for blending *****************************************************************************/ unsigned char *LoadBitmapFileWithAlpha(char *filename, BITMAPINFOHEADER *bitmapInfoHeader,unsigned char r,unsigned char g,unsigned char b) { unsigned char *bitmapImage = LoadBitmapFile(filename, bitmapInfoHeader); unsigned char *bitmapWithAlpha = (unsigned char *)malloc(bitmapInfoHeader->biSizeImage * 4 / 3); unsigned int src = 0, dst = 0 ; if (bitmapImage == NULL || bitmapWithAlpha == NULL) return NULL; // loop through the bitmap data if((bitmapInfoHeader->biWidth & 1)!=0 || (bitmapInfoHeader->biHeight & 1)!=0) { printf("Image Size not divisible by 2\n"); return NULL; } for (; src < bitmapInfoHeader->biSizeImage; src +=3, dst +=4) { // if the pixel is black, set the alpha to 0. Otherwise, set it to 255. if (bitmapImage[src] ==r&& bitmapImage[src+1] ==g && bitmapImage[src+2] ==b) bitmapWithAlpha[dst+3] =0 ; else bitmapWithAlpha[dst+3] = 0xFF; // copy pixel data over bitmapWithAlpha[dst] = bitmapImage[src]; bitmapWithAlpha[dst+1] = bitmapImage[src+1]; bitmapWithAlpha[dst+2] = bitmapImage[src+2]; } free(bitmapImage); return bitmapWithAlpha; }
GLuint ReadBMP2TEX(const char* filename) { BITMAPINFOHEADER bitmapInfoHeader; // bitmap信息头 unsigned char* bitmapData; // 纹理数据 GLuint texture; bitmapData = LoadBitmapFile(filename, &bitmapInfoHeader); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); // 指定当前纹理的放大/缩小过滤方式 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, //mipmap层次(通常为,表示最上层) GL_RGB, //我们希望该纹理有红、绿、蓝数据 bitmapInfoHeader.biWidth, //纹理宽带,必须是n,若有边框+2 bitmapInfoHeader.biHeight, //纹理高度,必须是n,若有边框+2 0, //边框(0=无边框, 1=有边框) GL_RGB, //bitmap数据的格式 GL_UNSIGNED_BYTE, //每个颜色数据的类型 bitmapData); //bitmap数据指针 return texture; }
void Init() { // ::SetTimer(g_hwnd,100,1000,NULL); bool bret = LoadBitmapFile(&bitmap,"wall.bmp"); int bitmapwidth = bitmap.bitmapinfoheader.biWidth; int bitmapheight = bitmap.bitmapinfoheader.biHeight; CRenderObject *pobj = new CRenderObject; std::vector<Vertex> pointlist; pointlist.push_back(Vertex(POINT3D(10,10,10) )); pointlist.push_back(Vertex(POINT3D(10,10,-10))); pointlist.push_back(Vertex(POINT3D(-10,10,-10))); pointlist.push_back(Vertex(POINT3D(-10,10,10))); pointlist.push_back(Vertex(POINT3D(10,-10,10))); pointlist.push_back(Vertex(POINT3D(-10,-10,10))); pointlist.push_back(Vertex(POINT3D(-10,-10,-10))); pointlist.push_back(Vertex(POINT3D(10,-10,-10))); pobj->m_translateverticesList = pointlist; pobj->m_verticesList = pointlist; //Set texture pointlist std::vector<POINT2D> texturelist; texturelist.push_back(POINT2D(0,0)); texturelist.push_back(POINT2D(bitmapwidth-1,0)); texturelist.push_back(POINT2D(bitmapwidth-1,bitmapheight-1)); texturelist.push_back(POINT2D(0,bitmapheight-1)); pobj->m_texturecoordinatesList = texturelist; int tempindices[36]= { 0,1,2, 0,2,3, 0,7,1, 0,4,7, 1,7,6, 1,6,2, 2,6,5, 2,3,5, 0,5,4, 0,3,5, 5,6,7, 4,5,7 }; int textindices[36] = { 2,1,0, 2,0,3, 2,0,1, 2,3,0, 1,0,3, 1,3,0, 0,1,2, 2,3,0, 2,0,1, 2,3,0, 2,1,0, 3,2,0 }; for(int i =0; i <12;++i) { POLYGON temp ; temp.v[0] = tempindices[i*3+0]; temp.v[1] = tempindices[i*3+1]; temp.v[2] = tempindices[i*3 +2]; temp.text[0] = textindices[i*3+0]; temp.text[1] = textindices[i*3+1]; temp.text[2] = textindices[i*3+2]; temp.state |= OBJECT_HAS_TEXTURE|SHADE_MODEL_CONSTANT; temp.color = RGBA(RGB(128,123,140)); temp.texture = &bitmap; temp.pointlist = &pobj->m_verticesList; temp.texturecoordinatelist = &pobj->m_texturecoordinatesList; pobj->m_PolyGonList.push_back(temp); } pobj->world_pos = POINT3D(-10,0,50); CRenderObject *pobj2 = new CRenderObject(*pobj); pobj2->world_pos = POINT3D(15,0,50); CRenderObject* pobj3 =new CRenderObject(*pobj); pobj3->world_pos = POINT3D(0,10,80); CRenderObject *pobj4 = new CRenderObject(*pobj); pobj4->world_pos = POINT3D(20,-10,100); g_RenderManager.Add(pobj); g_RenderManager.Add(pobj2); g_RenderManager.Add(pobj3); g_RenderManager.Add(pobj4); //Set lights CLight *pLight = new CLight; pLight->InitLight(CLight::kAmbientLight,RGBA(RGB(255,0,0)),Black_Color,Black_Color); g_lights.AddLight(pLight); CLight *pLight2 = new CLight; pLight2->InitLight(CLight::kInfiniteLigtht,Black_Color,RGBA(255,0,0),Black_Color,ZeroVector, Vector4D(-1.0,0.0,1.0)); g_lights.AddLight(pLight2); CLight *pLight3 = new CLight; pLight3->InitLight(CLight::kPointLight,Black_Color,RGBA(0,255,0),Black_Color,Vector4D(0,10,0), ZeroVector,1.0,2.0,4.0); g_lights.AddLight(pLight3); CLight *pLight4 = new CLight; pLight4->InitLight(CLight::kSpotLight,Black_Color,RGBA(255,255,255),Black_Color,Vector4D(0,20,10), Vector4D(0.0,0.0,1.0),0.0,0.01,0.0,30.0,60.0,1.0); g_lights.AddLight(pLight4); g_RenderManager.SetCamera(&g_cam); g_RenderManager.SetLightManager(&g_lights); }
void dik_InitialisePostApocalypticGarderOfEden() { int i; // Indexer for 'for loops' in this function. SetEnvironmentSpotlight(); InitialiseTransparents(); // Initialise scoreboard font. AllocateHeapForScoreboard(); g_FontListID = CreateOpenGL3DFont("Impact", FONT_EXTRUDE); // Load graphics files. powerUpImageData[0] = LoadBitmapFile("standard.bmp", &powerUpBitmapInfoHeader[0]); powerUpTexture[0] = LoadBitmapFile("standard.bmp", &powerUpBitmapInfo[0]); powerUpImageData[1] = LoadBitmapFile("supblast.bmp", &powerUpBitmapInfoHeader[1]); powerUpTexture[1] = LoadBitmapFile("supblast.bmp", &powerUpBitmapInfo[1]); powerUpImageData[2] = LoadBitmapFile("rebirth.bmp", &powerUpBitmapInfoHeader[2]); powerUpTexture[2] = LoadBitmapFile("rebirth.bmp", &powerUpBitmapInfo[2]); powerUpImageData[3] = LoadBitmapFile("sbrebirth.bmp", &powerUpBitmapInfoHeader[3]); powerUpTexture[3] = LoadBitmapFile("sbrebirth.bmp", &powerUpBitmapInfo[3]); powerUpImageData[4] = LoadBitmapFile("invisibility.bmp", &powerUpBitmapInfoHeader[4]); powerUpTexture[4] = LoadBitmapFile("invisibility.bmp", &powerUpBitmapInfo[4]); BindTexturesAndSetMipmapsForPowerUpsInEnvironments(); glEnable(GL_TEXTURE_2D); // Allocate power up objects and allow them to be texture mapped. for(i = 0; i < NUMEFFECTS; i++) { powerUpSphere[i] = gluNewQuadric(); if(powerUpSphere[i] == NULL) MessageBox(ghwnd, "Failed to allocate power up object for PAGoE!", "PAGoE Population Error...", MB_OK | MB_ICONEXCLAMATION); // If out of memory. else gluQuadricTexture(powerUpSphere[i], GL_TRUE); } // Claim all memory required to render all players. for(i = 0; i < MAXPLAYERCHAINLENGTH; i++) { player1Chain[i] = gluNewQuadric(); player2Chain[i] = gluNewQuadric(); player3Chain[i] = gluNewQuadric(); if((player1Chain[i] == NULL) || (player2Chain[i] == NULL) || (player3Chain[i] == NULL)) MessageBox(ghwnd, "Failed to allocate all player models for PAGoE!", "PAGoE Population Error...", MB_OK | MB_ICONEXCLAMATION); // If out of memory. else { gluQuadricTexture(player1Chain[i], GL_TRUE); gluQuadricTexture(player2Chain[i], GL_TRUE); gluQuadricTexture(player3Chain[i], GL_TRUE); } } // Initialise marker spere for player markerSphere = gluNewQuadric(); if(markerSphere == NULL) MessageBox(ghwnd, "Failed to allocate marker for player.", "PAGoE Population Error...", MB_OK | MB_ICONEXCLAMATION); // Return to processing for environment. imageData = LoadBitmapFile("KBGrass.bmp", &bitmapInfoHeader); landTexture = LoadBitmapFile("KBGrass.bmp", &landInfo); InitialiseTerrain(); LoadTextures(); if(!LoadTextures()) MessageBox(ghwnd, "Texture(s) could not be loaded.", "Post Apocalyptic Garden of Eden", MB_ICONEXCLAMATION); }
// Load texture from mtl file // Return texture index static int load_wavefront_mtl(const char *mtlname, WAVEFRONT_MODEL_T *model) { char line[256+1]; //unsigned short pp[54+1]; int i, valid; char texFile[128]; FILE *mtl_file = NULL; // Open .mtl file mtl_file = fopen(mtlname, "rb"); if (!mtl_file) return -1; valid = fread(line, 1, sizeof(line)-1, mtl_file); while (valid > 0) { char *s, *end = line; // Seek end of line while((end-line < valid) && *end != '\n' && *end != '\r') end++; *end++ = 0; // Remove all stray \r\n's while((end-line < valid) && (*end == '\n' || *end == '\r')) end++; s = line; if (s[strlen(s)-1] == 10) s[strlen(s)-1]=0; switch (s[0]) { case '#': break; // comment case '\r': case '\n': case '\0': break; // blank line case 'd': { if(sscanf(s, "d %f", model->transparency) == 1) { s += 1; } break; } case 'N': { if(s[1] == 's') { if(sscanf(s, "Ns %f", model->shininess) == 1) { s += 1; } } break; } case 'K': { switch(s[1]) { case 'a': { if(sscanf(s, "Ka %f %f %f %f", model->ambientColor, model->ambientColor+1, model->ambientColor+2, model->ambientColor+3) == 4) { s += 4; } else if(sscanf(s, "Ka %f %f %f", model->ambientColor, model->ambientColor+1, model->ambientColor+2) == 3) { s += 3; model->ambientColor[3] = 1; } break; } case 'd': { if(sscanf(s, "Kd %f %f %f %f", model->difuseColor, model->difuseColor+1, model->difuseColor+2, model->difuseColor+3) == 4) { s += 4; } else if(sscanf(s, "Kd %f %f %f", model->difuseColor, model->difuseColor+1, model->difuseColor+2) == 3) { s += 3; model->difuseColor[3] = 1; } break; } case 's': { if(sscanf(s, "Ks %f %f %f %f", model->specularColor, model->specularColor+1, model->specularColor+2, model->specularColor+3) == 4) { s += 4; } else if(sscanf(s, "Ks %f %f %f", model->specularColor, model->specularColor+1, model->specularColor+2) == 3) { s += 3; model->specularColor[3] = 1; } break; } } break; } // If texture location case 'm': { if(s[1] == 'a' && s[2] == 'p') { // Extract file name int len = strlen(s); len = len - 7; memmove ( texFile, s + 7, len); // Load texture file // Copy file name (get root dir) char fileName[512]; memmove (fileName, mtlname, 512); int nameEnd = strlen(fileName); // Seek start of mtlName int nameStart = nameEnd; while((nameStart > 0)&&(fileName[nameStart] != '/')) { nameStart --; } // Increase by 1 to point past / nameStart++; int copyCount = 0; for(copyCount = 0; copyCount < len; copyCount++) { fileName[nameStart + copyCount] = texFile[copyCount]; } fileName[nameStart + copyCount] = 0; // BMP file vars BITMAPINFOHEADER bitmapInfoHeader; unsigned char *tex_buf = NULL; tex_buf = LoadBitmapFile(fileName, &bitmapInfoHeader); // Create texture with bitmap data glGenTextures(1, &model->texture); glBindTexture(GL_TEXTURE_2D, model->texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, tex_buf); // Generate texture mipmap glGenerateMipmap(GL_TEXTURE_2D); checkGLError(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); } } default: break;//printf("%02x %02x %s", s[0], s[1], s); vc_assert(0); break; } // shift down read characters and read some more into the end // if we didn't find a newline, then end is one off the end of our // line, so end-line will be valid+1 i = end-line > valid ? valid : end-line; memmove(line, end, valid - i); valid -= i; valid += fread(line+valid, 1, sizeof(line)-1-valid, mtl_file); } fclose(mtl_file); return 0; }
ContinuousBuild::ContinuousBuild(IManager *manager) : IPlugin(manager) , m_buildInProgress(false) { m_longName = wxT("Continuous build plugin which compiles files on save and report errors"); m_shortName = wxT("ContinuousBuild"); m_view = new ContinousBuildPane(m_mgr->GetOutputPaneNotebook(), m_mgr, this); // add our page to the output pane notebook m_mgr->GetOutputPaneNotebook()->AddPage(m_view, wxT("Continuous Build"), wxT("Continuous Build"), LoadBitmapFile(wxT("compfile.png")), false); m_topWin = m_mgr->GetTheApp(); m_topWin->Connect(wxEVT_FILE_SAVED, wxCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this); m_topWin->Connect(wxEVT_FILE_SAVE_BY_BUILD_START, wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this); m_topWin->Connect(wxEVT_FILE_SAVE_BY_BUILD_END, wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this); }
int CTextureManager::LoadTexture (const char *szFilename, int nTextureID) { sprintf (m_Singleton->szErrorMessage, "Beginning to Loading [%s]", szFilename); int nWidth = 0, nHeight = 0, nBPP = 0; UBYTE *pData = 0; // Determine the type and actually load the file // =========================================================================================== char szCapFilename [80]; int nLen = strlen (szFilename); for (int c = 0; c <= nLen; c++) // <= to include the NULL as well szCapFilename [c] = toupper (szFilename [c]); if (strcmp (szCapFilename + (nLen - 3), "BMP") == 0 || strcmp (szCapFilename + (nLen - 3), "TGA") == 0) { // Actually load them if (strcmp (szCapFilename + (nLen - 3), "BMP") == 0) { pData = LoadBitmapFile (szFilename, nWidth, nHeight, nBPP); if (pData == 0) return -1; } if (strcmp (szCapFilename + (nLen - 3), "TGA") == 0) { pData = LoadTargaFile (szFilename, nWidth, nHeight, nBPP); if (pData == 0) return -1; } } else { sprintf (m_Singleton->szErrorMessage, "ERROR : Unable to load extension [%s]", szCapFilename + (nLen - 3)); return -1; } // Assign a valid Texture ID (if one wasn't specified) // =========================================================================================== int nNewTextureID = GetNewTextureID (nTextureID); // Also increases nNumTextures! // =========================================================================================== // Register and upload the texture in OpenGL glBindTexture (GL_TEXTURE_2D, nNewTextureID); // NOTE : Making some assumptions about texture parameters glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); /* You can use this one if you don't want to eat memory and Mip-mapped textures glTexImage2D (GL_TEXTURE_2D, 0, nGLFormat, nWidth, nHeight, 0, nGLFormat, GL_UNSIGNED_BYTE, pData); */ gluBuild2DMipmaps (GL_TEXTURE_2D, nBPP, nWidth, nHeight, (nBPP == 3 ? GL_RGB : GL_RGBA), GL_UNSIGNED_BYTE, pData); delete [] pData; sprintf (m_Singleton->szErrorMessage, "Loaded [%s] W/O a hitch!", szFilename); return nNewTextureID; }
void CGeneral::LoadImages() { m_imgCards = LoadBitmapFile(IMAGES_DIR "cards.bmp"); m_imgBack = LoadBitmapFile(IMAGES_DIR "back.bmp"); }
// Window procedure, handles all messages for this program LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HGLRC hRC; // Permenant Rendering context static HDC hDC; // Private GDI Device context switch (message) { // Window creation, setup for OpenGL case WM_CREATE: SetTimer(hWnd, 1002, Tools::refreshFreq, NULL); // Store the device context hDC = GetDC(hWnd); // Select the pixel format SetDCPixelFormat(hDC); // Create palette if needed hPalette = GetOpenGLPalette(hDC); // Create the rendering context and make it current hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); SetupRC(); nazwa = "Moon.bmp"; const char* bitmapFileName; bitmapFileName =nazwa.c_str(); glGenTextures(1, &texture); // tworzy obiekt tekstury // 3aduje pierwszy obraz tekstury: bitmapData = LoadBitmapFile((char*)bitmapFileName, &bitmapInfoHeader); glBindTexture(GL_TEXTURE_2D, texture); // aktywuje obiekt tekstury glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // tworzy obraz tekstury glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData); //if (bitmapData) //free(bitmapData); /* GLuint texture; int width, height; unsigned char* image; // Load textures glGenTextures(1, &texture); image = LoadBitmapFile("Bitmapy//Moon.bmp",&bitmapInfoHeader); // select our current texture glBindTexture(GL_TEXTURE_2D, texture); // select modulate to mix texture with color for shading glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData); */ // 3aduje drugi obraz tekstury: /* bitmapData = LoadBitmapFile("Bitmapy\\crate.bmp", &bitmapInfoHeader); glBindTexture(GL_TEXTURE_2D, texture[1]); // aktywuje obiekt tekstury glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); // tworzy obraz tekstury glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData); if (bitmapData) free(bitmapData); */ // ustalenie sposobu mieszania tekstury z t3em //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); break; // Window is being destroyed, cleanup case WM_DESTROY: // Deselect the current rendering context and delete it wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); // Delete the palette if it was created if (hPalette != NULL) DeleteObject(hPalette); // Tell the application to terminate after the window // is gone. PostQuitMessage(0); break; // Window is resized. case WM_SIZE: // Call our function which modifies the clipping // volume and viewport ChangeSize(LOWORD(lParam), HIWORD(lParam)); break; // The painting function. This message sent by Windows // whenever the screen needs updating. case WM_PAINT: { } case WM_TIMER: { // Call OpenGL drawing code position = world->getPosition(); v = world->getVelocity(); fuel = 1000 * world->getFuel(); velocity = v.y; velocityx = v.x / 2; velocityz = v.z / 2; height = position.y / 20; score = world->getHighscore(); if (score > highscore) { highscore = score; } RenderScene(); SwapBuffers(hDC); if (spisSet) { world->control[0] = true; } else { world->control[0] = false; } if (s) { world->control[3] = true; } else { world->control[3] = false; } if (a) { world->control[2] = true; } else { world->control[2] = false; } if (d) { world->control[1] = true; } else { world->control[1] = false; } if (w) { world->control[4] = true; } else { world->control[4] = false; } // Validate the newly painted client area ValidateRect(hWnd, NULL); } // Windows is telling the application that it may modify // the system palette. This message in essance asks the // application for a new palette. case WM_QUERYNEWPALETTE: // If the palette was created. if (hPalette) { int nRet; // Selects the palette into the current device context SelectPalette(hDC, hPalette, FALSE); // Map entries from the currently selected palette to // the system palette. The return value is the number // of palette entries modified. nRet = RealizePalette(hDC); // Repaint, forces remap of palette in current window InvalidateRect(hWnd, NULL, FALSE); return nRet; } break; // This window may set the palette, even though it is not the // currently active window. case WM_PALETTECHANGED: // Don't do anything if the palette does not exist, or if // this is the window that changed the palette. if ((hPalette != NULL) && ((HWND)wParam != hWnd)) { // Select the palette into the device context SelectPalette(hDC, hPalette, FALSE); // Map entries to system palette RealizePalette(hDC); // Remap the current colors to the newly realized palette UpdateColors(hDC); return 0; } break; // Key press, check for arrow keys to do cube rotation. case WM_KEYDOWN: { if (wParam == VK_UP) xRot -= 5.0f; if (wParam == VK_DOWN) xRot += 5.0f; if (wParam == VK_LEFT) yRot -= 5.0f; if (wParam == VK_RIGHT) yRot += 5.0f; if (wParam == VK_SPACE) spisSet = true; if (wParam == 0x41) a = true; if (wParam == 0x44) d = true; if (wParam == 0x57) w = true; if (wParam == 0x53) s = true; if (wParam == 0x52) world->tryRefuel(); xRot = GLfloat((const int)xRot % 360); yRot = GLfloat((const int)yRot % 360); InvalidateRect(hWnd, NULL, FALSE); } break; case WM_KEYUP: { if (wParam == VK_SPACE) spisSet = false; if (wParam == 0x41) a = false; if (wParam == 0x44) d = false; if (wParam == 0x57) w = false; if (wParam == 0x53) s = false; } case WM_MOUSEMOVE: { int posX = GET_X_LPARAM(lParam); int posY = GET_Y_LPARAM(lParam); float xAngle = 0.2f; float yAngle = 0.2f; int angle = 1.0f; if (GetKeyState(VK_LBUTTON) & 0x80) { /* if (posX > mousePosX) world->changeCamera(0.0f, angle, 0.0f); if (posX < mousePosX) world->changeCamera(0.0f, -angle, 0.0f); if (posY > mousePosY) world->changeCamera(angle, 0.0f, 0.0f); if (posY < mousePosY) world->changeCamera(-angle, 0.0f, 0.0f);*/ world->changeCamera((posY - mousePosY)*yAngle, (posX - mousePosX)*xAngle, 0.0f); } mousePosX = posX; mousePosY = posY; } break; case WM_MOUSEWHEEL: { int x = GET_Y_LPARAM(wParam); if (x > 0) world->changeCamera(0.0f, 0.0f, -20.0f); if (x < 0) world->changeCamera(0.0f, 0.0f, 20.0f); } break; // A menu command case WM_COMMAND: { switch (LOWORD(wParam)) { // Exit the program case ID_FILE_EXIT: DestroyWindow(hWnd); break; // Display the about box case ID_HELP_ABOUT: DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_ABOUT), hWnd, (DLGPROC)AboutDlgProc); break; } } break; default: // Passes it on if unproccessed return (DefWindowProc(hWnd, message, wParam, lParam)); } return (0L); }