• R/O
  • SSH

qpilot: コミット

ソースコードおよびリソース管理。


コミットメタ情報

リビジョンf265d873eb3a4d04b267aeb34bd73c4b82620321 (tree)
日時2011-03-27 12:23:43
作者satofumi
コミッターsatofumi

ログメッセージ

added time sync prototype

変更サマリ

差分

diff -r 633b3720d04f -r f265d873eb3a .hgignore
--- a/.hgignore Sat Mar 26 16:27:42 2011 +0900
+++ b/.hgignore Sun Mar 27 12:23:43 2011 +0900
@@ -11,3 +11,5 @@
1111
1212 prototype/box2d_compile_test
1313 prototype/box2d_bounds_test
14+prototype/time_sync_server
15+prototype/time_sync_client
diff -r 633b3720d04f -r f265d873eb3a prototype/Makefile
--- a/prototype/Makefile Sat Mar 26 16:27:42 2011 +0900
+++ b/prototype/Makefile Sun Mar 27 12:23:43 2011 +0900
@@ -4,14 +4,16 @@
44
55 CC = $(CXX)
66 CXXFLAGS = -g -O0 -Wall -Werror -W $(INCLUDES) `sdl-config --cflags`
7-INCLUDES = -I$(LIB_DIR)/gui -I$(LIB_DIR)/geometry -I$(LIB_DIR)/common -I$(LIB_DIR)/lua -I$(LIB_DIR)/system
7+INCLUDES = -I$(LIB_DIR)/connection -I$(LIB_DIR)/gui -I$(LIB_DIR)/geometry -I$(LIB_DIR)/common -I$(LIB_DIR)/lua -I$(LIB_DIR)/system
88 LDFLAGS = -L/usr/X11/lib
9-LDLIBS = -lBox2D `sdl-config --libs` -lSDL_image -lGL -lboost_signals-mt
9+LDLIBS = -lBox2D `sdl-config --libs` -lSDL_net -lSDL_image -lSDL_ttf -lGL -lboost_signals-mt
1010
1111
1212 TARGET = \
1313 box2d_compile_test \
1414 box2d_bounds_test \
15+ time_sync_server \
16+ time_sync_client \
1517
1618
1719 all : $(TARGET)
@@ -24,7 +26,7 @@
2426
2527 .PHONY : all clean depend
2628 ######################################################################
27-REQUIRED_LIBS = $(LIB_DIR)/gui/gui.a $(LIB_DIR)/geometry/geometry.a $(LIB_DIR)/system/system.a $(LIB_DIR)/system/sdl/system_sdl.a
29+REQUIRED_LIBS = $(LIB_DIR)/connection/sdl/connection_sdl.a $(LIB_DIR)/gui/gui.a $(LIB_DIR)/geometry/geometry.a $(LIB_DIR)/system/system.a $(LIB_DIR)/system/sdl/system_sdl.a
2830 $(REQUIRED_LIBS) :
2931 cd $(@D)/ && $(MAKE) $(@F)
3032
@@ -46,3 +48,18 @@
4648 box2d_bounds_test.o: ../../../libs/system/CycleTimer.h
4749 box2d_bounds_test.o: ../../../libs/system/ticks.h
4850 box2d_bounds_test.o: ../../../libs/system/delay.h
51+time_sync_client.o: prototype_port.h
52+time_sync_server.o: prototype_port.h ../../../libs/connection/TcpipAccepter.h
53+time_sync_server.o: ../../../libs/gui/Screen.h ../../../libs/geometry/Rect.h
54+time_sync_server.o: ../../../libs/gui/LayerManager.h
55+time_sync_server.o: ../../../libs/gui/LayerInterface.h
56+time_sync_server.o: ../../../libs/geometry/Point.h ../../../libs/gui/Layer.h
57+time_sync_server.o: ../../../libs/gui/CallbackEvent.h
58+time_sync_server.o: ../../../libs/gui/Event.h ../../../libs/gui/Font.h
59+time_sync_server.o: ../../../libs/common/Color.h
60+time_sync_server.o: ../../../libs/gui/TextSurface.h
61+time_sync_server.o: ../../../libs/gui/Surface.h ../../../libs/gui/Label.h
62+time_sync_server.o: ../../../libs/gui/Component.h
63+time_sync_server.o: ../../../libs/gui/EventUtils.h
64+time_sync_server.o: ../../../libs/system/CycleTimer.h
65+time_sync_server.o: ../../../libs/system/ticks.h ../../../libs/system/delay.h
diff -r 633b3720d04f -r f265d873eb3a prototype/prototype_port.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prototype/prototype_port.h Sun Mar 27 12:23:43 2011 +0900
@@ -0,0 +1,18 @@
1+#ifndef SERVER_PORT_H
2+#define SERVER_PORT_H
3+
4+/*!
5+ \file
6+ \brief プロトタイプで使うポートの宣言
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+
14+enum {
15+ Prototype_port = 9816,
16+};
17+
18+#endif /* !SERVER_PORT_H */
diff -r 633b3720d04f -r f265d873eb3a prototype/time_sync_client.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prototype/time_sync_client.cpp Sun Mar 27 12:23:43 2011 +0900
@@ -0,0 +1,17 @@
1+/*!
2+ \example time_sync_client.cpp 時間の同期 (クライアント)
3+
4+ \author Satofumi KAMIMURA
5+
6+ $Id$
7+*/
8+
9+#include "prototype_port.h"
10+
11+
12+int main(void)
13+{
14+ // !!!
15+
16+ return 0;
17+}
diff -r 633b3720d04f -r f265d873eb3a prototype/time_sync_server.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prototype/time_sync_server.cpp Sun Mar 27 12:23:43 2011 +0900
@@ -0,0 +1,101 @@
1+/*!
2+ \example time_sync_client.cpp 時間の同期 (サーバ)
3+
4+ \author Satofumi KAMIMURA
5+
6+ $Id$
7+*/
8+
9+#include "prototype_port.h"
10+#include "TcpipAccepter.h"
11+#include "Screen.h"
12+#include "LayerManager.h"
13+#include "Layer.h"
14+#include "CallbackEvent.h"
15+#include "Font.h"
16+#include "TextSurface.h"
17+#include "Label.h"
18+#include "EventUtils.h"
19+#include "CycleTimer.h"
20+#include "ticks.h"
21+#include "delay.h"
22+#include <iostream>
23+
24+using namespace qrk;
25+using namespace std;
26+
27+
28+namespace
29+{
30+ enum {
31+ Font_size = 64,
32+ };
33+ const char* Font_file = "../game_resource/font.ttf";
34+}
35+
36+
37+int main(void)
38+{
39+ // サーバの起動
40+ TcpipAccepter server_accepter;
41+ if (!server_accepter.activate(Prototype_port)) {
42+ cout << "TcpipAccepter::activate(): " << server_accepter.what() << endl;
43+ return 1;
44+ }
45+
46+ // 画面の初期化
47+ Screen screen;
48+ if (!screen.show(SDL_OPENGL)) {
49+ cout << "Screen::show(): " << screen.what() << endl;
50+ return 1;
51+ }
52+
53+ // 画面のオブジェクト管理
54+ LayerManager layer_manager;
55+ Layer layer;
56+ layer_manager.push_front(&layer);
57+
58+ // 終了キーの登録
59+ CallbackEvent quit_event;
60+ setQuitEvent(&quit_event);
61+ layer_manager.insertEvent(&quit_event);
62+
63+ // 描画用のリソース初期化
64+ Font font(Font_file, Font_size);
65+ if (! font.resource()) {
66+ return 1;
67+ }
68+
69+ unsigned long first_ticks = ticks();
70+ CycleTimer cycle_timer;
71+
72+ bool quit = false;
73+ while (! quit) {
74+ // カウント処理
75+ long timestamp = ticks() - first_ticks;
76+
77+ // 入力情報の更新
78+ layer_manager.updateEvent();
79+ quit |= quit_event.isActive();
80+
81+ // 描画内容の更新
82+ enum { Buffer_size = 128 };
83+ char buffer[Buffer_size];
84+ snprintf(buffer, Buffer_size, "%ld", timestamp);
85+ TextSurface timestamp_surface(font, buffer);
86+ Label timestamp_label(timestamp_surface);
87+ layer.push_back(&timestamp_label);
88+
89+ screen.clear();
90+ layer_manager.draw();
91+ layer_manager.swap();
92+ delay(cycle_timer.waitMsec());
93+
94+ layer.remove(&timestamp_label);
95+
96+ // 接続しているクライアントに対するパケット処理
97+ // !!!
98+ }
99+
100+ return 0;
101+}
旧リポジトリブラウザで表示