glSpline/src/scene.cpp
2018-10-09 23:29:30 +02:00

60 lines
1.2 KiB
C++

#include "scene.h"
#include <iostream>
Scene::Scene(int width, int height, MainWindow* w) : _width(width), _height(height), _w(w), _drawfill(true) {
glEnable(GL_DEPTH_TEST);
glViewport(0, 0, width, height);
glPointSize(5.0f);
_drawfill = 2;
}
Scene::~Scene() {
}
void Scene::resize(int width, int height) {
_width = width;
_height = height;
glViewport(0, 0, width, height);
}
void Scene::draw() {
glClearColor(0.2f, 0.3f, 0.3f, 1.0f); // Gris foncé
glClear(GL_COLOR_BUFFER_BIT);
// Activer ou non le back face culling
if (_w->culling)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
// Mode de rendu: sommets, arêtes ou faces
switch(_drawfill) {
case 0: glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); break;
case 1: glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); break;
case 2: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); break;
}
}
void Scene::mouseclick(int , float , float ) {
}
void Scene::mousemove(float , float ) {
}
void Scene::keyboardmove(int , double ) {
}
bool Scene::keyboard(unsigned char ) {
return false;
}
void Scene::toggledrawmode() {
_drawfill = (_drawfill + 1) % 3;
}