카테고리 보관물: 미분류

Windows message pump

DirectX 렌더링 프로그램을 만들다 보면 main() 함수에 다음과 같은 코드를 볼 수 있다.

main()
{
   ...
   while(1)
   {
      if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
      {
         if(msg.message == WM_QUIT)
            break;
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
      else
      {
         renderer.Update();
         renderer.Render();
      }
   }
   ...
}

다음과 같은 코드를 메세지 펌프 라고 부른다.
다른 메세지를 처리하는 중에 큐에서 메세지를 꺼내 처리하는 코드

이 단어는 Z emotion에 다닐 때 들은 것인데 오늘 문득 저게 떠올랐다, 갑자기?, 하지만 ‘메세지 펌프’ 라는 용어가 기억이 안나 한참을 검색하여 발견한 내용을 기억하기 위해 포스트로 적게 되었다.


윈도우에서 이벤트 메세지를 가져오는 함수는 두가지가 있다

GetMessage(…) 와 PeekMessage(…) 두 함수는 메세지 큐가 비어있을 때 리턴 여부에 있다.

GetMessage(…) 의 활용은 다음과 같다.

while(bRet = (GetMessage(&msg, hWnd, 0, 0) != 0)) // <<여기서 대기
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

출처 : https://abipictures.tistory.com/26


git submodule 사용법

서브모듈 추가

$git submodule add [url] [name]

*가끔 add_clone not function 이라는 에러 메세지가 나올때가 있는데 깃 버전이 낮아 발생하는 에러이니 버전 업데이트를 해보기 바란다.

https://ohgyun.com/711

서브모듈의 url 변경

.gitsubmodule 파일의 url 항목을 변경하고 다음 명령을 실행한다

git submodule sync --recursive <submodule_dir>

리포지토리 기록이 다를경우 새로 체크아웃 해야한다.

cd <submodule_dir>
git fetch
git checkout origin/master
git branch master -f
git checkout master

https://stackoverflow.com/questions/913701/how-to-change-the-remote-repository-for-a-git-submodule

https://rateye.tistory.com/296

Built-in extra asset

private const string kStandardSpritePath = "UI/Skin/UISprite.psd";
private const string kBackgroundSpriteResourcePath = "UI/Skin/Background.psd";
private const string kInputFieldBackgroundPath = "UI/Skin/InputFieldBackground.psd";
private const string kKnobPath = "UI/Skin/Knob.psd";
private const string kCheckmarkPath = "UI/Skin/Checkmark.psd";
Image image = buttonRoot.AddComponent<Image>();
image.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath);

https://forum.unity.com/threads/accessing-ui-build-in-sprites-in-c.305075/

Spherical coordinate system

구면 좌표계

다음의 3가지 요소를 이용하여 3차원 좌표를 결정할 수 있는 체계를 말한다.

3요소 : 반지름(radial distance), 극각(polar angle), 방위각(azimuthal angle)

구면 좌표계의 한 점 P (r, θ, φ) r= radius, θ=polar angle, φ=azimuthal angle 을 3차원 데카르트 공간좌표계로 변환하면 다음과 같다

P (x,y,z) = P(r, θ, φ)
x = r cosφ sinθ
y = r sinφ cosθ
z = r cosθ

https://en.wikipedia.org/wiki/Spherical_coordinate_system

https://github.com/mrdoob/three.js/blob/master/src/math/Spherical.js

three.js 구면좌표계 계산 클래스

Javascript에 대한 사소한 궁금증

Q. 문자열 ‘ ‘ 과 ” ” 의 차이

A. 차이 없음.
자바스크립트에서는 String 값을 표현할 때 “”를 사용하는데 C언어 기반 과 자바에서는 큰 따옴표(“) 만 사용해서 자칫 차이점이 있는 것 같은데 조사에 따르면 String을 표현하는 방식일뿐 차이가 없는 것으로 나온다.
참고로 작음 따옴표(‘)와 마찬가지로 억음 부호(backtick – ` ) 도 차이가 없다.
[ref. 클릭]