beginning opengl game programming 2004 phần 10

Tham khảo tài liệu 'beginning opengl game programming 2004 phần 10', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Using OpenGL in the Game 279 Figure Initialize sequence diagram. CChessBoard class is initialized allowing the chessboard to be set up and all of the pieces to be positioned correctly and their models loaded. Finally we attach the CChessGame class pointer to the CGfxOpenGL class which needs to know about the data stored in CChessGame in order to render the chessboard and pieces correctly. Next we have the main game loop whose sequence diagram is shown in Figure . The CGfxOpenGL class is used as the entry point into the rest of the game software. It is here that we call the Update method of the CChessGame class where we then proceed to update chess piece model animations piece movements captures the game board and the overall game state. After performing the data update for the current frame we then render it with the Render method of CGfxOpenGL. Let s take a look at this method. Figure Update sequence diagram. TLFeBOOK 280 Chapter 13 The Endgame Using OpenGL in the Game The Render method in the CGfxOpenGL class is the entry point for all rendering functionality in the game. void CGfxOpenGL Render glClearColor glClear GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT GL_STENCIL_BUFFER_BIT glLoadIdentity if m_currentView WHITE gluLookAt else gluLookAt In this first block of code you can see that we clear the color depth and stencil buffer bits load the identity matrix and set the camera position based on the current player. We clear the stencil buffer bit because we use the stencil buffer to properly render piece reflections on the chessboard. render the wood table glDisable GL_DEPTH_TEST RenderTable glEnable GL_DEPTH_TEST In this section we draw the background wood table with the RenderTable method. The background table is drawn primarily for aesthetic purposes but since we are drawing piece .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.