资源简介

用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] = ‘\0‘;
ofn.nMaxFile = sizeof(strFile);
ofn.lpstrFilter = L“AVI\0*.avi\0MKV\0*.mkv\0MP4\0*.mp4\0FLV\0*.flv\
\0MOV\0*.mov\0RMVB\0*.rmvb;*.rm\0MPEG\0*.mpg;*.mpeg\0*3G*\0*.3gp;*.3g2;*.3gp2;*.3gpp\
\0WMV\0*.wmv\0OGG\0*.ogg\0All\0*.*“;
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

评论

共有 条评论