Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <stdlib.h>
- #include "SOIL.h"
- #include "glut.h"
- #include "freeglut.h"
- #include "Obj.h"
- using namespace std;
- Obj* object = new Obj();
- GLuint texture[1];
- int w;
- int h;
- void handleResize(int w, int h) {
- glViewport(0, 0, w, h);
- gluPerspective(45.0,(double)w / (double)h,1.0,200.0);
- }
- void initRendering() {
- object->GetObj("cube.obj");
- glShadeModel(GL_LINEAR);
- glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
- glEnable(GL_DEPTH_TEST);
- }
- int LoadGLTextures()
- {
- texture[0] = SOIL_load_OGL_texture
- (
- "fehér.png",
- 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;
- }
- void handleKeypress(unsigned char key, int x, int y) {
- switch (key) {
- case 27:
- {
- exit(0);
- break;
- }
- }
- }
- void drawScene()
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glTranslatef(0.0,0.0,-5.0);
- object->DrawObj();
- glPopMatrix();
- glutSwapBuffers();
- glFlush();
- }
- int _tmain(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowSize(400, 400);
- glutCreateWindow("3D");
- initRendering();
- glutReshapeFunc(handleResize);
- glutDisplayFunc(drawScene);
- glutKeyboardFunc(handleKeypress);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement