当前位置: 首页>>代码示例>>C++>>正文


C++ DrawBox函数代码示例

本文整理汇总了C++中DrawBox函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawBox函数的具体用法?C++ DrawBox怎么用?C++ DrawBox使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DrawBox函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DisplayFunc

/*
 * The callback function when a redraw has been requested
 */
void DisplayFunc()
{
	// Create the screen for both colour and depth values
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// The modelview matrix is pushed before drawing the scene
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	// Set up the trackball transformation
	float rotmatrix[4][4];
	build_rotmatrix(rotmatrix, quat);
	glMultMatrixf(&rotmatrix[0][0]);

	// Draw the scene from the display list
	if (current_display == DISPLAY_TEAPOT)
		glCallList(teapot_list);
	else {


		/*
		 *
		 * Draw your hierarchical tin robot model here
		 *
		 */

		glColor3f(0.0, 0.0, 1.0);
		DrawBox(400, 400, 400);


	}

	glPopMatrix();

	// Redraw the screen by swapping the buffer
	glutSwapBuffers();
}
开发者ID:qwertyman2009,项目名称:OpenGL_Android_robot,代码行数:40,代码来源:a2.cpp

示例2: SetDrawBlendMode

Scene* Menu::Update(){
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
	DrawBox(0, 0, MainLoop::WINDOW_WIDTH, MainLoop::WINDOW_HEIGHT, GetColor(0, 0, 0), TRUE);
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
	
	int menuLeft = MainLoop::WINDOW_WIDTH / 2 - GetDrawStringWidth("[X-KEY]:START", strlen("[X-KEY]:START")) / 2;

	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2 - 50, GetColor(255, 255, 255), mFontHandle, "[Z-KEY]:RESUME");
	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2, GetColor(255, 255, 255), mFontHandle, "[X-KEY]:RESTART");
	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2 + 50, GetColor(255, 255, 255), mFontHandle, "[C-KEY]:TITLE");

	//シーケンス処理
	Scene* next = this;
	if (CheckHitKey(KEY_INPUT_Z) != 0){
		next = new Play(mParent);
	}
	else if (CheckHitKey(KEY_INPUT_X) != 0){
		next = new OnePlayGame();
	}
	else if (CheckHitKey(KEY_INPUT_C) != 0){
		next = new Title();
	}
	return next;
}
开发者ID:TetsuyaNegishi,项目名称:Billiards,代码行数:24,代码来源:Menu.cpp

示例3: switch

Scene* SceneTitleInit::Update()
{
	int t;
	switch (state) {
	case 0:
		if (Bright::Instance()->ChangeBright(255, 30)) ++state;
		break;
	case 1: // データロード
		t = GetNowCount();
		Image::Instance()->Init("data/image/image.csv");
		Sound::Instance()->Init();
		//ショットデータ読み込み
		PlayerBullet::Load();
		//セーブデータ読み込み
		Save::Instance()->LoadSaveData();
		//フォントデータ読み込み
		ChangeFont("MS ゴシック");
		SetFontThickness(3);
		SetFontSize(16);
		ChangeFontType(1);
		fonts.push_back(std::make_shared<Font>("梅PゴシックC5", 24, 4, "data/font/ume-pgc5.ttf"));
		fonts.push_back(std::make_shared<Font>("梅PゴシックC5", 16, 3, "data/font/ume-pgc5.ttf", DX_FONTTYPE_ANTIALIASING_EDGE));
		//ロードにかかった時間
		t = GetNowCount() - t;
		// ロードが1000ms以下なら1000msまで待機
		if (t < 1000) Sleep(1000 - t);
		++state;
		break;
	case 2:
		if (Bright::Instance()->ChangeBright(0, 30)) return new SceneTitle();
	}
	DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0xffffff, TRUE);
	DrawGraph(60, 40, images[0], TRUE);

	return this;
}
开发者ID:masa0345,项目名称:sds,代码行数:36,代码来源:Scene.cpp

示例4: ClientWndProc

//--------------------------------------------------------------------------
//
//  Client window procedure.
//
// --------------------------------------------------------------------------
MRESULT EXPENTRY ClientWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{

   switch (msg)
   {

     // When the left mouse button is clicked, run the sample functions.

     case WM_BUTTON1DOWN:
     {
       DrawBox( hwnd );
       DrawTransformedBox( hwnd );
       RotateBox( hwnd );
       DrawShearedBox( hwnd );
     }
     break;

     case WM_PAINT:
     {
       HPS   hpsPaint ;
       RECTL rectl;

       hpsPaint = WinBeginPaint( hwnd, (HPS)0, &rectl );

       WinFillRect( hpsPaint, &rectl, SYSCLR_WINDOW );

       WinEndPaint( hpsPaint );
     }
     break;

     default:
     {
       return( WinDefWindowProc( hwnd, msg, mp1, mp2 )) ;
     }
   }
}
开发者ID:OS2World,项目名称:DEV-SAMPLES-The-IBM-Developer-Connection-Release-12,代码行数:41,代码来源:xform.c

示例5: DrawBox

void CShop::Draw()
{
	// This draws the first menu to the player to have them select if they
	// want to buy or sell items.  First, draw menu and it's buy/sell buttons
	DrawBox(kShopPromptWidth, kShopPromptHeight, kMenuX, kMenuY);

	DrawString("Buy", 3, kMenuX + 3, kMenuY + 2, NULL,  ShowBuyMenu);
	DrawString("Sell", 4, kMenuX + 12, kMenuY + 2, NULL,  ShowSellMenu);

	// Loop until the user escapes or clicks on one of the buttons
	while(!EscapePressed() && !ChoiceMade())
	{
		HandleInput();
	}

	// Reset the flag that says we hit escape and redraw the map
	ResetEscapeFlag();
	g_Map.SetDrawFlag(true);
	g_Map.Draw();

	// If there was a button clicked, let's go to it's associated function
	if(ChoiceMade())
		ChoiceMade()->m_function();
}
开发者ID:88er,项目名称:tutorials,代码行数:24,代码来源:ShopKeeper.cpp

示例6: disp_frame

void disp_frame()
{
	static int draw_x = 0;
	static unsigned int e = GetNowCount();
	int y, cell_x, cell_y;
	int r,g,b;
	char key[256];	// 入力状態を格納する
	

	cell_x = W_CELL*draw_x;
	for (y=0; y<H_SIZE; y++)
	{
		pat2rgb(pat[y][draw_x], &r, &g, &b);

		cell_y = H_CELL*y;
		//DrawBox(cell_x, cell_y, cell_x+W_CELL, cell_y+H_CELL, GetColor(r,g,b), 1);	// 隙間なしバージョン
		DrawBox(cell_x, cell_y, cell_x+W_CELL-1, cell_y+H_CELL-1, GetColor(r,g,b), 1);	// 隙間ありバージョン
	}

	// 実行するたびに次の列を描画する
	draw_x = (draw_x+1) % H_SIZE;


	//1/60秒間隔でループ。
	//while (GetNowCount() - e < (1.0/60*1000)) { Sleep(10); }
	//e = GetNowCount();

	// 入力信号を取得
	GetHitKeyStateAll(key);
	U_BTN = key[KEY_INPUT_UP];
	D_BTN = key[KEY_INPUT_DOWN];
	R_BTN = key[KEY_INPUT_RIGHT];
	L_BTN = key[KEY_INPUT_LEFT];
	BTN1  = key[KEY_INPUT_Z];
	BTN2  = key[KEY_INPUT_X];
}
开发者ID:fujiruki,项目名称:Nnct-Pic-Game,代码行数:36,代码来源:PicBaseSystem.cpp

示例7: SetDrawBlendMode

void Options::Draw()
{
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 120); //透過
	DrawBox(0, 0, 640, 480, black, TRUE); //明るい背景を暗くする
	if (!keyconfigflag)
	{
		DrawBox(0, 25, 100, 55, yellow, TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す
		DrawExtendString(20, 30, 1.5, 1.5, "Option", black);
		DrawBox(0, choosenow * 25 + 65, 640, (choosenow + 1) * 25 + 65, yellow, TRUE);
		for (int i = 0; i < option_max; i++)
		{
			DrawFormatString(200 - GetDrawFormatStringWidth("%s", option_list[i]), i * 25 + 70, (choosenow == i ? black : white), "%s", option_list[i]);
		}
		DrawString(400, (option_max - 2) * 25 + 70, "設定", (choosenow == option_max - 2 ? black : white));
	}
	else
	{
		DrawBox(0, 25, 200, 55, yellow, TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す
		DrawExtendString(20, 30, 1.5, 1.5, "KeyConfig", black);
		DrawString(222, 35, "キーボード", white);
		DrawString(422, 35, "ゲームパッド", white);


		DrawBox(0, choosenow_keyconfig * 20 + 58, 640, (choosenow_keyconfig + 1) * 20 + 58, (keyconfingflag?black:yellow), TRUE);
		for (int i = 0; i < key_name_max - 1; i++)
		{
			DrawFormatString(160, i * 20 + 60, (choosenow_keyconfig == i ? black : white),"%s",key_name_list[i]);
			DrawKey(260, i * 20 + 60, key_deside_temp[i]);
		}
		DrawString(60, (key_name_max - 1) * 20 + 60, "設定を反映して戻る", (choosenow_keyconfig == 8 ? black : white));
	}
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 144); //透過
	DrawBox(0, 0, 640, 20, blue, TRUE); //説明欄
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す

	DrawFormatString(22, 2, white, "%s", option_explanation[choosenow], TRUE); //説明しよう
}
开发者ID:emelenthia,项目名称:THBlock,代码行数:39,代码来源:Options.cpp

示例8: DrawCube

void DrawCube(CPUTRenderParameters &renderParams, float3 position, float size, CPUTColor4 color)
{
	DrawBox(renderParams, position, float3(size, size, size), color);
}
开发者ID:GameTechDev,项目名称:FaceMapping2,代码行数:4,代码来源:SampleUtil.cpp

示例9: reset

void reset()
{
    receivedX = 0;
    receivedY = 0;

    memset(videoBuffer, 0, 1024);

    if(level == 0) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 1) {
        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 2) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(64, 0, 64, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 32;
        } else {
            playerX = 96;
        }
    }
    if(level == 3) {
        DrawLine(0, 0, 127, 0, videoBuffer, BLACK);
        DrawLine(0, 63, 127, 63, videoBuffer, BLACK);
        DrawLine(64, 0, 64, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 4) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(0, 23, 57, 23, videoBuffer, BLACK);
        DrawLine(0, 40, 57, 40, videoBuffer, BLACK);
        DrawLine(70, 23, 127, 23, videoBuffer, BLACK);
        DrawLine(70, 40, 127, 40, videoBuffer, BLACK);

        playerY = 32;
        if(isHost) {
            direction = 1;
            playerX = 5;
        } else {
            direction = 3;
            playerX = 122;
        }
    }
    if(level == 5) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawBox(59, 5, 68, 58, videoBuffer, BLACK);
        DrawLine(8, 45, 30, 45, videoBuffer, BLACK);
        DrawLine(30, 45, 30, 63, videoBuffer, BLACK);
        DrawLine(119, 45, 97, 45, videoBuffer, BLACK);
        DrawLine(97, 45, 97, 63, videoBuffer, BLACK);

        playerY = 52;
        if(isHost) {
            direction = 3;
            playerX = 21;
        } else {
            direction = 1;
            playerX = 106;
        }
    }
}
开发者ID:Rojetto,项目名称:MTRON,代码行数:86,代码来源:MTRON.c

示例10: AddIn_main

int AddIn_main(int isAppli, unsigned short OptionNum)
{
    int collided = 0;
    unsigned char answer;

    Bdisp_AllClr_DDVRAM();

    Init_SerialPort();
    Start_SerialPort();

    if(connect() == 0) {
        isHost = 1;
    }

    while(1) {
        startScreen();

        memset(videoBuffer, 0, 1024);
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawBox(48, 27, 79, 37, videoBuffer, BLACK);
        CoolText(51, 29, FONT_FIVE, "Ready?", videoBuffer);
        DrawAll(videoBuffer);

        Sleep(1000);

        SerialTransmit(READY);
        while(SerialReceive() != READY) {
            ;
        }

        reset();

        while(1) {
            answer = SerialReceive();

            if(answer == CRASH) {
                score++;
                wonLast = ME;
                break;
            }
            if(answer == EXIT) {
                Reset_Calc();
            }
            if(answer == COORDS) {
                receivedX = SerialReceive();
                receivedY = SerialReceive();

                setBit(videoBuffer, 128, receivedX, receivedY, 1);
            }

            checkKeys();
            move();

            collided = getBit(videoBuffer, 128, playerX, playerY);
            if(collided) {
                otherScore++;
                wonLast = OTHER;
                SerialTransmit(CRASH);
                break;
            }

            setBit(videoBuffer, 128, playerX, playerY, 1);

            SerialTransmit(COORDS);
            SerialTransmit(playerX);
            SerialTransmit(playerY);

            DrawAll(videoBuffer);

            Sleep(delays[speed]);
        }
    }

    return 1;
}
开发者ID:Rojetto,项目名称:MTRON,代码行数:75,代码来源:MTRON.c

示例11: startScreen

void startScreen()
{
    unsigned char answer;
    char scoreText[4], otherScoreText[4], statusText[22], speedText[22], levelText[22];
    int isReady = 0, is1Pressed = 0, is2Pressed = 0, is3Pressed = 0, isLeftPressed = 0, isRightPressed = 0;

    while(!isReady) {
        if(isHost) {
            if(isConnected) {
                strcpy(statusText, "Hosting");
            } else {
                strcpy(statusText, "Waiting");
            }
        } else {
            strcpy(statusText, "Connected");
        }

        sprintf(scoreText, "%d", score);
        sprintf(otherScoreText, "%d", otherScore);
        sprintf(speedText, "SPEED:  %d", speed + 1);
        sprintf(levelText, "LEVEL:  %d", level + 1);

        memset(videoBuffer, 0, 1024);

        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(0, 8, 127, 8, videoBuffer, BLACK);
        DrawLine(0, 16, 127, 16, videoBuffer, BLACK);
        DrawLine(0, 24, 127, 24, videoBuffer, BLACK);
        DrawLine(64, 16, 64, 24, videoBuffer, BLACK);
        DrawLine(0, 32, 127, 32, videoBuffer, BLACK);
        DrawLine(0, 40, 127, 40, videoBuffer, BLACK);

        CoolText(32, 1, FONT_FIVE, "MTRON by rojet601", videoBuffer);
        CoolText(48, 9, FONT_FIVE, statusText, videoBuffer);
        CoolText(27, 17, FONT_FIVE, scoreText, videoBuffer);
        CoolText(91, 17, FONT_FIVE, otherScoreText, videoBuffer);
        if(wonLast == ME) {
            CoolText(48, 25, FONT_FIVE, "You won", videoBuffer);
        }
        if(wonLast == OTHER) {
            CoolText(48, 25, FONT_FIVE, "You lost", videoBuffer);   
        }
        if(isHost) {
            CoolText(2, 33, FONT_FIVE, speedText, videoBuffer);
            CoolText(65, 33, FONT_FIVE, levelText, videoBuffer);
            CoolText(2, 52, FONT_FIVE, "[1]-[3] SPEED", videoBuffer);
            CoolText(65, 52, FONT_FIVE, "         LEVEL", videoBuffer);
            DrawLine(65, 55, 71, 55, videoBuffer, BLACK);
            DrawLine(66, 55, 68, 53, videoBuffer, BLACK);
            DrawLine(66, 55, 68, 57, videoBuffer, BLACK);

            DrawLine(73, 55, 79, 55, videoBuffer, BLACK);
            DrawLine(79, 55, 77, 53, videoBuffer, BLACK);
            DrawLine(79, 55, 77, 57, videoBuffer, BLACK);
            if(isConnected) {
                CoolText(2, 43, FONT_FIVE, "[SHIFT] START", videoBuffer);
            }
        } else {
            CoolText(2, 43, FONT_FIVE, "Only the host can change", videoBuffer);
            CoolText(2, 52, FONT_FIVE, "the settings", videoBuffer);
        }

        DrawAll(videoBuffer);

        if(IsKeyDown(KEY_CTRL_EXIT) || IsKeyDown(KEY_CTRL_MENU)) {
            SerialTransmit(EXIT);
            Stop_SerialPort();
            Reset_Calc();
        }

        answer = SerialReceive();

        if(answer == EXIT) {
            Stop_SerialPort();
            Reset_Calc();
        }
        if(answer == START) {
            Sleep(50);
            speed = SerialReceive();
            level = SerialReceive();
            isReady = 1;
        }

        if(isHost) {
            if(!isConnected) {
                if(answer == HELLO_HOST) {
                    SerialTransmit(HELLO_CLIENT);
                    isConnected = 1;
                }
            } else {
                if(IsKeyDown(KEY_CTRL_SHIFT)) {
                    SerialTransmit(START);
                    SerialTransmit(speed);
                    SerialTransmit(level);
                    Sleep(50);
                    isReady = 1;
                }
            }
            if(!IsKeyDown(KEY_CHAR_1)) {
                is1Pressed = 0;
//.........这里部分代码省略.........
开发者ID:Rojetto,项目名称:MTRON,代码行数:101,代码来源:MTRON.c

示例12: WinMain

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	ChangeWindowMode(TRUE);
	//SetMouseDispFlag(TRUE);
	SetDrawMode(DX_DRAWMODE_BILINEAR);
	SetScreenMemToVramFlag(FALSE);
	SetAlwaysRunFlag(TRUE);
	SetDrawScreen( DX_SCREEN_BACK);
	if(DxLib_Init()==-1)		// DXライブラリ初期化処理
	{
		return -1 ;			// エラーが起きたら直ちに終了
	}

	//デバック用にコンソールを出現させる
	/*
	AllocConsole();
	freopen("CONOUT$","w",stdout);
	freopen("CONIN$","r",stdin);z
	*/

	Mode gamemode=OPENING;
	AI_T ai[AI_NUM];
	Takara takara;
	int death[AI_NUM]={0};
	Tagger tagger[TAGGER_NUM];
	int tagger_num = 0;
	int STAGE[WIDTH][HEIGHT]={0};
	int round=0;
	int start=0;
	int end=0;
	int StartTime,TimeLimit;

	for(int i=0;i<AI_NUM;i++){
		ai[i].entry=1;
	}
	ai[0].entry=0;

	while(ProcessMessage()!=-1){
		int speed=0;
		switch(gamemode){
		case OPENING:
			start=intro(ai);
			if(start==1)gamemode=SETTING;
			break;
		case SETTING:
			takara.x=GetRand(WIDTH/2)+WIDTH/2-1;
			takara.y=GetRand(HEIGHT/2)+1;
			takara.drop=0;
			make_Stage(STAGE,takara);//マップ構成
			tagger_num = init_Tagger(tagger,STAGE);//鬼の初期化 //tagger_numは鬼の要素番号

			init_Ai(ai,STAGE);

			round++;
			TimeLimit=TIME_LIMIT*60*79;//ゲーム開始時の時刻に合わせる
			gamemode=RUNNING;

			break;
		case RUNNING:
			TimeLimit-=79;
			if(TimeLimit<0)TimeLimit=0;
			if(tagger[tagger_num].step==0){
				//tagger[tagger_num].act=next_Tagger(tagger[tagger_num],STAGE,ai);
				tagger[tagger_num].act=tagger[tagger_num].moveFunc(tagger[tagger_num].x,tagger[tagger_num].y,STAGE); //AIと一緒で、moveFunc使う
			}
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].step==0 && ai[i].entry==1){
					setview_Ai(&ai[i],STAGE);
					//ai[i].act=next_Ai(ai[i].view); //henteko : 下のmoveFunc()を使うためコメントアウト
					ai[i].act = ai[i].moveFunc(ai[i].view);
				}
			}
			if(TimeLimit>TIME_LIMIT*45*79)speed=0;
			else if(TimeLimit>TIME_LIMIT*30*79)speed=1;
			else if(TimeLimit>TIME_LIMIT*15*79)speed=1;
			else speed=3;
			update_Tagger(&tagger[tagger_num],STAGE,speed);
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].entry==1)
					update_Ai(&ai[i],STAGE,&takara);
			}
			update_stage(STAGE,ai,tagger[tagger_num],takara);
			
			ClearDrawScreen();
			draw(STAGE,ai,tagger[tagger_num],takara);
			DrawFormatString(30,30,GetColor(0,255,255),"ROUND%d",round);
			
			DrawFormatString(500,15,GetColor(0,255,0),"TIME %d",TimeLimit);
			
			if(1){
				for(int i=0;i<AI_NUM;i++){
					if(death_Ai(ai[i],tagger[tagger_num])==1 && ai[i].entry==1){
						death[i]++;
						DrawBox(0,230,640,260,GetColor(0,0,0),1);
						DrawBox(-1,230,642,260,GetColor(255,0,0),0);
						DrawFormatString(100,240,GetColor(255,0,0),"%sがつかまりました",ai[i].name);// 8/3 zero追記:AI捕獲の宣言をまとめた。
						init_Ai(&ai[i],STAGE);//元の場所に戻される
						TimeLimit-=1000;//時間ペナルティ
						/*WaitTimer(3000);
						if(round>=ROUND_MAX){
//.........这里部分代码省略.........
开发者ID:tsuro624,项目名称:2013teresAI,代码行数:101,代码来源:main.cpp

示例13: VecToFloatArray

// -----------------------------------------------------------
// Engine::FindNearest
// Finds the nearest intersection in a KdTree for a ray
// -----------------------------------------------------------
int KDTree::FindNearestToRay( Ray& vRay, Vec3 &tmin, Vec3 &tmax, RayIntersectCallback callback, Matrix4x4 * temp )
{
	static bool bOutput = false;
	float tnear = 0;
	float tfar = ( tmax - tmin ).Length();
	float t;
	int retval = 0;
	float D[3];
	float O[3];
	VecToFloatArray( vRay.m_Direction, D );
	VecToFloatArray( vRay.m_Origin, O );
	// We assume ray fits in extents
	// clip ray segment to box
	static AABB bbox;
	bbox.Set( tmin, tmax );
	if( !bbox.IntersectRay( vRay, tnear, tfar ) )
		return 0;
	if( tnear < 0 || 
		tfar < 0 || 
		tnear > tfar )
		return 0;
	// init stack
	int entrypoint = 0, exitpoint = 1;
	// init traversal
	KDTreeNode* farchild, *currnode;
	farchild = 0;
	currnode = m_Root;
	m_Stack[entrypoint].t = tnear;
	if (tnear > 0.0f) 
	{
		m_Stack[entrypoint].pb[0] = O[0] + D[0]*tnear;
		m_Stack[entrypoint].pb[1] = O[1] + D[1]*tnear;
		m_Stack[entrypoint].pb[2] = O[2] + D[2]*tnear;
	}
	else
	{
		m_Stack[entrypoint].pb[0] = O[0];
		m_Stack[entrypoint].pb[1] = O[1];
		m_Stack[entrypoint].pb[2] = O[2];
	}
	m_Stack[exitpoint].t = tfar;
	m_Stack[exitpoint].pb[0] = O[0] + D[0]*tfar;
	m_Stack[exitpoint].pb[1] = O[1] + D[1]*tfar;
	m_Stack[exitpoint].pb[2]= O[2] + D[2]*tfar;
	m_Stack[exitpoint].node = 0;
	int dim = -1;
	// traverse kd-tree
	char buf[1024];

	static int aa = 0;
	if( bOutput )
	{
		sprintf( buf, "tfar: %f, tnear: %f\n", tfar, tnear );
		OutputDebugString( buf );
		OutputVector( vRay.m_Origin, "Ray origin" );
		OutputVector( vRay.m_Direction, "Ray direction" );
		OutputVector( O, "Ray origin2" );
		OutputVector( D, "Ray direction2" );
		OutputVector( m_Stack[ entrypoint ].pb, "entry" );
		sprintf( buf, "exit far: %f\n", m_Stack[exitpoint].t );
		OutputDebugString( buf );
		OutputVector( m_Stack[ exitpoint ].pb, "exit" );
	}
	KDTreeNode * lastNode = 0;
	g_Boxes.clear();
	vector< KDTreeNode * > nodesToCheck;
	while(currnode)
	{
		if( aa < 1 )
			DrawBox( currnode->bounds.m_Bounds[0], currnode->bounds.m_Bounds[1], temp );
		//Is not a leaf?
		while( currnode->pntidx < 0 )
		{		
			lastNode = currnode;
			dim = (dim + 1) % ndim;
			if( m_Stack[entrypoint].pb[dim] <= currnode->key )
			{
				if( m_Stack[exitpoint].pb[dim] <= currnode->key )
				{
					currnode = m_Root + currnode->leftIdx;
					continue;
				}
				farchild = m_Root + currnode->rightIdx; // GetRight();
				currnode = m_Root + currnode->leftIdx;
			}
			else 
			{
				if (m_Stack[exitpoint].pb[dim] > currnode->key)
				{
					currnode = m_Root + currnode->rightIdx;
					continue;
				}
				farchild = m_Root + currnode->leftIdx;
				currnode = m_Root + currnode->rightIdx; // GetRight();
			}
			
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:KDTree.cpp

示例14: DrawBox

void csGraphics2D::Clear(int color)
{
  DrawBox (0, 0, vpWidth, vpHeight, color);
}
开发者ID:crystalspace,项目名称:CS,代码行数:4,代码来源:graph2d.cpp

示例15: server_main

void server_main(){
  graresource.initialize();
  static const int BLACK = GetColor(0, 0, 0);
  static const int WHITE = GetColor(255, 255, 255);
	ServerConnection server(PORT);
	server.startListen();
	while(server.size() < CLIENT_NUM){
		DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
		DrawFormatString(60, 60, WHITE, "access: %d", server.size());
		ScreenFlip();
		Sleep(10);
		server.action();
    // Windows 特有の面倒な処理をDXライブラリにやらせる
    // -1 が返ってきたらループを抜ける
    if( ProcessMessage() < 0 ) exit(1) ;

    // もしESCキーが押されていたらループから抜ける
    if( CheckHitKey( KEY_INPUT_ESCAPE ) ) exit(1);
	}
	server.endListen();
	DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
	DrawFormatString(60, 60, WHITE, "access: %d", server.size());
	DrawFormatString(60, 80, WHITE, "game start", server.size());
	ScreenFlip();
  Shooting shooting(CLIENT_NUM);
  // 移動ルーチン
	int fpsTimer = GetNowCount();
  while( 1 ){
		string serverMessage;
    // todo treat dead client
    //while(true){
    //  int lostNetWork = GetLostNetWork();
    //}

		for(int i = 0; i < server.size(); ++i){
      if(server.receive(i, serverMessage) >= 0){
        while(server.receive(i, serverMessage) >= 0);
        // receive succssessed
        shooting.setInput(i, serverMessage);
      }else{
        // receive failed
        shooting.clearInput(i);
      }
	  }
    shooting.action();

		// debug messages
		dxout << serverMessage << dxendl;

		vector<int> clientMessage = graresource.getMessages();

		DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
		DrawFormatString(60, 60, WHITE, "access: %d", server.size());
		DrawFormatString(60, 80, WHITE, "game start", server.size());
		//DrawFormatString(60, 100, WHITE, clientMessage.c_str());
		ScreenFlip();

		server.send(clientMessage);
	  graresource.clear();
	  int term;
	  term = GetNowCount()-fpsTimer;
	  if(16-term>0){
			Sleep(16-term);
		}
	  fpsTimer = GetNowCount();

		if (!shooting.isValid()) break;
    // Windows 特有の面倒な処理をDXライブラリにやらせる
    // -1 が返ってきたらループを抜ける
    if( ProcessMessage() < 0 ) break ;

    // もしESCキーが押されていたらループから抜ける
    if( CheckHitKey( KEY_INPUT_ESCAPE ) ) break;
  }
}
开发者ID:nakao5924,项目名称:projectShooting2011,代码行数:75,代码来源:main.cpp


注:本文中的DrawBox函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。