《GPU高性能编程》——cpu_anim.h

《GPU 高性能编程 CUDA 实战》书中 cpu_anim.h 头文件分享《GPU高性能编程CUDA实战》是一本不错的好书,其中所含示例代码,经常包含有 "cpu_anim.h"等头文件, 为方便学习者查找,将头文件 “cpu_anim.h” 分享在这里。/* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved....
摘要由CSDN通过智能技术生成

《GPU 高性能编程 CUDA 实战》

书中 cpu_anim.h 头文件分享

《GPU高性能编程CUDA实战》是一本不错的好书,其中所含示例代码,经常包含有 "cpu_anim.h"等头文件, 为方便学习者查找,将头文件 “cpu_anim.h” 分享在这里。

/*
 * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
 *
 * NVIDIA Corporation and its licensors retain all intellectual property and
 * proprietary rights in and to this software and related documentation.
 * Any use, reproduction, disclosure, or distribution of this software
 * and related documentation without an express license agreement from
 * NVIDIA Corporation is strictly prohibited.
 *
 * Please refer to the applicable NVIDIA end user license agreement (EULA)
 * associated with this source code for terms and conditions that govern
 * your use of this NVIDIA software.
 *
 */


#ifndef __CPU_ANIM_H__
#define __CPU_ANIM_H__

#include "gl_helper.h"

#include <iostream>


struct CPUAnimBitmap {
   
    unsigned char    *pixels;
    int     width, height;
    void    *dataBlock;
    void (*fAnim)(void*,int);
    void (*animExit)(void*);
    void (*clickDrag)(void*,int,int,int,int);
    int     dragStartX, dragStartY;

    CPUAnimBitmap( int w, int h, void *d = NULL ) {
   
        width = w;
        height = h;
        pixels = new 
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是一个自定义的手势监听器,主要实现了手势滑动切换视图的功能。具体实现方法如下: 1. 首先,在Activity中创建一个GestureDetector对象,并在onTouchEvent方法中将触摸事件传递给它: ```java private GestureDetector mGestureDetector = null; @Override public boolean onTouchEvent(MotionEvent event) { return mGestureDetector.onTouchEvent(event); } ``` 2. 然后,在构造函数中初始化GestureDetector对象,并将自定义的MyGestureListener对象设置为它的监听器: ```java public MyActivity() { mGestureDetector = new GestureDetector(this, new MyGestureListener()); } ``` 3. 最后,在MyGestureListener中实现onFling方法,该方法会在手势滑动时被调用。在onFling方法中,根据手势滑动的方向来切换视图: ```java private class MyGestureListener extends GestureDetector.SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (e1.getX() - e2.getX() > MIN_MOVE) { // 向左滑动 vflp_help.setInAnimation(mContext, R.anim.right_in); vflp_help.setOutAnimation(mContext, R.anim.right_out); vflp_help.showNext(); } else if (e2.getX() - e1.getX() > MIN_MOVE) { // 向右滑动 vflp_help.setInAnimation(mContext, R.anim.left_in); vflp_help.setOutAnimation(mContext, R.anim.left_out); vflp_help.showPrevious(); } return true; } } ``` 在这段代码中,MIN_MOVE表示最小的手势滑动距离,可以根据需要进行调整。当用户向左滑动时,使用R.anim.right_in和R.anim.right_out动画来实现视图的进入和退出;当用户向右滑动时,使用R.anim.left_in和R.anim.left_out动画来实现视图的进入和退出。vflp_help是一个ViewFlipper控件,用于显示多个视图。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值