Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Window.hpp>
- #include <SFML/OpenGL.hpp>
- #include <gl\GLU.h>
- #include "SOIL.h";
- int texture[1];
- int LoadGLTextures()
- {
- texture[0] = SOIL_load_OGL_texture
- (
- "Crate.bmp",
- SOIL_LOAD_AUTO,
- SOIL_CREATE_NEW_ID,
- SOIL_FLAG_INVERT_Y
- );
- if(texture[0] == 0)
- return false;
- glBindTexture(GL_TEXTURE_2D, texture[0]);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
- return true;
- }
- int main()
- {
- sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
- window.setVerticalSyncEnabled(true);
- bool running = true;
- while (running)
- {
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- {
- running = false;
- }
- else if (event.type == sf::Event::Resized)
- {
- glViewport(0, 0, event.size.width, event.size.height);
- }
- }
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearDepth(1.f);
- glClearColor(0.f, 0.f, 0.f, 0.f);
- glEnable(GL_DEPTH_TEST);
- glDepthMask(GL_TRUE);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(90.f, 1.f, 1.f, 500.f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.f, 0.f, -200.f);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, texture[0]);
- glBegin(GL_QUADS);
- glVertex3f(-50.f, -50.f, -50.f);
- glVertex3f(-50.f, 50.f, -50.f);
- glVertex3f( 50.f, 50.f, -50.f);
- glVertex3f( 50.f, -50.f, -50.f);
- glVertex3f(-50.f, -50.f, 50.f);
- glVertex3f(-50.f, 50.f, 50.f);
- glVertex3f( 50.f, 50.f, 50.f);
- glVertex3f( 50.f, -50.f, 50.f);
- glVertex3f(-50.f, -50.f, -50.f);
- glVertex3f(-50.f, 50.f, -50.f);
- glVertex3f(-50.f, 50.f, 50.f);
- glVertex3f(-50.f, -50.f, 50.f);
- glVertex3f(50.f, -50.f, -50.f);
- glVertex3f(50.f, 50.f, -50.f);
- glVertex3f(50.f, 50.f, 50.f);
- glVertex3f(50.f, -50.f, 50.f);
- glVertex3f(-50.f, -50.f, 50.f);
- glVertex3f(-50.f, -50.f, -50.f);
- glVertex3f( 50.f, -50.f, -50.f);
- glVertex3f( 50.f, -50.f, 50.f);
- glVertex3f(-50.f, 50.f, 50.f);
- glVertex3f(-50.f, 50.f, -50.f);
- glVertex3f( 50.f, 50.f, -50.f);
- glVertex3f( 50.f, 50.f, 50.f);
- glEnd();
- window.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement