SHARE
TWEET

Untitled

a guest Oct 12th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glew.h>
  2. #include <GL/glut.h>
  3. #include "soil-master/src/SOIL/SOIL.h"
  4.  
  5. GLuint texID;
  6. int rep=1;
  7.  
  8. void Display(void) {
  9.  
  10.     glClear(GL_COLOR_BUFFER_BIT);
  11.  
  12.     glPushMatrix();
  13.  
  14.     glBindTexture(GL_TEXTURE_2D, texID);
  15.  
  16.     glBegin(GL_QUADS);
  17.     glTexCoord2f(0.0f, 0.0f);           glVertex3f(200, 200, 0);
  18.     glTexCoord2f(rep, 0.0f);            glVertex3f(500, 200, 0);
  19.     glTexCoord2f(rep, rep);              glVertex3f(500, 500, 0);
  20.     glTexCoord2f(0.0f, rep);             glVertex3f(200, 500, 0);
  21.     glEnd();
  22.  
  23.     glPopMatrix();
  24.  
  25.     glFlush();
  26.  
  27. }
  28.  
  29.     int main(int argc, char** argr) {
  30.         glutInit(&argc, argr);
  31.  
  32.         glutInitWindowSize(600, 600);
  33.         glutInitWindowPosition(50, 50);
  34.  
  35.         glutCreateWindow("Texture 2D");
  36.         glutDisplayFunc(Display);
  37.  
  38.         glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  39.         glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
  40.  
  41.         glEnable(GL_TEXTURE_2D);
  42.  
  43.         gluOrtho2D(0,600,0,600);
  44.         texID = SOIL_load_OGL_texture("metal.bmp", SOIL_CREATE_NEW_ID, SOIL_LOAD_AUTO, SOIL_FLAG_MIPMAPS);
  45.         glutMainLoop();
  46.     }.
RAW Paste Data
Top