/* Copyright 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * SharpConstruct is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Brush.h" #include "Cursor.hh" #include "Mesh.h" #include #include #include using SharpConstruct::GInterface::Cursor; Cursor::Cursor() : list_( 0 ) {} void Cursor::Update() { static float prev_rad( 0 ); if( !list_ ) list_ = glGenLists( 1 ); const float radius( Mesh::CurrentBrush().Radius() ); if( prev_rad != radius ) { const unsigned SEGMENTS = 32; glNewList( list_, GL_COMPILE ); { glColor4f( 1, 0, 0, 0.5 ); glBegin( GL_LINE_LOOP ); { for( unsigned i = 0; i < SEGMENTS; ++i ) { const float angle( i * 2 * M_PI / SEGMENTS ); glVertex2f( radius * cos( angle ), radius * sin( angle ) ); } } glEnd(); } glEndList(); } prev_rad = radius; } void Cursor::Draw( unsigned x, unsigned y ) const { /*if( Contains( Mouse.Location() ) ) glTranslatef( Mouse.Location().X(), Mouse.Location().Y(), 0 ); else*/ glTranslatef( x, y, 0 ); glCallList( list_ ); }