OpenGL鱼眼镜头特效的视频播放器 基于万能的VLC


用OpenGL纹理实现的鱼眼镜头,两种贴图方式。数据源是窗口的HBITMAP到图像数据、VLC的帧渲染到内存的图像数据。
资源截图
代码片段和文件信息
#define _WIN32_WINNT  0x0600
/**************************
 * Includes
 *
 **************************/
//#define UNICODE

#include 
#include 
#include //注意定义顺序 
#include 
#include 

#include 

#include 
#include 

/**************************
 * Function Declarations
 *
 **************************/

LRESULT CALLBACK WndProc (HWND hWnd UINT message
WPARAM wParam LPARAM lParam);
void EnableOpenGL (HWND hWnd HDC *hDC HGLRC *hRC);
void DisableOpenGL (HWND hWnd HDC hDC HGLRC hRC);

void OpenMediaFile();
void* VideoLockCallBack(void *opaque void **planes);
void VideoUnLockCallBack(void *opaque void *picture void *const *planes);
void VideoDisplayCallBack(void *opaque void *picture);
WCHAR* AnsiToUnicode(char * ansiStr);
char *UnicodeToUtf8(WCHAR* uniStr);

/**************************
 * WinMain
 *
 **************************/
#define DIV 64
#define PI 3.1416f

int *pBmpData;
unsigned dataWidthdataHeight;
GLuint texture[1];
HWND hWindow=0;
int FishEye=0;
float radius=10; 

BOOL hasMedia=FALSE;
int bmpRotateZ=0;
BOOL mirrorX=FALSE;
BOOL mirrorY=FALSE;
libvlc_instance_t *vlcInstance;
libvlc_media_player_t *vlcPlayer;
libvlc_media_t *vlcMedia;

OPENFILENAMEW ofn;
WCHAR strFile[260];       

int WINAPI WinMain (HINSTANCE hInstance
                    HINSTANCE hPrevInstance
                    LPSTR lpCmdLine
                    int iCmdShow)
{
    WNDCLASS wc;
    HWND hWnd;
    HDC hDC;
    HGLRC hRC;        
    MSG msg;
    BOOL bQuit = FALSE;

    /* register window class */
    wc.style = CS_OWNDC;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon (NULL IDI_APPLICATION);
    wc.hCursor = LoadCursor (NULL IDC_ARROW);
    wc.hbrBackground = (HBRUSH) GetStockobject (BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = “FishEye“;
    RegisterClass (&wc);

    /* create main window */
    hWnd = CreateWindow (
      “FishEye“ “FishEye“ 
      WS_OVERLAPPEDWINDOW|WS_VISIBLE
      0 0 800 600
      NULL NULL hInstance NULL);
    pBmpData=0;
    ZeroMemory(&ofnsizeof(OPENFILENAME));
    ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = strFile;
ofn.lpstrFile[0] = ‘‘;
ofn.nMaxFile = sizeof(strFile);
ofn.lpstrFilter = L“AVI*.aviMKV*.mkvMP4*.mp4FLV*.flv
MOV*.movRMVB*.rmvb;*.rmMPEG*.mpg;*.mpeg*3G**.3gp;*.3g2;*.3gp2;*.3gpp
WMV*.wmvOGG*.oggAll*.*“;
ofn.nFilterIndex = 1;
ofn.lpstrFiletitle = NULL;
ofn.nMaxFiletitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

vlcInstance = libvlc_new(0NULL);
vlcPlayer = libvlc_media_player_new(vlcInstance);
OpenMediaFile();
MoveWindow(hWnd00dataWidthdataHeightTRUE);
    /* enable OpenGL for the wind

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)