本文整理汇总了C++中CD3DTexture::createRenderTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ CD3DTexture::createRenderTexture方法的具体用法?C++ CD3DTexture::createRenderTexture怎么用?C++ CD3DTexture::createRenderTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CD3DTexture
的用法示例。
在下文中一共展示了CD3DTexture::createRenderTexture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 -- Shadow Mapping (HLSL)",
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(!CreateSphere(0.05f, D3DCOLOR_XRGB(255,255,0), &gLight))
return false; // Couldn't create the sphere... Something very bad happened...
if(!CreateSphere(0.75f, D3DCOLOR_XRGB(0,128,64), &gSphere))
return false; // Couldn't create the sphere... Something very bad happened...
if(!CreateBox(1.0f, 2.0f, 1.0f, D3DCOLOR_XRGB(0, 128, 64), &gBox))
return false; // Couldn't create the box... This isn't good!
if(!CreateBox(16.0f, 0.05f, 16.0f, D3DCOLOR_XRGB(225, 225, 255), &gGround))
return false; // Couldn't create the ground... Time to bail
if(!gShadowMap.createRenderTexture(512, 512, D3DFMT_R32F))
return false; // Couldn't create a shadow map texture. Your video card
// probably doesn't support the D3DFMT_R32F format. You will need a beefier card to
// run this tutorial
if(!gRenderTarget.init(512, 512, D3DFMT_R32F, D3DFMT_D24S8))
return false; // Couldn't create a shadow map texture. Your video card doesn't support render
// targets or it probably doesn't support the D3DFMT_R32F format. You will need
// a beefier card to run this tutorial
// 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));
D3DXMATRIXA16 projMat;
// Create texture projection matrix
D3DXMatrixPerspectiveFovLH(&projMat, DEG2RAD(60), 1.0f, 0.1f, 100.0f);
// Set data in our shader that will never change
g3D->mShader->SetFloatArray("gLightProjMat", &projMat._11, 16);
g3D->mShader->SetFloatArray("gEyePos", &kEyePos.x, 3); // Set the camera's eye position
g3D->mShader->SetFloatArray("gDiffuse", &kDiffuse.r, 3); // Lights diffuse color
g3D->mShader->SetFloatArray("gSpecular", &kSpecular.r, 3); // Lights specular color
g3D->mShader->SetFloatArray("gAmbient", &kAmbient.r, 3); // Lights ambient color
// 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;
//.........这里部分代码省略.........
示例2: WinProc
// WinProc
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
const float kMoveAmt = 0.05f; // Amount to move light by
switch(message)
{
case WM_SYSKEYDOWN:
// Toggle on ALT + ENTER
if(wparam == VK_RETURN && (lparam & (1 << 29)))
{
// Shut down are render texture and render target
gShadowMap.deinit();
gRenderTarget.deinit();
g3D->toggleFullScreen(); // Toggle!
// Reinitialize the render texture and target
gShadowMap.createRenderTexture(512, 512, D3DFMT_R32F);
gRenderTarget.init(512, 512, D3DFMT_R32F, D3DFMT_D24S8);
g3D->setViewMatrix(kEyePos, CPos(0.0f, 0.0f, 0.0f)); // Reset the view of our scene
return 0;
}
break; // Allow other system keys to be handled by DefWindowProc()
case WM_KEYDOWN:
switch(wparam)
{
case VK_LEFT: // Move the light along the -X axis
gLightPos.x -= kMoveAmt;
break;
case VK_RIGHT: // Move the light along the +X axis
gLightPos.x += kMoveAmt;
break;
case VK_UP: // Move the light along the +Z axis
gLightPos.z += kMoveAmt;
break;
case VK_DOWN: // Move the light along the -Z axis
gLightPos.z -= kMoveAmt;
break;
case VK_ESCAPE:
SendMessage(hwnd, WM_CLOSE, 0, 0);
break;
}
return 0;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, message, wparam, lparam);
}
示例3: 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();
}
//.........这里部分代码省略.........