C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[17254] Re:OpenGl에 질문입니다.
남병철.레조 [lezo] 1138 읽음    2002-04-06 15:42
안녕하세요? 레조입니다.

소스를 직접 컴파일 해봤습니다. 그런데... 0__0;;

잘돌아갑니다..
삼각형 뱅글뱅글 잘돌아가고 종료할때 "a"라는 메시지 뜨네요.

[참고]
New -> 콘솔 -> C++만 채크



장인수 님이 쓰신 글 :
: 안녕하세요~ 이제 막 오픈GL를 배우는 초보입니다.
:
: C++빌더에서 OpenGl을 사용할경우 컴파일한 프로그램을 종료하면 디버그창 뜹니다.
: 그래도 어디가 문제인가 찾아봤더니..
:
:     wglMakeCurrent( NULL, NULL );
:     if( TRUE == wglDeleteContext( hRC ) )  // <--- 이 부분에서 문제
:     {
:       MessageBox(hWnd,"a","a",MB_OK);
:     }
:     ReleaseDC( hWnd, hDC );
:
: 저기 주석으로 표시된 줄이 문제더군요.. Dev-C++로 동일한 소스를 컴파일 해봤는데.
: 저 부분에서 TRUE 잘 리턴 하더군요..
: 근데 C++빌더에선 FALSE리턴하네여.. 저부분 때문에 자꾸 빌더에서 디버그창이 뜨는데
: 고칠 방법이 없나여??
:
: 참고로 전체 소스 올려드릴께여..
:
: /*
:    Name: GLSAMPLE
:    Author: Blaine Hodge
:    Description: OpenGL sample. Read the file Include\Gl\ReadMe.txt
:                 for informations on using OpenGL.
:    Date: -
:    Copyright: Public domain
: */
:
: // Includes
:
: #include <windows.h>
: #include <gl/gl.h>
:
: // Function Declarations
:
: LRESULT CALLBACK WndProc( HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam );
:
: VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC );
: VOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC );
:
: // WinMain
:
: int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
:                                                 LPSTR lpCmdLine, int iCmdShow )
: {
:     WNDCLASS wc;
:     HWND hWnd;
:     HDC hDC;
:     HGLRC hRC;       
:     MSG msg;
:     BOOL bQuit = FALSE;
:     float theta = 0.0f;
:
: // register window class
:     wc.style = CS_OWNDC;
:     wc.lpfnWndProc = WndProc;
:     wc.cbClsExtra = 0;
:     wc.cbWndExtra = 0;
:     wc.hInstance = hInstance;
:     wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
:     wc.hCursor = LoadCursor( NULL, IDC_ARROW );
:     wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
:     wc.lpszMenuName = NULL;
:     wc.lpszClassName = "GLSample";
:    
:     RegisterClass( &wc );
:
: // create main window
:     hWnd = CreateWindow(
:             "GLSample",
:             "OpenGL Sample",
:             WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
:             0,
:             0,
:             256,
:             256,
:             NULL,
:             NULL,
:             hInstance,
:             NULL);
:
: // enable OpenGL for the window
:     EnableOpenGL( hWnd, &hDC, &hRC );
:
: // program main loop
:     while ( !bQuit )
:     {
:         if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
:         {
:             if ( msg.message == WM_QUIT )
:             {
:                 bQuit = TRUE;
:             }
:             else
:             {
:                 TranslateMessage( &msg );
:                 DispatchMessage( &msg );
:              }
:
:          }
:          else
:          {
:
: // OpenGL animation code goes here
:         glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
:         glClear( GL_COLOR_BUFFER_BIT );
:
:         glPushMatrix();
:         glRotatef( theta, 0.0f, 0.0f, 1.0f );
:        
:         glBegin( GL_TRIANGLES );
:            glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
:            glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
:            glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
:         glEnd();
:        
:         glPopMatrix();
:         SwapBuffers( hDC );
:
:         theta += 1.0f;
:
:         }
:
:         }
:
:     // shutdown OpenGL
:     DisableOpenGL( hWnd, hDC, hRC );
:     // destroy the window explicitly
:     DestroyWindow( hWnd );
:
:     return msg.wParam;
: }
:
: // Window Procedure
:
: LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
: {
:
:     switch ( message )
:     {
:
:         case WM_CREATE:
:                 return 0;
:
:         case WM_CLOSE:
:                 PostQuitMessage( 0 );
:                 return 0;
:
:         case WM_DESTROY:
:                 return 0;
:
:         case WM_KEYDOWN:
:                 switch ( wParam )
:                 {
:                 case VK_ESCAPE:
:                       PostQuitMessage( 0 );
:                       return 0;
:                  }
:                  return 0;
:
:          default:
:                return DefWindowProc( hWnd, message, wParam, lParam );
: }
:
: }
:
: // Enable OpenGL
: VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC )
: {
:     PIXELFORMATDESCRIPTOR pfd;
:     int iFormat;
:
:     // get the device context (DC)
:     *hDC = GetDC( hWnd );
:
:     // set the pixel format for the DC
:     ZeroMemory( &pfd, sizeof( pfd ) );
:     pfd.nSize = sizeof( pfd );
:     pfd.nVersion = 1;
:     pfd.dwFlags = PFD_DRAW_TO_WINDOW |
:     PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
:     pfd.iPixelType = PFD_TYPE_RGBA;
:     pfd.cColorBits = 24;
:     pfd.cDepthBits = 16;
:     pfd.iLayerType = PFD_MAIN_PLANE;
:     iFormat = ChoosePixelFormat( *hDC, &pfd );
:     SetPixelFormat( *hDC, iFormat, &pfd );
:
:     // create and enable the render context (RC)
:     *hRC = wglCreateContext( *hDC );
:     wglMakeCurrent( *hDC, *hRC );
: }
:
: // Disable OpenGL
: VOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC )
: {
:     wglMakeCurrent( NULL, NULL );
:     if( TRUE == wglDeleteContext( hRC ) )
:     {
:       MessageBox(hWnd,"a","a",MB_OK);
:     }
:     ReleaseDC( hWnd, hDC );
: }

+ -

관련 글 리스트
17232 OpenGl에 질문입니다. 장인수 1062 2002/04/04
17254     Re:OpenGl에 질문입니다. 남병철.레조 1138 2002/04/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.