SlideShare una empresa de Scribd logo
1 de 13
API 더블 버퍼링


     열혈장인 - 김민호
1. 문제인식 - " 더블버퍼링은 왜쓸까 ?"
 api 를 제일 먼저 시작하면 , 그냥 텍스트 띄우고 타이머로
 독서도우미 같은 거만들고 하다가 , 비트맾 사용방법을 배우
 고나서 게임 예제를 만들어 보게된다 .

예제를 만들어보고 , 잘되는 것을 확인한뒤 자신감이 붙어
 서 자신만의 게임 비스무리한 것을 만들고 보면 , 케릭터 같
 은게 움직일때마다 화면이 깜박깜박이는 현상때문에 눈으로
 보기힘들 정도이다 .

왜 이러는 것일까 ? 바로 .. 화면을 지우고 다시그리고 , 화
 면을지우고 다시그리기를 반복하기 때문이다 .
1. 문제인식 - " 그렇다면 어쩐다 ?"
 더블 버퍼링을 이요하는 것이다 .

도장은 찍을 때마다 완전히 뒤덮어 버린다 .

하나하나 도장을 파내면서 제작하고 !

그리고   쾅!   찍어 버린다 .

그렇게 될 경우에는 , 지울 필요없이 한번에 되는 것이다 .
1. 문제인식 - " 도장 분석 "
도장은 도화지랑 같이 붙어 있는 놈이 아니다 .

따로 만들어서 이제 거기에다가 그림 다그리고

잉크 뭍여서 , 도화지에다가 찍어낸다 .

이방법을 분석해보면
2. 도장을 만들자 .
1. 도장을 깍을 도화지크기에 맞춤식 나무를 구한다 .

2. 그리고 그것을 원하는 그림으로 하나하나 구성시킨다 .

3. 그리고나서 그것에 잉크를 뭍이고

4. 찍는다 .

5. 반복한다 .

이걸 그대로 코드화해보자 .
소스 부분 .
   case WM_PAINT:
   hdc = BeginPaint(hWnd,&ps)
   // hdc 에 그려 주기 위해 필요한 MemDC
   MemDC = CreateCompatibleDC(hdc);
   // 임시로 그림을 그리기 위해 BackBitMap 을 생성한다 .
   g_BackBitMap = CreateCompatibleBitmap(hdc, 800, 600 );
   // BackBitMap 을 MemDC 에 넣어 준다 .
   hPreBit = (HBITMAP)SelectObject(MemDC, g_BackBitMap);
   // 마찬가지로 BackDC 도 생성해 준다 .
   BackDC = CreateCompatibleDC( hdc );
   // BackDC 에 실제 이미지를 삽입한다 .
   SelectObject(BackDC, hIcon);
   // BackDC 에 있는 이미지를 MemDC 로 옮긴다 .
   BitBlt(MemDC,300+x,300,48,48,BackDC,0,0,SRCCOPY);
   // 그 후 BackDC 를 삭제
   DeleteObject(BackDC);
   // 마지막으로 MemDC 에 있는 것을 hdc 로 옮긴다 .
   BitBlt(hdc, 0, 0, 800, 600, MemDC, 0, 0, SRCCOPY);
   // 그 후 MemDC 이전값으로 복원
   SelectObject( MemDC, hPreBit );
   // 관련 데이터 삭제
   DeleteObject(g_BackBitMap);
   DeleteDc(MemDC);
   EndPaint(hWnd, &ps);
   return;
첫번째
 MemDC = CreateCompatibleDC(hdc);
 hdc 를 MemDC 에 저장시키고 !




     MemDC                           hdc
두번째
 // 임시로 그림을 그리기 위해 BackBitMap 을 생성한다 .
 g_BackBitMap = CreateCompatibleBitmap(hdc, 800, 600 );



 g_BackBitMap                                MemDC




 // BackBitMap 을 MemDC 에 넣어 준다 .
 hPreBit = (HBITMAP)SelectObject(MemDC, g_BackBitMap);

 셀렉트 오브젝트 함수의 리턴값은 MemDC 에 g_BackBitMap 을 집어넣기 전에 있었던
 그 것이 hPreBit 로 들어간다


    hPreBit                                  MemDC
                                             옛날꺼
세번째
 // 마찬가지로 BackDC 도 생성해 준다 .
 BackDC = CreateCompatibleDC( hdc );



   BackDC

                                        hIcon

 // BackDC 에 실제 이미지를 삽입한다 .
 SelectObject(BackDC, hIcon);
네번째
 // BackDC 에 있는 이미지를 MemDC 로 옮긴다 .
 BitBlt(MemDC,300+x,300,48,48,BackDC,0,0,SRCCOPY);




     MemDC
                                                      BackDC


                                    1




                                                           hIcon
네번째
   // 그 후 BackDC 를 삭제
   DeleteObject(BackDC);
   // 마지막으로 MemDC 에 있는 것을 hdc 로 옮긴다 .
   BitBlt(hdc, 0, 0, 800, 600, MemDC, 0, 0, SRCCOPY);


                                                         hIcon


      BackDC                               이 시점에서        MemDC

                                           화면에 그림이
                                           그려진다 !!

                                                hdc
마무리
 // 그 후 MemDC 이전값으로 복원
 SelectObject( MemDC, hPreBit ); // 복귀시키고 .


 // 관련 데이터 삭제
 DeleteObject(g_BackBitMap);
 DeleteDc(MemDC);
                                               MemDC




                    g_BackBitMap
이런 과정에 의해서 더블버퍼링이 되는것 .

많이 헤깔린다 .

정말 헤깔린다 .

나의 이해용으로 이 PPT 를 제작하였는데

다른분들도 도움이 됬으면 좋겠다 .

끝 .

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Api더블버퍼링

  • 1. API 더블 버퍼링 열혈장인 - 김민호
  • 2. 1. 문제인식 - " 더블버퍼링은 왜쓸까 ?"  api 를 제일 먼저 시작하면 , 그냥 텍스트 띄우고 타이머로 독서도우미 같은 거만들고 하다가 , 비트맾 사용방법을 배우 고나서 게임 예제를 만들어 보게된다 . 예제를 만들어보고 , 잘되는 것을 확인한뒤 자신감이 붙어 서 자신만의 게임 비스무리한 것을 만들고 보면 , 케릭터 같 은게 움직일때마다 화면이 깜박깜박이는 현상때문에 눈으로 보기힘들 정도이다 . 왜 이러는 것일까 ? 바로 .. 화면을 지우고 다시그리고 , 화 면을지우고 다시그리기를 반복하기 때문이다 .
  • 3. 1. 문제인식 - " 그렇다면 어쩐다 ?"  더블 버퍼링을 이요하는 것이다 . 도장은 찍을 때마다 완전히 뒤덮어 버린다 . 하나하나 도장을 파내면서 제작하고 ! 그리고 쾅! 찍어 버린다 . 그렇게 될 경우에는 , 지울 필요없이 한번에 되는 것이다 .
  • 4. 1. 문제인식 - " 도장 분석 " 도장은 도화지랑 같이 붙어 있는 놈이 아니다 . 따로 만들어서 이제 거기에다가 그림 다그리고 잉크 뭍여서 , 도화지에다가 찍어낸다 . 이방법을 분석해보면
  • 5. 2. 도장을 만들자 . 1. 도장을 깍을 도화지크기에 맞춤식 나무를 구한다 . 2. 그리고 그것을 원하는 그림으로 하나하나 구성시킨다 . 3. 그리고나서 그것에 잉크를 뭍이고 4. 찍는다 . 5. 반복한다 . 이걸 그대로 코드화해보자 .
  • 6. 소스 부분 .  case WM_PAINT:  hdc = BeginPaint(hWnd,&ps)  // hdc 에 그려 주기 위해 필요한 MemDC  MemDC = CreateCompatibleDC(hdc);  // 임시로 그림을 그리기 위해 BackBitMap 을 생성한다 .  g_BackBitMap = CreateCompatibleBitmap(hdc, 800, 600 );  // BackBitMap 을 MemDC 에 넣어 준다 .  hPreBit = (HBITMAP)SelectObject(MemDC, g_BackBitMap);  // 마찬가지로 BackDC 도 생성해 준다 .  BackDC = CreateCompatibleDC( hdc );  // BackDC 에 실제 이미지를 삽입한다 .  SelectObject(BackDC, hIcon);  // BackDC 에 있는 이미지를 MemDC 로 옮긴다 .  BitBlt(MemDC,300+x,300,48,48,BackDC,0,0,SRCCOPY);  // 그 후 BackDC 를 삭제  DeleteObject(BackDC);  // 마지막으로 MemDC 에 있는 것을 hdc 로 옮긴다 .  BitBlt(hdc, 0, 0, 800, 600, MemDC, 0, 0, SRCCOPY);  // 그 후 MemDC 이전값으로 복원  SelectObject( MemDC, hPreBit );  // 관련 데이터 삭제  DeleteObject(g_BackBitMap);  DeleteDc(MemDC);  EndPaint(hWnd, &ps);  return;
  • 7. 첫번째  MemDC = CreateCompatibleDC(hdc);  hdc 를 MemDC 에 저장시키고 ! MemDC hdc
  • 8. 두번째  // 임시로 그림을 그리기 위해 BackBitMap 을 생성한다 .  g_BackBitMap = CreateCompatibleBitmap(hdc, 800, 600 ); g_BackBitMap MemDC  // BackBitMap 을 MemDC 에 넣어 준다 .  hPreBit = (HBITMAP)SelectObject(MemDC, g_BackBitMap);  셀렉트 오브젝트 함수의 리턴값은 MemDC 에 g_BackBitMap 을 집어넣기 전에 있었던  그 것이 hPreBit 로 들어간다 hPreBit MemDC 옛날꺼
  • 9. 세번째  // 마찬가지로 BackDC 도 생성해 준다 .  BackDC = CreateCompatibleDC( hdc ); BackDC hIcon  // BackDC 에 실제 이미지를 삽입한다 .  SelectObject(BackDC, hIcon);
  • 10. 네번째  // BackDC 에 있는 이미지를 MemDC 로 옮긴다 .  BitBlt(MemDC,300+x,300,48,48,BackDC,0,0,SRCCOPY); MemDC BackDC 1 hIcon
  • 11. 네번째  // 그 후 BackDC 를 삭제  DeleteObject(BackDC);  // 마지막으로 MemDC 에 있는 것을 hdc 로 옮긴다 .  BitBlt(hdc, 0, 0, 800, 600, MemDC, 0, 0, SRCCOPY); hIcon BackDC 이 시점에서 MemDC 화면에 그림이 그려진다 !! hdc
  • 12. 마무리  // 그 후 MemDC 이전값으로 복원  SelectObject( MemDC, hPreBit ); // 복귀시키고 .  // 관련 데이터 삭제  DeleteObject(g_BackBitMap);  DeleteDc(MemDC); MemDC g_BackBitMap
  • 13. 이런 과정에 의해서 더블버퍼링이 되는것 . 많이 헤깔린다 . 정말 헤깔린다 . 나의 이해용으로 이 PPT 를 제작하였는데 다른분들도 도움이 됬으면 좋겠다 . 끝 .