void TextureDx11::initWithTexture1D(ID3D11Texture1D* tex1d) { D3D11_TEXTURE1D_DESC desc; tex1d->GetDesc(&desc); _config = Config(); _config.format = TranslateFromDxgiFormat(desc.Format); _config.usage = TranslateUsage(desc.BindFlags, desc.CPUAccessFlags); _config.flags = TranslateFlags(desc.MiscFlags); _config.lastMip = desc.MipLevels - 1; _config.width = desc.Width; _config.arrayLength = desc.ArraySize; _d3dResource = tex1d; }
void TextureDx11::initWithTexture3D(ID3D11Texture3D* tex3d) { D3D11_TEXTURE3D_DESC desc; tex3d->GetDesc(&desc); _config = Config(); _config.format = TranslateFromDxgiFormat(desc.Format); _config.usage = TranslateUsage(desc.BindFlags, desc.CPUAccessFlags); _config.flags = TranslateFlags(desc.MiscFlags); _config.lastMip = desc.MipLevels - 1; _config.width = desc.Width; _config.height = desc.Height; _config.depth = desc.Depth; _d3dResource = tex3d; }
void AnimaMouseInteractor::HandleMessage(HWND hWnd, AUint message, WPARAM wParam, LPARAM lParam, AnimaMouseInteractor* interactor) { switch (message) { case WM_MOUSEMOVE: { RECT rc; GetClientRect(hWnd, &rc); AFloat xPos = (AFloat)GET_X_LPARAM(lParam); AFloat yPos = (AFloat)(rc.bottom - GET_Y_LPARAM(lParam)); POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); if (PtInRect(&rc, point)) { AnimaVertex2f pt(xPos, yPos); AnimaVertex2f delta = interactor->_mousePosition - pt; AnimaVertex2f size((AFloat)rc.right - (AFloat)rc.left, (AFloat)rc.bottom - (AFloat)rc.top); // Siccome il messaggio di mouse move viene lanciato anche al primo click con i tasti del mouse, // controllo se la posizione non è diversa da quella dell'ultima posizione nota e il flag _mouseMoved è falso // che in questo caso significa che ho appena fatto click con un pulsante e non devo mandare il messaggio di mouse move // o dragged e soprattuo non impostare il flag _mouseMoved a true, altrimenti non verranno mai inviati dei messaggi di click if (pt.x == interactor->_mousePosition.x && pt.y == interactor->_mousePosition.y && interactor->_mouseMoved == false) return; interactor->_mousePosition = pt; interactor->_mouseMoved = true; interactor->_delta += delta; interactor->_modifiers = TranslateFlags(); interactor->_leftButtonDown = false; interactor->_rightButtonDown = false; if ((wParam & MK_LBUTTON) == MK_LBUTTON) { interactor->_leftButtonDown = true; AnimaEventArgs* args = new AnimaMouseDraggedEventArgs(interactor, pt, size, TranslateFlags(), delta); interactor->LaunchEvent("onLeftMouseDragged", args); delete args; args = nullptr; } else if ((wParam & MK_RBUTTON) == MK_RBUTTON) { interactor->_rightButtonDown = true; AnimaEventArgs* args = new AnimaMouseDraggedEventArgs(interactor, pt, size, TranslateFlags(), delta); interactor->LaunchEvent("onRightMouseDragged", args); delete args; args = nullptr; } } break; } case WM_LBUTTONDOWN: { RECT rc; GetClientRect(hWnd, &rc); AFloat xPos = (AFloat)GET_X_LPARAM(lParam); AFloat yPos = (AFloat)(rc.bottom - GET_Y_LPARAM(lParam)); POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); if (PtInRect(&rc, point)) { AnimaVertex2f pt(xPos, yPos); AnimaVertex2f size((AFloat)rc.right - (AFloat)rc.left, (AFloat)rc.bottom - (AFloat)rc.top); interactor->_mousePosition = pt; interactor->_mouseMoved = false; interactor->_delta = AnimaVertex2f(0, 0); interactor->_modifiers = TranslateFlags(); interactor->_leftButtonDown = true; interactor->_rightButtonDown = false; AnimaEventArgs* args = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onLeftMouseDown", args); delete args; args = nullptr; } break; } case WM_RBUTTONDOWN: { RECT rc; GetClientRect(hWnd, &rc); AFloat xPos = (AFloat)GET_X_LPARAM(lParam); AFloat yPos = (AFloat)(rc.bottom - GET_Y_LPARAM(lParam)); POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); if (PtInRect(&rc, point)) { AnimaVertex2f pt(xPos, yPos); AnimaVertex2f size((AFloat)rc.right - (AFloat)rc.left, (AFloat)rc.bottom - (AFloat)rc.top); interactor->_mousePosition = pt; interactor->_mouseMoved = false; interactor->_delta = AnimaVertex2f(0, 0); interactor->_modifiers = TranslateFlags(); interactor->_leftButtonDown = false; interactor->_rightButtonDown = true; AnimaEventArgs* args = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onRightMouseDown", args); delete args; args = nullptr; } break; } case WM_LBUTTONUP: { RECT rc; GetClientRect(hWnd, &rc); AFloat xPos = (AFloat)GET_X_LPARAM(lParam); AFloat yPos = (AFloat)(rc.bottom - GET_Y_LPARAM(lParam)); POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); if (PtInRect(&rc, point)) { AnimaVertex2f pt(xPos, yPos); AnimaVertex2f size((AFloat)rc.right - (AFloat)rc.left, (AFloat)rc.bottom - (AFloat)rc.top); interactor->_mousePosition = pt; interactor->_delta = AnimaVertex2f(0, 0); interactor->_modifiers = TranslateFlags(); interactor->_leftButtonDown = false; interactor->_rightButtonDown = false; AnimaEventArgs* argsUp = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onLeftMouseUp", argsUp); delete argsUp; argsUp = nullptr; if (interactor->_mouseMoved == false) { AnimaEventArgs* argsClick = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onLeftMouseClick", argsClick); delete argsClick; argsClick = nullptr; } } break; } case WM_RBUTTONUP: { RECT rc; GetClientRect(hWnd, &rc); AFloat xPos = (AFloat)GET_X_LPARAM(lParam); AFloat yPos = (AFloat)(rc.bottom - GET_Y_LPARAM(lParam)); POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); if (PtInRect(&rc, point)) { AnimaVertex2f pt(xPos, yPos); AnimaVertex2f size((AFloat)rc.right - (AFloat)rc.left, (AFloat)rc.bottom - (AFloat)rc.top); interactor->_mousePosition = pt; interactor->_delta = AnimaVertex2f(0, 0); interactor->_modifiers = TranslateFlags(); interactor->_leftButtonDown = false; interactor->_rightButtonDown = false; AnimaEventArgs* argsUp = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onRightMouseUp", argsUp); delete argsUp; argsUp = nullptr; if (interactor->_mouseMoved == false) { AnimaEventArgs* argsClick = new AnimaMouseEventArgs(interactor, pt, size, TranslateFlags()); interactor->LaunchEvent("onRightMouseClick", argsClick); delete argsClick; argsClick = nullptr; } } break; } } }