Subversion Repositories gelsvn

Rev

Rev 561 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 561 Rev 563
Line 74... Line 74...
74
    //}
74
    //}
75
 
75
 
76
    glutPostRedisplay();
76
    glutPostRedisplay();
77
}
77
}
78
 
78
 
-
 
79
void vararg_test(const std::vector<std::string>& args)
-
 
80
{
-
 
81
    console.printf("Number of arguments: %i", int(args.size()));
-
 
82
    for (int i=0; i<int(args.size()); ++i)
-
 
83
        console.printf("  arg %i: %s", i, args[i].c_str());
-
 
84
}
-
 
85
 
79
int main( int argc, char *argv[] )
86
int main( int argc, char *argv[] )
80
{
87
{
81
  glutInit(&argc, argv);
88
  glutInit(&argc, argv);
82
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
89
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
83
  glutInitWindowSize(768, 768);
90
  glutInitWindowSize(768, 768);
Line 91... Line 98...
91
  console.printf("GLGraphics console test.");
98
  console.printf("GLGraphics console test.");
92
  console.newline();
99
  console.newline();
93
 
100
 
94
  //some examples of use:
101
  //some examples of use:
95
 
102
 
96
  console.reg_cmd("quit",
103
  console.reg_cmd0("quit",
97
      std::bind(&std::exit, EXIT_SUCCESS), "Exit application.");
104
      std::bind(&std::exit, EXIT_SUCCESS), "Exit application.");
98
 
105
 
99
  console.reg_cmd<int>("quit",
106
  console.reg_cmd1<int>("quit",
100
      std::bind(&std::exit, std::placeholders::_1),
107
      std::bind(&std::exit, std::placeholders::_1),
101
      "Exit application with specified exit code.");
108
      "Exit application with specified exit code.");
102
 
109
 
103
  console.reg_cmd("fullscreen", std::bind(&glutFullScreen), "Switch to fullscreen.");
110
  console.reg_cmd0("fullscreen", std::bind(&glutFullScreen), "Switch to fullscreen.");
104
 
111
 
105
#if 1
112
#if 1
106
  //needs lambda
113
  //needs lambda
107
  console.reg_cmd("window_pos", [&]{
114
  console.reg_cmd0("window_pos", [&]{
108
      console.printf("window_pos = %i %i", glutGet(GLUT_WINDOW_X),
115
      console.printf("window_pos = %i %i", glutGet(GLUT_WINDOW_X),
109
          glutGet(GLUT_WINDOW_Y));
116
          glutGet(GLUT_WINDOW_Y));
110
  }, "Show window position.");
117
  }, "Show window position.");
111
  console.reg_cmd("window_size", [&]{
118
  console.reg_cmd0("window_size", [&]{
112
      console.printf("window_size = %i %i", glutGet(GLUT_WINDOW_WIDTH),
119
      console.printf("window_size = %i %i", glutGet(GLUT_WINDOW_WIDTH),
113
          glutGet(GLUT_WINDOW_HEIGHT));
120
          glutGet(GLUT_WINDOW_HEIGHT));
114
  }, "Show window position.");
121
  }, "Show window position.");
115
#endif
122
#endif
116
 
123
 
117
  console.reg_cmd<int,int>("window_pos", std::bind(&glutPositionWindow,
124
  console.reg_cmd2<int,int>("window_pos", std::bind(&glutPositionWindow,
118
      std::placeholders::_1, std::placeholders::_2),
125
      std::placeholders::_1, std::placeholders::_2),
119
      "Set the window position.");
126
      "Set the window position.");
120
 
127
 
121
  console.executef("window_pos %i %i", 384, 256);
128
  console.executef("window_pos %i %i", 384, 256);
122
 
129
 
123
  console.reg_cmd<int,int>("window_size", std::bind(&glutReshapeWindow,
130
  console.reg_cmd2<int,int>("window_size", std::bind(&glutReshapeWindow,
124
      std::placeholders::_1, std::placeholders::_2),
131
      std::placeholders::_1, std::placeholders::_2),
125
      "Set the window size.");
132
      "Set the window size.");
126
 
133
 
-
 
134
  console.reg_cmdN("vararg_test", vararg_test, "Test of variable number of arguments.");
-
 
135
 
127
  using namespace GLGraphics;
136
  using namespace GLGraphics;
128
 
137
 
129
  Console::variable<int> test_int(42);
138
  Console::variable<int> test_int(42);
130
  test_int.reg(console, "test_int", "Some clever help string..");
139
  test_int.reg(console, "test_int", "Some clever help string..");
131
  console.execute("test_int");
140
  console.execute("test_int");