Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setUpTexture()
- {
- unsigned char grass[512 * 512 * 3];
- FILE* f = fopen("grass.raw", "r");
- fread(grass, 512 * 512 * 3, 1, f);
- fclose(f);
- glEnable(GL_TEXTURE_2D);
- //Here 1 is the texture id
- glBindTexture(GL_TEXTURE_2D, 1);
- 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, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE,grass);
- glDisable(GL_TEXTURE_2D);
- }
- void grass()
- {
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,3);
- glBegin(GL_QUADS);
- glColor4f(1,1,1,0.1);
- glTexCoord2d(0,0); glVertex3f(2, 1, 2);
- glTexCoord2d(1,0); glVertex3f(-2, 1, 2);
- glTexCoord2d(1,1); glVertex3f(-2, 1, -2);
- glTexCoord2d(0,1); glVertex3f(2, 1, -2);
- glEnd();
- glDisable(GL_TEXTURE_2D);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement