взял код загрузки из ранее рабо4ей программы вот так гружу и рисую... в любом виде/проекции вид один и тотже
| Код | GLuint loadTexture(Image* image) { GLuint textureId; glGenTextures(1, &textureId); //Make room for our texture glBindTexture(GL_TEXTURE_2D, textureId); //Tell OpenGL which texture to edit //Map the image to the texture glTexImage2D(GL_TEXTURE_2D, //Always GL_TEXTURE_2D 0, //0 for now GL_RGB, //Format OpenGL uses for image image->width, image->height, //Width and height 0, //The border of the image GL_RGB, //GL_RGB, because pixels are stored in RGB format GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored //as unsigned numbers image->pixels); //The actual pixel data return textureId; //Returns the id of the texture }
|
| Код | void drawLines(){
glEnable(GL_TEXTURE_2D);
for(int i=0; i<8; i++){ std::ostringstream oss; oss << i; std::string sscore(oss.str()); Image* image = loadBMP(sscore.append(".bmp").c_str()); glBindTexture(GL_TEXTURE_2D, loadTexture(image)); delete image; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glPushMatrix(); glTranslated(60+i*75, 0, 0);
glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0);//vasen ala nurkka glTexCoord2f(1.0f, 1.0f); glVertex2f(0, 30);//vasen ylä nurkka glTexCoord2f(1.0f, 0.0f); glVertex2f(30, 30);//oikea ylä nurkka glTexCoord2f(0.0f, 0.0f); glVertex2f(30, 0);//oikea raja glEnd();
glPopMatrix(); }
|
Добавлено через 3 минуты и 44 секунды http://ipicture.ru/ |