当前位置: 首页>>代码示例>>C++>>正文


C++ CD3DTexture::load方法代码示例

本文整理汇总了C++中CD3DTexture::load方法的典型用法代码示例。如果您正苦于以下问题:C++ CD3DTexture::load方法的具体用法?C++ CD3DTexture::load怎么用?C++ CD3DTexture::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CD3DTexture的用法示例。


在下文中一共展示了CD3DTexture::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WinMain

// Our Win32 main
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{
    HWND hwnd = NULL; // Handle to our window
    MSG msg = {0};
    WNDCLASSEX wndclassex = {0};

    // Init fields we care about
    wndclassex.cbSize = sizeof(WNDCLASSEX); // Always set to size of WNDCLASSEX
    wndclassex.style = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc = WinProc;
    wndclassex.hInstance = hinstance;
    wndclassex.lpszClassName = kClassName;
    wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW),
                                            IMAGE_CURSOR, 0, 0, LR_SHARED);

    RegisterClassEx(&wndclassex); // Register the WNDCLASSEX

    RECT rect = { 0, 0, kWinWid, kWinHgt }; // Desired window client rect

    DWORD winStyleEx = WS_EX_CLIENTEDGE;
    DWORD winStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME;

    // Adjust window rect so it gives us our desired client rect when we
    // create the window
    AdjustWindowRectEx(&rect, winStyle, false, winStyleEx);

    // Create the window
    hwnd = CreateWindowEx(winStyleEx,
                          kClassName,
                          "www.GameTutorials.com -- Render Targets",
                          winStyle,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          rect.right - rect.left,
                          rect.bottom - rect.top,
                          NULL,
                          NULL,
                          hinstance,
                          NULL);

    // Get the client rect and make sure our client is the size we want
    GetClientRect(hwnd, &rect);
    assert(rect.right == kWinWid && rect.bottom == kWinHgt);



    // Init our global 3D object
    if(g3D->init(hwnd) == false)
        return EXIT_FAILURE; // There's been an error, lets get out of this joint

    if(!gBlurTexture1.createRenderTexture(256, 256, D3DFMT_A8R8G8B8))
        return false; // Couldn't create a off screen texture to render to

    if(!gBlurTexture2.createRenderTexture(256, 256, D3DFMT_A8R8G8B8))
        return false; // Couldn't create a off screen texture to render to

    if(!gDiffTex.load("texture.jpg"))
        return false;

    if(!gRenderTarget.init(256, 256, D3DFMT_A8R8G8B8, D3DFMT_D24S8))
        return false; // Couldn't create a render texture... Does your video card support this?

    Make3x3GuassianDistribution();

    // Set up our projection matrix once because it will not change
    g3D->setProjMatrix(DEG2RAD(60), 1.0f, 2048.0f);

    // We set up our view matrix once because it will never change
    g3D->setViewMatrix(kEyePos, CPos(0.0f, 0.0f, 0.0f));

    g3D->mShader->SetFloatArray("gEyePos", &kEyePos.x, 3); // Set the camera's eye position
    g3D->mShader->SetFloatArray("gBlurWeights", gBlurWeights, 9); // Gaussian blur weights

    // Show and update the window
    ShowWindow(hwnd, ishow);
    UpdateWindow(hwnd);

    while(1) // While the app is alive
    {
        if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // If the OS has a message for us
        {
            if(msg.message == WM_QUIT)
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else if(LockFrameRate()) // Else, if it's time to draw
        {
            // Render the off screen texture (created directly above) to another
            // off screen texture using a Gaussian blur
            if(gToggle)
                Combined();
            else
                RenderSobelFilter();

            // Render the two textures to the screen
            RenderScene();
        }
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:101,代码来源:win_main.cpp

示例2: WinMain

// Main window program
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{
	HWND hwnd = NULL;
	MSG msg = {0};
	WNDCLASSEX wndclassex = {0};

	// Init fields we care about
	wndclassex.cbSize = sizeof(WNDCLASSEX); // Always set to size of WNDCLASSEX
	wndclassex.style = CS_HREDRAW | CS_VREDRAW;
	wndclassex.lpfnWndProc = WinProc;
	wndclassex.hInstance = hinstance;
	wndclassex.lpszClassName = kClassName;
	wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW),
											IMAGE_CURSOR, 0, 0, LR_SHARED);

	RegisterClassEx(&wndclassex); // Register the WNDCLASSEX

	RECT rect = { 0, 0, kWinWid, kWinHgt }; // Desired window client rect

	DWORD winStyleEx = WS_EX_CLIENTEDGE;
	DWORD winStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
					 WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

	// Adjust window rect so it gives us our desired client rect when we 
	// create the window
	AdjustWindowRectEx(&rect, winStyle, false, winStyleEx);
	
	// Create the window
    hwnd = CreateWindowEx(winStyleEx, // Window extended style
					      kClassName,
						  "www.GameTutorials.com -- D3D Vertex Buffers",
						  winStyle, // Window style
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  rect.right - rect.left,
						  rect.bottom - rect.top,
						  NULL,
						  NULL,
						  hinstance,
						  NULL);
						  
	// Get the client rect and make sure our client is the size we want
	GetClientRect(hwnd, &rect);
	assert(rect.right == kWinWid && rect.bottom == kWinHgt);

	// Init our global 3D object
	if(g3D->init(hwnd) == false)
		return EXIT_FAILURE; // There's been an error, lets get out of this joint
		
	if(gTexture.load("Texture.jpg") == false)
		return EXIT_FAILURE; // There's been an error, lets get out of this joint
		
	// Create and set the vertex buffer in our CD3DMesh object
	if(gQuad.setVertexData(gQuadVertexData, kMaxVerts) == false)
		return EXIT_FAILURE; // This is bad!  The tutorial is officially broken

	// Set the perspective matrix once because it will never change
	g3D->setProjMatrix(DEG2RAD(60), (float)rect.right / (float)rect.bottom, 1.0f, 8192.0f);
	
	// We set up our view matrix once because it will never change
	g3D->setViewMatrix(CPos(0.0f, 0.0f, -5.0f), CPos(0.0f, 0.0f, 0.0f));

	ShowWindow(hwnd, ishow);
	UpdateWindow(hwnd);

    while(1) // While the app is running
	{
		if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Handle messages from the OS
		{
			if(msg.message == WM_QUIT)
				break;
			
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else if(LockFrameRate()) // If it is time to draw, do so
		{
			g3D->begin(); // Begin the scene
			g3D->clear(); // Clear the Z-buffer
			
			gTexture.select(); // Select the texture to be used
			
			// Render the textured quad
			gQuad.render();
			
			g3D->end(); // End the scene
		}
		else
			Sleep(1); // Give the OS a slice of time to process other things
	
	} // end of while(1)

	g3D->deinit(); // Free up CD3DObj
	UnregisterClass(kClassName, hinstance); // Free up WNDCLASSEX
	    return EXIT_SUCCESS; // Application was a success
}
开发者ID:88er,项目名称:tutorials,代码行数:97,代码来源:win_main.cpp


注:本文中的CD3DTexture::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。