PlotPixelTest.cpp
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:4k
源码类别:
DirextX编程
开发平台:
Visual C++
- // PlotPixelTest.cpp : Defines the class behaviors for the application.
- #include "stdafx.h"
- #include "PlotPixelTest.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- const bool g_bFullScreen = true; // false;
- const DWORD g_dwWidth = 640; // 800; // 1024;
- const DWORD g_dwHeight = 480; // 600; // 768;
- const DWORD g_dwBPP = 16; // 16; // 24; // 32;
- CPlotPixelTestApp::CPlotPixelTestApp(void)
- {
- SetFullScreen(g_bFullScreen);
- SetPackFileName(_T("."), _T("gui"));
- // Called during initial app startup, this function
- // performs all the permanent initialization.
- m_pDDDevice = NULL;
- m_pRenderSurface = NULL;
- // add your permanent init code here !
- }
- // Called before the app exits, this function gives the app
- // the chance to cleanup after itself.
- CPlotPixelTestApp::~CPlotPixelTestApp()
- {
- // add your cleaup code here !
- }
- bool CPlotPixelTestApp::GetDXInitSettings(void)
- {
- if (m_pDirectSound != NULL)
- {
- if (m_pDirectSound->SelectDSDriver(0) == false)
- return false;
- }
- if (m_pDirectMusic != NULL)
- {
- if (m_pDirectMusic->SelectDefaultDMusPort() == false)
- return false;
- }
- if (m_pDirectDraw->SelectDDDevice(0) == false)
- return false;
- if (GetFirstDDDevice()->SelectDisplayMode(
- IsFullScreen(), g_dwWidth, g_dwHeight, g_dwBPP) == false)
- return false;
- return true;
- }
- // Called during device intialization, this code checks the device
- // for some minimum set of capabilities, Initialize scene objects.
- bool CPlotPixelTestApp::InitDXObjects(void)
- {
- m_pDDDevice = GetFirstDDDevice();
- m_pRenderSurface = m_pDDDevice->GetRenderSurface();
- // add your init code here !
- m_pRenderSurface->Fill(0);
- return true;
- }
- // Called when the app is exitting, or the device is being changed,
- // this function deletes any device dependant objects.
- bool CPlotPixelTestApp::DestroyDXObjects(void)
- {
- // add your destroy code here !
- m_pRenderSurface = NULL;
- m_pDDDevice = NULL;
- return CDirectXApp::DestroyDXObjects();
- }
- // Called once per frame, the call is the entry point for
- // animating the scene. This function sets up render states,
- // clears the viewport, and renders the scene.
- bool CPlotPixelTestApp::UpdateFrame(void)
- {
- // add your code here !
- DDSURFACEDESC2 ddsd;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- if (SUCCEEDED(m_pRenderSurface->Lock(&ddsd)))
- {
- for (WORD wX = 0; wX < 50; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 255, 0, 0);
- }
- }
- for (wX = 50; wX < 100; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 0, 255, 0);
- }
- }
- for (wX = 100; wX < 150; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 0, 0, 255);
- }
- }
- for (wX = 150; wX < 200; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 255, 255, 0);
- }
- }
- for (wX = 200; wX < 250; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 255, 0, 255);
- }
- }
- for (wX = 250; wX < 300; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PlotPixel(&ddsd, wX, wY, 0, 255, 255);
- }
- }
- //if (m_dwBPP == 8)
- {
- for (wX = 300; wX < 400; ++ wX)
- {
- for (WORD wY = 0; wY < 100; ++ wY)
- {
- m_pRenderSurface->PutPixel(&ddsd, wX, wY, 1);
- }
- }
- }
- m_pRenderSurface->Unlock();
- }
- return CDirectXApp::UpdateFrame();
- }
- // ---- add your functions ! ----
- // ----
- #if _MSC_VER >= 1200 && _MSC_VER < 1400
- #ifdef _DEBUG
- #pragma comment(lib, "DXGuideD_VC6.lib")
- #else
- #pragma comment(lib, "DXGuide_VC6.lib")
- #endif // _DEBUG
- #endif // _MSC_VER
- #if _MSC_VER >= 1000 && _MSC_VER < 1200
- #ifdef _DEBUG
- #pragma comment(lib, "DXGuideD_VC5.lib")
- #else
- #pragma comment(lib, "DXGuide_VC5.lib")
- #endif // _DEBUG
- #endif // _MSC_VER
- BEGIN_MESSAGE_MAP(CPlotPixelTestApp, CDirectXApp)
- //{{AFX_MSG_MAP(CPlotPixelTestApp)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- CPlotPixelTestApp theApp;