iOS真钱捕鱼 实现类似擦玻璃效果的一种方法

兄弟有多少个windowsphone8d3d的标题,项目挺急的,向大神求救:第一个难题:文字的绘图,特别是中文如什么地点理第一个难题:图片的绘图,最佳辅助越来越多的格式,而不光是dds第八个难点:图形的绘图中的圆石怎么绘制出来证实:以上的显示屏坐标都是显示器的左上角为原点,绘制时传出的有关长度的参数采取物理像素各位大神,自身刚开首做游戏,才接触direct,很生分,麻烦给个全点的简化demo,不要用d3dxtk那些helper和cocos那个框架,很麻烦看不懂啊,麻烦发到我邮箱后生可畏份不胜谢谢:lei2nuo@126.com,二弟在那先谢过了

兄弟初学d3d,代码是一心依据教材来的,原来指标是体现叁个星型,然而最终只展现了紫褐的背景,其余的d3d代码也可以有此难题,急求大神解惑释疑!

以下是源代码:

 //--------------------------------------------------------------------------------------// File: VertexBuffer.cpp//--------------------------------------------------------------------------------------#include <d3d9.h> // Direct3D头文件#define SAFE_RELEASE { if->Release=NULL; } }wchar_t *g_pClassName = L"VertexBuffer"; // 窗口类名wchar_t *g_pWindowName = L"顶点缓存示例"; // 窗口标题名LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Direct3D设备接口LPDIRECT3DVERTEXBUFFER9 g_pVertexBuf = NULL; // 顶点缓存接口struct CUSTOMVERTEX { FLOAT _x, _y, _z, _rhw; // 顶点的位置 DWORD _color; // 顶点的颜色 CUSTOMVERTEX(FLOAT x, FLOAT y, FLOAT z, FLOAT rhw, DWORD color) : _x, _z, _rhw, _color {}};#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)HRESULT InitDirect3D(HWND hWnd); // 初始化Direct3DVOID Direct3DRender(); // 渲染图形VOID Direct3DCleanup(); // 清理Direct3D资源// 窗口消息处理函数声明LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);//--------------------------------------------------------------------------------------// Name: WinMain();// Desc: Windows应用程序入口函数//--------------------------------------------------------------------------------------int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ // 初始化窗口类 WNDCLASS wndclass; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); // 窗口背景 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); // 光标形状 wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); // 窗口小图标 wndclass.hInstance = hInstance; wndclass.lpfnWndProc = WndProc; wndclass.lpszClassName = g_pClassName; wndclass.lpszMenuName = NULL; wndclass.style = CS_HREDRAW | CS_VREDRAW; // 注册窗口类 if (!RegisterClass(&wndclass)) return 0; // 创建窗口 HWND hWnd = CreateWindow(g_pClassName, g_pWindowName, WS_OVERLAPPEDWINDOW, 100, 100, 640, 480, NULL, NULL, wndclass.hInstance, NULL); // 初始化Direct3D InitDirect3D; // 显示、更新窗口 ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow; // 消息循环 MSG msg; ZeroMemory(&msg, sizeof; while (msg.message!=WM_QUIT) { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage; DispatchMessage; } else { Direct3DRender(); // 绘制3D场景 } } UnregisterClass(g_pClassName, wndclass.hInstance); return 0;}//--------------------------------------------------------------------------------------// Name: WndProc()// Desc: 窗口消息处理函数//--------------------------------------------------------------------------------------LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch  { case WM_PAINT: // 客户区重绘消息 Direct3DRender(); // 渲染图形 ValidateRect(hWnd, NULL); // 更新客户区的显示 break; case WM_KEYDOWN: // 键盘按下消息 if (wParam == VK_ESCAPE) // ESC键 DestroyWindow; // 销毁窗口, 并发送一条WM_DESTROY消息 break; case WM_DESTROY: // 窗口销毁消息 Direct3DCleanup(); // 清理Direct3D PostQuitMessage; // 退出程序 break; } // 默认的消息处理 return DefWindowProc( hWnd, message, wParam, lParam );}//--------------------------------------------------------------------------------------// Name: InitDirect3D()// Desc: 初始化Direct3D//--------------------------------------------------------------------------------------HRESULT InitDirect3D(HWND hWnd) { // 创建IDirect3D接口 LPDIRECT3D9 pD3D = NULL; // IDirect3D9接口 pD3D = Direct3DCreate9(D3D_SDK_VERSION); // 创建IDirect3D9接口对象 if (pD3D == NULL) return E_FAIL; // 获取硬件设备信息 D3DCAPS9 caps; int vp = 0; pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps ); if( caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ) vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; // 创建Direct3D设备接口 D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof; d3dpp.BackBufferWidth = 640; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.MultiSampleQuality = 0; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = hWnd; d3dpp.Windowed = true; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; d3dpp.Flags = 0; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, vp, &d3dpp, &g_pd3dDevice); pD3D->Release(); // 创建顶点缓存 g_pd3dDevice->CreateVertexBuffer(6 * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVertexBuf, NULL); // 填充顶点数据 CUSTOMVERTEX *pVertices = NULL; g_pVertexBuf->Lock(0, 0, &pVertices, 0); pVertices[0] = CUSTOMVERTEX( 220.0f, 120.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0)); // V0 pVertices[1] = CUSTOMVERTEX( 420.0f, 120.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0)); // V1 pVertices[2] = CUSTOMVERTEX( 220.0f, 320.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 255, 0)); // V2 pVertices[3] = CUSTOMVERTEX( 420.0f, 120.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0)); // V1 pVertices[4] = CUSTOMVERTEX( 420.0f, 320.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255)); // V3 pVertices[5] = CUSTOMVERTEX( 220.0f, 320.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 255, 0)); // V2 g_pVertexBuf->Unlock(); return S_OK;}//--------------------------------------------------------------------------------------// Name: Direct3DRender()// Desc: 绘制3D场景//--------------------------------------------------------------------------------------VOID Direct3DRender() { g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(45, 50, 170), 1.0f, 0); g_pd3dDevice->BeginScene(); // 开始绘制 // 渲染正方形 g_pd3dDevice->SetStreamSource(0, g_pVertexBuf, 0, sizeof(CUSTOMVERTEX)); g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); g_pd3dDevice->EndScene(); // 结束绘制 g_pd3dDevice->Present(NULL, NULL, NULL, NULL); // 翻转}//--------------------------------------------------------------------------------------// Name: Direct3DCleanup()// Desc: 清理Direct3D, 并释放COM接口//--------------------------------------------------------------------------------------VOID Direct3DCleanup() { SAFE_RELEASE(g_pVertexBuf); // 释放顶点缓存接口 SAFE_RELEASE(g_pd3dDevice); // 释放D3D设备接口}

末尾完结


终极设置mask就相当轻松了,设置大家就要展现的图样(那张清晰的)的layer的mask为地点通过绘制作而成形的image的layer,那样唯有绘制过的职责技能看出就要展现的图形,功能就到位了,作者深感利用这些小技能能够做过多美不可言的东西(相通刮奖等)

    CALayer *mask = [CALayer layer];
    mask.contents = (id)image.CGImage;
    mask.anchorPoint = CGPointZero;
    mask.frame = self.bounds;
    self.imageView.layer.mask = mask;
    self.imageView.layer.masksToBounds = YES;

Direct3d9绘制的图纸不可能显得,求解! 5C

第一谈下写这一个demo的灵感源于(扯谈),是潜意识在github上阅览以那一件事物(以下简单称谓大神),以为风趣就拿下来看看,结果看了少数遍也没完全看懂,再结合本身前面学的东西以为不用那样复杂也能完毕平等的意义,于是乎就从头入手了。

返回列表