Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Header
- #include "GameSteps.h"
- class MainGameSteps : public GameSteps
- {
- public:
- explicit MainGameSteps();
- virtual void setup();
- virtual void processEvents(const SDL_Event& event);
- virtual void processLogics();
- virtual void draw() const;
- virtual bool ended();
- virtual void teardown();
- private:
- float degreesToRotateX;
- float degreesToRotateY;
- float degreesToRotateZ;
- float camX, camY, camZ;
- bool exit;
- };
- //Source
- //setup. Eu até checo se o zbuffer tá habilitado e ele sempre passa daqui
- void MainGameSteps::setup()
- {
- degreesToRotateX = degreesToRotateY = degreesToRotateZ = 0;
- camX = camY = 0;
- camZ = 5;
- glEnable(GL_BLEND);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_POLYGON_SMOOTH);
- // glDepthFunc(GL_LESS);
- glDepthRange(100,-100);
- glCullFace(GL_BACK);
- if(!glIsEnabled(GL_DEPTH_TEST))
- std::exit(-1);
- }
- //draw
- void MainGameSteps::draw() const
- {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity(); //Resetamos a projeção atual
- gluPerspective(60, GAMEWINDOW.getRatio(), 1, 15000);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- //Limpa a tela
- gluLookAt(camX, camY, camZ, 0, 0, 0, 0, 1, 0);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- // glClearDepth(1.0); // Tentei com valor de 1, de 0 e sem essa função
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- //Sun
- glColor3f(1, 1, .8f);
- drawCube();
- glPushMatrix();
- //Planet
- // glRotatef(degreesToRotateY, 0,1,0); // Achei q era aqui mas mesmo desabilitando ela ainda ainda mostra errado
- glColor3f(0, .2, .8f);
- glTranslatef(0, 0, -2);// Tentei tbm com z positivo, Sem sucesso
- glScalef(.4f, .4f, .4f);
- glRotatef(degreesToRotateY*2, 0,1,0);
- drawCube();
- glPopMatrix();
- glPopMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement