mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
GLTeapot: Use glGenLists() a bit to demonstrate that it works
This commit is contained in:
parent
720d21411b
commit
d42d984a2d
1 changed files with 11 additions and 5 deletions
|
@ -43,6 +43,15 @@ private:
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 1500);
|
glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 1500);
|
||||||
|
|
||||||
|
m_init_list = glGenLists(1);
|
||||||
|
glNewList(m_init_list, GL_COMPILE);
|
||||||
|
{
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearDepth(1.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
glEndList();
|
||||||
|
|
||||||
// Load the teapot
|
// Load the teapot
|
||||||
auto mesh_loader = adopt_own(*new WavefrontOBJLoader());
|
auto mesh_loader = adopt_own(*new WavefrontOBJLoader());
|
||||||
m_teapot = mesh_loader->load("/res/gl/teapot.obj");
|
m_teapot = mesh_loader->load("/res/gl/teapot.obj");
|
||||||
|
@ -57,6 +66,7 @@ private:
|
||||||
RefPtr<Mesh> m_teapot;
|
RefPtr<Mesh> m_teapot;
|
||||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||||
OwnPtr<GL::GLContext> m_context;
|
OwnPtr<GL::GLContext> m_context;
|
||||||
|
GLuint m_init_list { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
void GLContextWidget::paint_event(GUI::PaintEvent& event)
|
void GLContextWidget::paint_event(GUI::PaintEvent& event)
|
||||||
|
@ -69,13 +79,9 @@ void GLContextWidget::paint_event(GUI::PaintEvent& event)
|
||||||
void GLContextWidget::timer_event(Core::TimerEvent&)
|
void GLContextWidget::timer_event(Core::TimerEvent&)
|
||||||
{
|
{
|
||||||
static float angle = 0.0f;
|
static float angle = 0.0f;
|
||||||
|
glCallList(m_init_list);
|
||||||
|
|
||||||
angle -= 0.01f;
|
angle -= 0.01f;
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
glClearDepth(1.0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
auto matrix = FloatMatrix4x4::translate(FloatVector3(0, 0, -8.5))
|
auto matrix = FloatMatrix4x4::translate(FloatVector3(0, 0, -8.5))
|
||||||
* FloatMatrix4x4::rotate(FloatVector3(1, 0, 0), angle)
|
* FloatMatrix4x4::rotate(FloatVector3(1, 0, 0), angle)
|
||||||
* FloatMatrix4x4::rotate(FloatVector3(0, 1, 0), 0.0f)
|
* FloatMatrix4x4::rotate(FloatVector3(0, 1, 0), 0.0f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue