int LoadGLTextures() // Load Bitmaps And Convert To Textures { // Start Of User Initialization if (!NeHeLoadBitmap("Data/NeHe_gray.bmp", texture[0])) // Load The Bitmap return FALSE; // Return False If Loading Failed return TRUE; // Return The Status }
int InitGL(GLvoid) // All Setup For OpenGL Goes Here { FILE *allBMP; allBMP = fopen("allBMP.txt", "rt"); int numBMP = 0; char oneline[255]; readstr(allBMP,oneline); sscanf(oneline, "NUMOFBMP %d\n", &numBMP); //Get the number of filenames in the txt file //Dynamically assigning a 2D array of how ever many strings there are needed with 50 characters per string // Texture 1D array is also created char **BMPnames = (char **)malloc(numBMP*sizeof(*BMPnames)); texture = (GLuint *)malloc(numBMP*sizeof(GLuint)); for (int i = 0; i < numBMP; i++) { BMPnames[i] = (char *)malloc(50*sizeof(*BMPnames[0])); } // Put the image file names into the created 2D array for (int counter = 0; counter < numBMP; counter++) { readstr(allBMP,oneline); sscanf(oneline, "%s\n", BMPnames[counter]); } for (int counter = 0; counter < numBMP; counter++) { if (!NeHeLoadBitmap(BMPnames[counter], texture[counter])) // Load The Bitmap return FALSE; } glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Set The Blending Function For Translucency glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // This Will Clear The Background Color To Black glClearDepth(1.0); // Enables Clearing Of The Depth Buffer glDepthFunc(GL_LESS); // The Type Of Depth Test To Do glEnable(GL_DEPTH_TEST); // Enables Depth Testing glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations SetupWorld(); BuildFont(); //CoInitialize(0); //IPlatformCommand *m_platform; //HRESULT hResult = CoCreateInstance(CLSID_CPlatformCommand, NULL, CLSCTX_LOCAL_SERVER, IID_IPlatformCommand, (LPVOID*)&m_platform); ::CoInitialize(NULL); //// Create an instance of the Word application and obtain the //// pointer to the application's IDispatch interface. //CLSID clsid; //HRESULT hr; //IUnknown* pUnk; //CLSIDFromProgID(L"Word.Application",&clsid); //hr = ::CoCreateInstance( clsid, NULL, CLSCTX_SERVER,IID_IUnknown, (void**) &pUnk); return TRUE; // Initialization Went OK }
bool LoadGLTextures() { glGenTextures(3, &texture[0]); if (!NeHeLoadBitmap("Data/Crate.bmp", texture[0], GL_NEAREST, GL_NEAREST)) // Jump To Texture Loading Routine ( NEW ) { return FALSE; // If Texture Didn't Load Return FALSE ( NEW ) } if (!NeHeLoadBitmap("Data/Crate.bmp", texture[1], GL_LINEAR, GL_LINEAR)) // Jump To Texture Loading Routine ( NEW ) { return FALSE; // If Texture Didn't Load Return FALSE ( NEW ) } if (!NeHeLoadBitmap("Data/Crate.bmp", texture[2], GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST)) // Jump To Texture Loading Routine ( NEW ) { return FALSE; // If Texture Didn't Load Return FALSE ( NEW ) } return true; }
int InitGL(GLvoid) // All Setup For OpenGL Goes Here { glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.05f, 0.05f, 0.05f, 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 initBezier(); // Initialize the Bezier's control grid NeHeLoadBitmap("../../data/NeHe.bmp",mybezier.texture); // Load the texture mybezier.dlBPatch = genBezier(mybezier, divs); // Generate the patch return TRUE; // Initialization Went OK }
GLuint TextureMan::Get(string id) { if (textures.find(id) == textures.end() && toLoad.find(id) != toLoad.end()) { string tex = MODELSPATH + toLoad[id] + TEXEXT; cout << "\t" << tex << "..."; GLuint texId; bool success = NeHeLoadBitmap(LPTSTR(tex.c_str()), texId); if(!success) { cout << "Unsuccessful." << endl; return -1; } TextureMan::GetInstance()->Add(id, texId); cout << "DONE." << endl; } return textures[id]; }
void ObjectMan::LoadTexture(string id, string name) { string tex = MODELSPATH + name + TEXEXT; cout << "\t" << tex << "..."; GLuint texId; if (TextureMan::GetInstance()->Get(id) != 0) { cout << "Previously loaded." << endl; return; } bool success = NeHeLoadBitmap(LPTSTR(tex.c_str()), texId); if(!success) { cout << "Unsuccessful." << endl; return; } TextureMan::GetInstance()->Add(id, texId); cout << "DONE." << endl; }