일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 프로그램 개발
- 옥션해킹
- 보드게임
- MAME
- 영어단어게임
- 틀린그림 찾기
- 게임 개발
- 판매
- 맞고
- 틀린그림찾기
- 온라인게임
- 써치아이
- 홀뎀
- 프로그램 외주
- 티스토리 초대장
- 고스톱
- 맞고게임
- holdem
- 카일레라
- Mame32
- 윈윈전략
- 포커게임
- 윈윈
- 상호링크
- 영어단어
- 서치아이
- 포커
- 옥션소송
- 게임 외주
- 카일레라서버
- Today
- Total
kyuseo의 게임 프로그래밍
InversectRect 함수의 리턴값 오류 본문
개요.. |
Windows 2000 / XP에서 정상 작동되는 프로그램이 Windows 98 에서 정상 작동 되지 않는 현상을 발견하여, 시행착오와 테스트를 통하여 윈도우 API 함수인 IntersectRect 함수의 결함을 발견하였습니다.
IntersectRect 함수는 BOOL을 반환하도록 설계가 되어있지만, 이상한 원인으로 Window 98 에서는 리턴값이 TRUE(1), FALSE(0)이 아닌 0, Not 0 을 리턴하는 사실을 발견하였습니다.
따라서 그 함수의 리턴값을 사용할 경우 0 과 Not 0으로 비교해야 올바른 결과를 얻을 수 있습니다.
테스트 코드 |
void IntersectRectTest() { // 겹친 사각형 테스트 // rtn 이 TRUE(1)이 나오면 정상, Window XP /2000 / 98 모두 정상 작동됨 CRect rcTemp; CRect rcScreen( 0, 0, 1024, 768 ); CRect rcWindow( 5, 40, 80, 59 );
int rtn = rcTemp.IntersectRect( &rcScreen, &rcWindow ); cout << "IntersectRect1 = " << rtn << endl;
// 안겹친 사각형 테스트 // rtn 이 FALSE(0)이 나오면 정상, Window XP /2000 에서는 정상 작동됨, Window 98 에서는 0이 아닌값이 리턴됨
rcScreen.SetRect( 0, 0, 1024, 768 ); rcWindow.SetRect( 5000, 4000, 8000, 5900 );
rtn = rcTemp.IntersectRect( &rcScreen, &rcWindow );
cout << "IntersectRect2 = " << rtn << endl;
Sleep(1000); }
실행결과 Window 2000 / XP 에서의 결과 (올바른 결과가 나온다.)
>> IntersectRect1 = 1 >> IntersectRect2 = 0
Window 98 에서의 결과 (잘못된 결과가 나온다.)
>> IntersectRect1 = 769 >> IntersectRect2 = 0 |
참고 IntersectRect 함수의 MSDN 설명서 |
IntersectRect
The IntersectRect function calculates the intersection of two source rectangles and places the coordinates of the intersection rectangle into the destination rectangle. If the source rectangles do not intersect, an empty rectangle (in which all coordinates are set to zero) is placed into the destination rectangle.
BOOL IntersectRect( LPRECT lprcDst, // intersection buffer CONST RECT *lprcSrc1, // first rectangle CONST RECT *lprcSrc2 // second rectangle ); |
Parameters
lprcDst
[out] Pointer to the RECT structure that is to receive the intersection of the rectangles pointed to by the lprcSrc1 and lprcSrc2 parameters. This parameter cannot be NULL.
lprcSrc1
[in] Pointer to the RECT structure that contains the first source rectangle.
lprcSrc2
[in] Pointer to the RECT structure that contains the second source rectangle.
Return Values
If the rectangles intersect, the return value is nonzero.
If the rectangles do not intersect, the return value is zero.