技术标签: direct3d filter border Direct 3d游戏编程 textures function buffer
Creates a texture from a file.
HRESULT D3DXCreateTextureFromFile( LPDIRECT3DDEVICE9 pDevice, LPCTSTR pSrcFile, LPDIRECT3DTEXTURE9 * ppTexture );
If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following:
D3DERR_NOTAVAILABLED3DERR_OUTOFVIDEOMEMORYD3DERR_INVALIDCALLD3DXERR_INVALIDDATAE_OUTOFMEMORYThe compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCreateTextureFromFileW. Otherwise, the function call resolves to D3DXCreateTextureFromFileA because ANSI strings are being used.
This function supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga. See D3DXIMAGE_FILEFORMAT.
The function is equivalent to D3DXCreateTextureFromFileEx(pDevice, pSrcFile, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, ppTexture).
Mipmapped textures automatically have each level filled with the loaded texture.
When loading images into mipmapped textures, some devices are unable to go to a 1x1 image and this function will fail. If this happens, the images need to be loaded manually.
Note that a resource created with this function will be placed in the memory class denoted by D3DPOOL_MANAGED.
Filtering is automatically applied to a texture created using this method. The filtering is equivalent to D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER in D3DX_FILTER.
For the best performance when using D3DXCreateTextureFromFile:
可以使用更高级的函数D3DXCreateTextureFromFileEx来创建纹理对象。
Creates a texture from a file. This is a more advanced function than D3DXCreateTextureFromFile.
HRESULT D3DXCreateTextureFromFileEx(
LPDIRECT3DDEVICE9 pDevice,
LPCTSTR pSrcFile,
UINT Width,
UINT Height,
UINT MipLevels,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
DWORD Filter,
DWORD MipFilter,
D3DCOLOR ColorKey,
D3DXIMAGE_INFO * pSrcInfo,
PALETTEENTRY * pPalette,
LPDIRECT3DTEXTURE9 * ppTexture
);
Parameters
If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL.
D3DERR_NOTAVAILABLED3DERR_OUTOFVIDEOMEMORYD3DXERR_INVALIDDATAE_OUTOFMEMORYThe compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCreateTextureFromFileExW. Otherwise, the function call resolves to D3DXCreateTextureFromFileExA because ANSI strings are being used.
Use D3DXCheckTextureRequirements to determine if your device can support the texture given the current state.
This function supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga. See D3DXIMAGE_FILEFORMAT.
Mipmapped textures automatically have each level filled with the loaded texture. When loading images into mipmapped textures, some devices are unable to go to a 1x1 image and this function will fail. If this happens, then the images need to be loaded manually.
For the best performance when using D3DXCreateTextureFromFileEx:
When skipping mipmap levels while loading a .dds file, use the D3DX_SKIP_DDS_MIP_LEVELS macro to generate the MipFilter value. This macro takes the number of levels to skip and the filter type and returns the filter value, which would then be passed into the MipFilter parameter.
当然也可以通过IDirect3DDevice9::CreateTexture来创建一个纹理对象。
Creates a texture resource.
HRESULT CreateTexture( UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY.
An application can discover support for Automatic Generation of Mipmaps (Direct3D 9) in a particular format by calling IDirect3D9::CheckDeviceFormat with D3DUSAGE_AUTOGENMIPMAP. If IDirect3D9::CheckDeviceFormat returns D3DOK_NOAUTOGEN, IDirect3DDevice9::CreateTexture will succeed but it will return a one-level texture.
通过IDirect3DTexture9::LockRect创建完IDirect3DTexture9对象后,可以通过IDirect3DTexture9::LockRect获得纹理数据。
Locks a rectangle on a texture resource.
HRESULT LockRect( UINT Level, D3DLOCKED_RECT * pLockedRect, CONST RECT * pRect, DWORD Flags );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
Textures created with D3DPOOL_DEFAULT are not lockable. Textures created in video memory are lockable when created with USAGE_DYNAMIC.
For performance reasons, dirty regions are recorded only for level zero of a texture. Dirty regions are automatically recorded when IDirect3DTexture9::LockRect is called without D3DLOCK_NO_DIRTY_UPDATE or D3DLOCK_READONLY. See IDirect3DDevice9::UpdateTexture for more information.
The only lockable format for a depth-stencil texture is D3DLOCK_D16_LOCKABLE.
Video memory textures cannot be locked, but must be modified by calling IDirect3DDevice9::UpdateSurface or IDirect3DDevice9::UpdateTexture. There are exceptions for some proprietary driver pixel formats that Direct3D 9 does not recognize. These can be locked.
This method cannot retrieve data from a texture resource created with D3DUSAGE_RENDERTARGET because such a texture must be assigned to D3DPOOL_DEFAULT memory and is therefore not lockable. In this case, use instead IDirect3DDevice9::GetRenderTargetData to copy texture data from device memory to system memory.
锁定之后,必须通过IDirect3DTexture9::UnlockRect来对IDirect3DTexture9对象进行解锁。
Unlocks a rectangle on a texture resource.
HRESULT UnlockRect( UINT Level );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
利用IDirect3DDevice9接口提供的SetTexture函数进行纹理设置,由于可进行多次纹理蒙皮,将纹理对象设置给固定渲染管道流水线时,必须提供所在的采样器序号或纹理状态序号,以区别不同的纹理处理。
Sets a texture.
HRESULT SetTexture( D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
可以通过GetLevelDesc来获取特定采样级别的纹理表面描述信息:
Retrieves a level description of a texture resource.
HRESULT GetLevelDesc( UINT Level, D3DSURFACE_DESC * pDesc );
If the method succeeds, the return value is D3D_OK. D3DERR_INVALIDCALL is returned if one of the arguments is invalid.
pDesc为一个指向D3DSURFACE_DESC数据类型的指针,来看看它的具体定义:
Describes a surface.
typedef struct D3DSURFACE_DESC { D3DFORMAT Format; D3DRESOURCETYPE Type; DWORD Usage; D3DPOOL Pool; D3DMULTISAMPLE_TYPE MultiSampleType; DWORD MultiSampleQuality; UINT Width; UINT Height; } D3DSURFACE_DESC, *LPD3DSURFACE_DESC;
Defines resource types.
typedef enum D3DRESOURCETYPE { D3DRTYPE_SURFACE = 1, D3DRTYPE_VOLUME = 2, D3DRTYPE_TEXTURE = 3, D3DRTYPE_VOLUMETEXTURE = 4, D3DRTYPE_CubeTexture = 5, D3DRTYPE_VERTEXBUFFER = 6, D3DRTYPE_INDEXBUFFER = 7, D3DRTYPE_FORCE_DWORD = 0x7fffffff, } D3DRESOURCETYPE, *LPD3DRESOURCETYPE;
Sets the sampler state value.
HRESULT SetSamplerState( DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value );
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.
来看看D3DSAMPLERSTATETYPE的具体定义:
Sampler states define texture sampling operations such as texture addressing and texture filtering. Some sampler states set-up vertex processing, and some set-up pixel processing. Sampler states can be saved and restored using stateblocks (see State Blocks Save and Restore State (Direct3D 9)).
typedef enum D3DSAMPLERSTATETYPE { D3DSAMP_ADDRESSU = 1, D3DSAMP_ADDRESSV = 2, D3DSAMP_ADDRESSW = 3, D3DSAMP_BORDERCOLOR = 4, D3DSAMP_MAGFILTER = 5, D3DSAMP_MINFILTER = 6, D3DSAMP_MIPFILTER = 7, D3DSAMP_MIPMAPLODBIAS = 8, D3DSAMP_MAXMIPLEVEL = 9, D3DSAMP_MAXANISOTROPY = 10, D3DSAMP_SRGBTEXTURE = 11, D3DSAMP_ELEMENTINDEX = 12, D3DSAMP_DMAPOFFSET = 13, D3DSAMP_FORCE_DWORD = 0x7fffffff, } D3DSAMPLERSTATETYPE, *LPD3DSAMPLERSTATETYPE;
对于过滤技术来说,Type参数可取值D3DSAMP_MIPFILTER,D3DSAMP_MAGFILTER和 D3DSAMP_MINFILTER,而Value参数可取如下类型的枚举值。
Defines texture filtering modes for a texture stage.
typedef enum D3DTEXTUREFILTERTYPE { D3DTEXF_NONE = 0, D3DTEXF_POINT = 1, D3DTEXF_LINEAR = 2, D3DTEXF_ANISOTROPIC = 3, D3DTEXF_PYRAMIDALQUAD = 6, D3DTEXF_GAUSSIANQUAD = 7, D3DTEXF_FORCE_DWORD = 0x7fffffff, } D3DTEXTUREFILTERTYPE, *LPD3DTEXTUREFILTERTYPE;
To check if a format supports texture filter types other than D3DTEXF_POINT (which is always supported), call IDirect3D9::CheckDeviceFormat with D3DUSAGE_QUERY_FILTER.
Set a texture stage's magnification filter by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MAGFILTER value as the second parameter and one member of this enumeration as the third parameter.
Set a texture stage's minification filter by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MINFILTER value as the second parameter and one member of this enumeration as the third parameter.
Set the texture filter to use between-mipmap levels by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MIPFILTER value as the second parameter and one member of this enumeration as the third parameter.
Not all valid filtering modes for a device will apply to volume maps. In general, D3DTEXF_POINT and D3DTEXF_LINEAR magnification filters will be supported for volume maps. If D3DPTEXTURECAPS_MIPVOLUMEMAP is set, then the D3DTEXF_POINT mipmap filter and D3DTEXF_POINT and D3DTEXF_LINEAR minification filters will be supported for volume maps. The device may or may not support the D3DTEXF_LINEAR mipmap filter for volume maps. Devices that support anisotropic filtering for 2D maps do not necessarily support anisotropic filtering for volume maps. However, applications that enable anisotropic filtering will receive the best available filtering (probably linear) if anisotropic filtering is not supported.
纹理地址模式
纹理源图像的像素点都用纹理坐标系的[0, 1] x [0, 1]范围内的坐标来量度,如果选定的顶点纹理坐标u和v大于1或小于0时,那么对应的纹理像素点在纹理源图上是不存在的。因此需要用相应的纹理地址模式来寻址,确定该顶点颜色值应该采用的纹理像素颜色值。由此可见,当选定的待渲染三角形面顶点的纹理坐标超出[0, 1]区间时,可获得一些特别的渲染效果。
纹理地址模式具有包装模式(Wrap),镜像模式(Mirror),夹子模式(Clamp),边界模式(Border)和一次镜像模式(MirrorOnce)等多种寻址控制方式,来看看这些模式的枚举定义:
Defines constants that describe the supported texture-addressing modes.
typedef enum D3DTEXTUREADDRESS { D3DTADDRESS_WRAP = 1, D3DTADDRESS_MIRROR = 2, D3DTADDRESS_CLAMP = 3, D3DTADDRESS_BORDER = 4, D3DTADDRESS_MIRRORONCE = 5, D3DTADDRESS_FORCE_DWORD = 0x7fffffff, } D3DTEXTUREADDRESS, *LPD3DTEXTUREADDRESS;
头文件使用结构体CUSTOM_VERTEX定义了一个正方形的顶点格式,包括顶点坐标和顶点纹理坐标,Set_Texture_Address_Mode函数用来设置纹理地址模式,Render函数将使用三角形带方式进行渲染,并将纹理对象贴在正方形面上。
来看看TextureAddress.cpp的实现:
/************************************************************************************* [Implement File] PURPOSE: Define for texture mapped. *************************************************************************************/ #include "GE_COMMON.h" #include "TextureAddress.h" //------------------------------------------------------------------------------------ // Constructor, initialize all pointer with NULL. //------------------------------------------------------------------------------------ TEXTURE_ADDRESS::TEXTURE_ADDRESS() { _d3d = NULL; _d3d_device = NULL; _vertex_buffer = NULL; _d3d_texture = NULL; } //------------------------------------------------------------------------------------ // Destructor, release resource allocated for Direct3D. //------------------------------------------------------------------------------------ TEXTURE_ADDRESS::~TEXTURE_ADDRESS() { Release_Direct3D(); } //------------------------------------------------------------------------------------ // Create direct3D interface and direct3D device. //------------------------------------------------------------------------------------ bool TEXTURE_ADDRESS::Create_D3D_Device(HWND hwnd, bool full_screen) { // Create a IDirect3D9 object and returns an interace to it. _d3d = Direct3DCreate9(D3D_SDK_VERSION); if(_d3d == NULL) return false; // retrieve adapter capability D3DCAPS9 d3d_caps; _d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3d_caps); bool hardware_process_enable = (d3d_caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ? true : false); // Retrieves the current display mode of the adapter. D3DDISPLAYMODE display_mode; if(FAILED(_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &display_mode))) return false; // set present parameter for direct3D device D3DPRESENT_PARAMETERS present_param = {0}; present_param.BackBufferWidth = WINDOW_WIDTH; present_param.BackBufferHeight = WINDOW_HEIGHT; present_param.BackBufferFormat = display_mode.Format; present_param.BackBufferCount = 1; present_param.hDeviceWindow = hwnd; present_param.Windowed = !full_screen; present_param.SwapEffect = D3DSWAPEFFECT_FLIP; present_param.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; // Creates a device to represent the display adapter. DWORD behavior_flags; behavior_flags = hardware_process_enable ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING; if(FAILED(_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, behavior_flags, &present_param, &_d3d_device))) { return false; } // create successfully return true; } //------------------------------------------------------------------------------------ // Initialize vertex buffer. //------------------------------------------------------------------------------------ bool TEXTURE_ADDRESS::Init_Vertex_Buffer() { CUSTOM_VERTEX custom_vertex[] = { {100.0f, 100.0f, 0.0f, 1.0f, 0.0f, 0.0f}, {380.0f, 100.0f, 0.0f, 1.0f, 3.0f, 0.0f}, {100.0f, 380.0f, 0.0f, 1.0f, 0.0f, 3.0f}, {380.0f, 380.0f, 0.0f, 1.0f, 3.0f, 3.0f} }; BYTE* vertex_data; // create vertex buffer if(FAILED(_d3d_device->CreateVertexBuffer(4 * sizeof(CUSTOM_VERTEX), 0, CUSTOM_VERTEX_FVF, D3DPOOL_MANAGED, &_vertex_buffer, NULL))) { return false; } // get data pointer to vertex buffer if(FAILED(_vertex_buffer->Lock(0, 0, (void **) &vertex_data, 0))) return false; // copy custom vertex data into vertex buffer memcpy(vertex_data, custom_vertex, sizeof(custom_vertex)); // unlock vertex buffer _vertex_buffer->Unlock(); return true; } //------------------------------------------------------------------------------------ // Sets the sampler state value. //------------------------------------------------------------------------------------ void TEXTURE_ADDRESS::Set_Texture_Address_Mode(int mode) { switch(mode) { case D3DTADDRESS_WRAP: _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); break; case D3DTADDRESS_MIRROR: _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR); _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR); break; case D3DTADDRESS_CLAMP: _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); break; case D3DTADDRESS_BORDER: _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); break; case D3DTADDRESS_MIRRORONCE: _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRRORONCE); _d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRRORONCE); break; } } //------------------------------------------------------------------------------------ // Render object. //------------------------------------------------------------------------------------ void TEXTURE_ADDRESS::Render() { if(_d3d_device == NULL) return; // clear surface with color white _d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 1.0, 0); // begin scene _d3d_device->BeginScene(); // Binds a vertex buffer to a device data stream. _d3d_device->SetStreamSource(0, _vertex_buffer, 0, sizeof(CUSTOM_VERTEX)); // Sets the current vertex stream declaration. _d3d_device->SetFVF(CUSTOM_VERTEX_FVF); // Creates a texture from a file. if(FAILED(D3DXCreateTextureFromFile(_d3d_device, _T("tiger.jpg"), &_d3d_texture))) { MessageBox(NULL, "Create texture interface failed.", "ERROR", MB_OK); return; } // Assigns a texture to a stage for a device. _d3d_device->SetTexture(0, _d3d_texture); // Renders a sequence of nonindexed, geometric primitives of the specified type from the current // set of data input streams. _d3d_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); // end scene _d3d_device->EndScene(); // Presents the contents of the next buffer in the sequence of back buffers owned by the device. _d3d_device->Present(NULL, NULL, NULL, NULL); } //------------------------------------------------------------------------------------ // Release resource allocated for Direct3D. //------------------------------------------------------------------------------------ void TEXTURE_ADDRESS::Release_Direct3D() { Safe_Release(_d3d_texture); Safe_Release(_vertex_buffer); Safe_Release(_d3d_device); Safe_Release(_d3d); }
再来看看测试代码:
/************************************************************************************* [Implement File] PURPOSE: Test for texture render. *************************************************************************************/ #define DIRECTINPUT_VERSION 0x0800 #include "GE_APP.h" #include "GE_INPUT.h" #include "TextureAddress.h" #pragma warning(disable : 4305 4996) int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR cmd_line, int cmd_show) { GE_APP ge_app; GE_INPUT ge_input; TEXTURE_ADDRESS texture_address; MSG msg = {0}; // create window if(! ge_app.Create_Window("Material and light test", instance, cmd_show)) return false; HWND hwnd = ge_app.Get_Window_Handle(); HDC hdc = GetDC(hwnd); // create directinput ge_input.Create_Input(instance, hwnd); SetWindowPos(hwnd, 0, 0,0,0,0, SWP_NOSIZE); SetCursorPos(0, 0); // Create direct3D interface and direct3D device. if(! texture_address.Create_D3D_Device(hwnd, false)) return false; // Initialize vertex buffer with curstom vertex structure. if(! texture_address.Init_Vertex_Buffer()) return false; while(msg.message != WM_QUIT) { if(PeekMessage(&msg, NULL, 0,0 , PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // read data from keyboard buffer if(ge_input.Read_Keyboard()) { bool key_w_pressed = ge_input.Is_Key_Pressed(DIK_W); bool key_m_pressed = ge_input.Is_Key_Pressed(DIK_M); bool key_c_pressed = ge_input.Is_Key_Pressed(DIK_C); bool key_b_pressed = ge_input.Is_Key_Pressed(DIK_B); bool key_o_pressed = ge_input.Is_Key_Pressed(DIK_O); const char* text = NULL; // set texture address mode if(key_w_pressed || key_m_pressed || key_c_pressed || key_b_pressed || key_o_pressed) { if(key_w_pressed) { texture_address.Set_Texture_Address_Mode(D3DTADDRESS_WRAP); text = "wrap mode"; } if(key_m_pressed) { texture_address.Set_Texture_Address_Mode(D3DTADDRESS_MIRROR); text = "morror mode"; } if(key_c_pressed) { texture_address.Set_Texture_Address_Mode(D3DTADDRESS_CLAMP); text = "clamp mode"; } if(key_b_pressed) { texture_address.Set_Texture_Address_Mode(D3DTADDRESS_BORDER); text = "address border mode"; } if(key_o_pressed) { texture_address.Set_Texture_Address_Mode(D3DTADDRESS_MIRRORONCE); text = "address mirror once mode"; } // render object texture_address.Render(); // print hint information TextOut(hdc, WINDOW_WIDTH - 200, WINDOW_HEIGHT - 100, text, (int) strlen(text)); } // press "ESC", close window. if(ge_input.Is_Key_Pressed(DIK_ESCAPE)) PostQuitMessage(0); } } } UnregisterClass(WINDOW_CLASS_NAME, instance); return true; }
按下W键将启用包裹(Wrap)模式,按下M键将启用镜像(Mirror)模式,按下C键将启用夹子(Clamp)模式,按下B键将启用边界(Border)模式,按下O键将启用一次镜像(MirrorOnce)模式。 运行效果: 包裹模式 镜像模式 夹子模式 边界模式 一次镜像模式
文章浏览阅读1.6k次,点赞5次,收藏20次。【有害垃圾】:电池(1 号、2 号、5 号)、过期药品或内包装等;【可回收垃圾】:易拉罐、小号矿泉水瓶;【厨余垃圾】:小土豆、切过的白萝卜、胡萝卜,尺寸为电池大小;【其他垃圾】:瓷片、鹅卵石(小土豆大小)、砖块等。文件结构|----classes.txt # 标签种类|----data-txt\ # 数据集文件集合|----images\ # 数据集图片|----labels\ # yolo标签。_垃圾回收数据集
文章浏览阅读272次。之前写到 通过封装的API 已经可以做到使用redis进行缓存天气信息但是这一操作每次都由客户使用时才进行更新 不友好 所以应该自己实现半小时的定时存入redis 使用quartz框架 首先添加依赖build.gradle中// Quartz compile('org.springframework.boot:spring-boot-starter-quartz'..._cityid=101280803
文章浏览阅读1.8k次,点赞2次,收藏8次。对于使用触发事件来反应的按钮传递参数如下:可以通过lambda对function的参数传递:t.Bind(wx.EVT_BUTTON, lambda x, textctrl=t: self.input_fun(event=x, textctrl=textctrl))前提需要self.input_fun(self,event,t):传入参数而同时两个Frame之间的参数传..._wxpython frame.bind
文章浏览阅读1.9k次。最近接到一个任务要开发消消乐小游戏,当然首先就想到乐cocosCreator来作为开发工具。开发本身倒没有多少难点。消消乐的开发官网发行的书上有专门讲到。下面主要总结一下开发中遇到的问题以及解决方法屏幕适配由于设计尺寸是750*1336,如果适应高度,则在iphonX下,内容会超出屏幕宽度。按宽适应,iphon4下内容会超出屏幕高度。所以就需要根据屏幕比例来动态设置适配策略。 onLoad..._750*1336
文章浏览阅读745次,点赞21次,收藏21次。web项目的框架,通常更简单的数据源。21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们所认识,科学化的管理,使信息存储达到准确、快速、完善,并能提高工作管理效率,促进其发展。论文主要是对银行贷款管理系统进行了介绍,包括研究的现状,还有涉及的开发背景,然后还对系统的设计目标进行了论述,还有系统的需求,以及整个的设计方案,对系统的设计以及实现,也都论述的比较细致,最后对银行贷款管理系统进行了一些具体测试。_vue3重构信贷管理系统
文章浏览阅读774次。题目描述原题目戳这里小明过生日的时候,爸爸送给他一副乌龟棋当作礼物。乌龟棋的棋盘是一行 NNN 个格子,每个格子上一个分数(非负整数)。棋盘第 111 格是唯一的起点,第 NNN 格是终点,游戏要求玩家控制一个乌龟棋子从起点出发走到终点。乌龟棋中 MMM 张爬行卡片,分成 444 种不同的类型( MMM 张卡片中不一定包含所有 444 种类型的卡片,见样例),每种类型的卡片上分别标有 1,2,3,41, 2, 3, 41,2,3,4 四个数字之一,表示使用这种卡片后,乌龟棋子将向前爬行相应的格子数
文章浏览阅读1.5k次。吐槽内存泄露 ? 内存暴涨 ? OOM ?首先提一下我自己曾经历过多次内存泄露,到底有几次? 我自己心里悲伤的回想了下,造成线上影响的内存泄露事件有将近5次了,没上线就查出内存暴涨次数可能更多。这次不是最惨,相信也不会是最后的内存的泄露。有人说,内存泄露对于程序员来说,是个好事,也是个坏事。 怎么说? 好事在于,技术又有所长进,经验有所心得…. 毕竟不是所有程序员都写过OOM的服务…. 坏事..._python内存泄露
文章浏览阅读747次。1.sensor typeTYPE_ACCELEROMETER=1 TYPE_MAGNETIC_FIELD=2 (what's value mean at x and z axis)TYPE_ORIENTATION=3TYPE_GYROSCOPE=4 TYPE_LIGHT=5(in )TYPE_PRESSURE=6TYPE_TEMPERATURE=7TYPE_PRO_draft sensor
文章浏览阅读581次。/* * Copyright (c) 2009 湖南师范大学数计院 一心飞翔项目组 * All Right Reserved * * 文件名:matrix.cpp 定义Point、Node、Matrix类的各个方法 * 摘 要:定义矩阵类,包括矩阵的相关信息和方法 * * 作 者:刘 庆 * 修改日期:2009年7月19日21:15:12 **/
文章浏览阅读1.7w次,点赞6次,收藏20次。HTML不再推荐页面中使用框架集,因此HTML5删除了<frameset>、<frame>和<noframes>这三个元素。不过HTML5还保留了<iframe>元素,该元素可以在普通的HTML页面中使用,生成一个行内框架,可以直接放在HTML页面的任意位置。除了指定id、class和style之外,还可以指定如下属性:src 指定一个UR..._iframe allow-top-navigation
文章浏览阅读785次,点赞29次,收藏12次。Zipkin 是 Twitter 的一个开源项目,它基于 Google Dapper 实现,它致力于收集服务的定时数据,以解决微服务架构中的延迟问题,包括数据的收集、存储、查找和展现。我们可以使用它来收集各个服务器上请求链路的跟踪数据,并通过它提供的 REST API 接口来辅助我们查询跟踪数据以实现对分布式系统的监控程序,从而及时地发现系统中出现的延迟升高问题并找出系统性能瓶颈的根源。除了面向开发的 API 接口之外,它也提供了方便的 UI 组件来帮助我们直观的搜索跟踪信息和分析请求链路明细,
文章浏览阅读358次。“随着天网工程的建设,中国已经建成世界上规模最大的视频监控网,摄像头总 数超过2000万个,成为世界上最安全的国家。视频图像及配套数据已经应用在反恐维稳、治安防控、侦查破案、交通行政管理、服务民生等各行业各领域。烁博科技视频安全核心能力:精准智能数据采集能力:在建设之初即以应用需求为导向,开展点位选择、设备选型等布建工作,实现前端采集设备的精细化部署。随需而动的AI数据挖掘能力:让AI所需要的算力、算法、数据、服务都在应用需求的牵引下实现合理的调度,实现解析能力的最大化。完善的数据治理能力:面_2018年8月由于某知名视频监控厂商多款摄像机存在安全漏洞