Guest User

Untitled

a guest
Feb 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // once
  2. mTex = new unsigned[256 * 256];
  3.  
  4. for(int i = 0; i < 256 * 256; ++i) {
  5. mTex[i] = 0xfca97531;
  6. }
  7.  
  8. glGenTextures(1, &mTexId);
  9. glBindTexture(GL_TEXTURE_2D, mTexId);
  10. // Note that we set height to 256 so it is a power of two
  11. // The lower 16 rows are unused
  12. glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_INT_8_8_8_8_REV, mTex);
  13. glEnable(GL_TEXTURE_2D);
  14.  
  15.  
  16.  
  17. // every frame
  18. glBindTexture(GL_TEXTURE_2D, mTexId);
  19.  
  20. glLoadIdentity();
  21.  
  22. glEnable(GL_TEXTURE_2D);
  23.  
  24. glBegin(GL_QUADS);
  25. glTexCoord2f(0.0f, 0.0f);
  26. glVertex3f(-1.0f, -1.0f, 0.0f);
  27. glTexCoord2f(-1.0f, 1.0f);
  28. glVertex3f(-1.0f, 1.0f, 0.0f);
  29. glTexCoord2f(1.0f, 1.0f);
  30. glVertex3f(1.0f, 1.0f, 0.0f);
  31. glTexCoord2f(1.0f, 0.0f);
  32. glVertex3f(1.0f, -1.0f, 0.0f);
  33. glEnd();
Add Comment
Please, Sign In to add comment