more infrastructure
git-svn-id: svn://anubis/misc/sierpinski-gtk@247 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
2b5692498c
commit
04460dd52d
@ -16,13 +16,38 @@ SierpinskiDA::SierpinskiDA(const Glib::RefPtr<const Gdk::GL::Config> & config)
|
|||||||
| Gdk::SCROLL_MASK);
|
| Gdk::SCROLL_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SierpinskiDA::draw()
|
void SierpinskiDA::regenerate(int npts)
|
||||||
|
{
|
||||||
|
gl_begin();
|
||||||
|
glNewList(m_dl, GL_COMPILE);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex3f(1, 0, 1);
|
||||||
|
glVertex3f(-1, 0, 1);
|
||||||
|
glVertex3f(-1, 0, -1);
|
||||||
|
glVertex3f(1, 0, -1);
|
||||||
|
glEnd();
|
||||||
|
glEndList();
|
||||||
|
gl_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SierpinskiDA::gl_begin()
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
return glwindow->gl_begin(get_gl_context());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SierpinskiDA::gl_end()
|
||||||
|
{
|
||||||
|
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||||
|
glwindow->gl_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SierpinskiDA::draw()
|
||||||
|
{
|
||||||
|
if (!gl_begin())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glClearColor(0.1, 0.6, 1.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@ -32,11 +57,14 @@ bool SierpinskiDA::draw()
|
|||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0, 0, 1);
|
0, 0, 1);
|
||||||
|
|
||||||
if (glwindow->is_double_buffered())
|
glCallList(m_dl);
|
||||||
glwindow->swap_buffers();
|
|
||||||
|
if (get_gl_window()->is_double_buffered())
|
||||||
|
get_gl_window()->swap_buffers();
|
||||||
else
|
else
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
|
gl_end();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,15 +93,15 @@ void SierpinskiDA::on_realize()
|
|||||||
{
|
{
|
||||||
Gtk::GL::DrawingArea::on_realize();
|
Gtk::GL::DrawingArea::on_realize();
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
if (gl_begin())
|
||||||
glwindow->get_window()->set_cursor(Gdk::Cursor(Gdk::CROSSHAIR));
|
|
||||||
|
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glViewport(0, 0, get_width(), get_height());
|
glViewport(0, 0, get_width(), get_height());
|
||||||
|
m_dl = glGenLists(1);
|
||||||
|
|
||||||
glwindow->gl_end();
|
gl_end();
|
||||||
|
|
||||||
|
regenerate(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,14 +109,12 @@ void SierpinskiDA::on_realize()
|
|||||||
*/
|
*/
|
||||||
bool SierpinskiDA::on_configure_event(GdkEventConfigure * event)
|
bool SierpinskiDA::on_configure_event(GdkEventConfigure * event)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
if (gl_begin())
|
||||||
|
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glViewport(0, 0, get_width(), get_height());
|
glViewport(0, 0, get_width(), get_height());
|
||||||
|
|
||||||
glwindow->gl_end();
|
gl_end();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,18 @@ class SierpinskiDA : public Gtk::GL::DrawingArea
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SierpinskiDA(const Glib::RefPtr<const Gdk::GL::Config> & config);
|
SierpinskiDA(const Glib::RefPtr<const Gdk::GL::Config> & config);
|
||||||
|
void regenerate(int npts);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_x, m_y;
|
int m_x, m_y;
|
||||||
|
int m_dl;
|
||||||
|
|
||||||
virtual bool draw();
|
virtual bool draw();
|
||||||
virtual void on_realize();
|
virtual void on_realize();
|
||||||
virtual bool on_configure_event(GdkEventConfigure * event);
|
virtual bool on_configure_event(GdkEventConfigure * event);
|
||||||
virtual bool on_expose_event(GdkEventExpose * event);
|
virtual bool on_expose_event(GdkEventExpose * event);
|
||||||
|
bool gl_begin();
|
||||||
|
void gl_end();
|
||||||
|
|
||||||
/* signal handlers */
|
/* signal handlers */
|
||||||
virtual bool on_motion_notify_event(GdkEventMotion * event);
|
virtual bool on_motion_notify_event(GdkEventMotion * event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user