/*************************************************************************** * Copyright (C) 2008 by Eduard Grinke & Simon Martin Reich * * University of Goettingen, Germany * * * * This program 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 3 of the License, or * * (at your option) any later version. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * * * * * * OpenGL needs to be installed, more information can be found at: * * http://www.opengl.org/ * * * * Please remember to set the correct linker flag, in most cases * * something like: * * Project | Project Options | Configure Options | flags : -lglut * * * * * * * * https://sourceforge.net/projects/especially * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include using namespace std; int main(int argc, char *argv[]) { ESv_fps_color_red = 0.0f; ESv_fps_color_green = 0.0f; ESv_fps_color_blue = 0.0f; ESv_fps_pos_x =-28.0f; ESv_fps_pos_y = 20.0f; // uncomment or just use F2 // ESv_leavebuffer = true; ES_start( "ESpecially-Engine - Tutorial 3", false, true, 1.0f, 1.0f, 1.0f, argc, argv ); return EXIT_SUCCESS; } // Now this is our callback from Especially. All our drawing and calculations go here. It is called every frame. int ES_render() { // same stuff as in tutorial 1 & 2 ES_coorsys2d( 0.0f, 0.0f, -10.0f, 10.0f, -10.0f, 10.0f, true, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f ); ES_drawmass( sin(ESv_programtime/100)*3, cos(ESv_programtime/1000)*4, 2, 0.2, false, true, 0.0f, 0.5f, 1.0f ); // now we would like two nice graphs besides the main one showing only x- or y-position, the mass is now a triangle and a square. Hwo know why... ES_coorsys1d_y( 20.0f, 0.0f, -10.0f, 10.0f, false, 0.0f, 1.0f, 0.0f ); ES_drawmass( 20.0f, cos(ESv_programtime/1000)*4, 3, 1, true, false, 0.0f, 0.5f, 1.0f ); ES_coorsys1d_x( 0.0f, 20.0f, -10.0f, 10.0f, false, 0.0f, 1.0f, 0.0f ); ES_drawmass( sin(ESv_programtime/100)*3, 20.0f, 4, 1, true, false, 0.0f, 0.5f, 1.0f ); // last but not least we want the speed of the object drawn into a nice graph below the 2D coordinate system ES_drawbox( -50.0f, -12.0f, 100.0f, 0.2f, 1.0f, true, false, 0.0f, 0.0f, 0.0f ); float speed = sqrt((3*cos(ESv_programtime/100))*(3*cos(ESv_programtime/100)) + (-4*sin(ESv_programtime/1000)*(-4*sin(ESv_programtime/1000)))); ES_coorsys2d( -25.0f, -20.0f, -1.0f, 40.0f, -1.0f, 7.0f, true, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f ); ES_drawellipse( -25.0f + ESv_programtime/1000, -20.0f + speed, 0.05f, 0.05f, 0.5f, true, false, 0.0f, 0.5f, 1.0f ); // the data plot looks pretty awesomw, so why don't put the text next to the graph? ES_drawbox( 18.0f, -20.0f, 6.0f, 3.3f, 1.0f, false, false, 0.0f, 0.5f, 1.0f ); ES_write( "current speed:", 19.0f, -18.0f, 0.0f, 0.5f, 1.0f ); ES_writenr( speed, 19.0f, -19.0f, 0.0f, 0.5f, 1.0f ); cout << "current speed: " << speed << endl; return true; }