Už mi to jde celý zkomplikovat a myslím že už mám z:
http://nehe.ceske-hry.cz/tut_35.php
uplně všechny funkce ,ale teď nevím co mám napsat aby se mi to video vykreslilo:
mám tento kod: myslím že se to bude psát do onDisplay
#include <gl/glut.h>
#include <windows.h>
#include "NeHeGL.h"
#include <vfw.h>
#pragma comment(lib, "vfw32.lib")
GL_Window* g_window;
Keys* g_keys;
float angle;int next;int frame = 0;int effect;bool env = TRUE;bool bg = TRUE;bool sp;bool ep;bool bp;AVISTREAMINFO psi;PAVISTREAM pavi;PGETFRAME pgf;BITMAPINFOHEADER bmih;long lastframe;int width;int height;char* pdata;int mpf;GLUquadricObj *quadratic;HDRAWDIB hdd;HBITMAP hBitmap;HDC hdc = CreateCompatibleDC(0);
void flipIt(void* buffer)
{
void* b = buffer;// Ukazatel na buffer
__asm // ASM kód
{
mov ecx, 256*256
mov ebx, b
label:
mov al, [ebx+0]
mov ah, [ebx+2]
mov [ebx+2], al
mov [ebx+0], ah
add ebx, 3
dec ecx
jnz label
}
}
unsigned char* data = 0;
HWND hWnd;
void OpenAVI(LPCSTR szFile)
{
TCHAR title[100];
AVIFileInit();
AVIStreamInfo(pavi, &psi, sizeof(psi));
width = psi.rcFrame.right - psi.rcFrame.left;
height = psi.rcFrame.bottom - psi.rcFrame.top;
lastframe = AVIStreamLength(pavi);
mpf = AVIStreamSampleToTime(pavi, lastframe) / lastframe;
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biWidth = 256;
bmih.biHeight = 256;
bmih.biCompression = BI_RGB;
hBitmap = CreateDIBSection(hdc, (BITMAPINFO*)(&bmih), DIB_RGB_COLORS, (void**)(&data), NULL, NULL);
SelectObject(hdc, hBitmap);
pgf = AVIStreamGetFrameOpen(pavi, NULL);
if (pgf == NULL)
{
MessageBox (HWND_DESKTOP, TEXT("Failed To Open The AVI Frame"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
}
wsprintf (title, TEXT("NeHe's AVI Player: Width: %d, Height: %d, Frames: %d"), width, height, lastframe);
}
void GrabAVIFrame(int frame)
{
LPBITMAPINFOHEADER lpbi;// Hlavička bitmapy
lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);
pdata = (char *)lpbi + lpbi->biSize + lpbi->biClrUsed * sizeof(RGBQUAD);
DrawDibDraw(hdd, hdc, 0, 0, 256, 256, lpbi, pdata, 0, 0, width, height, 0);
flipIt(data);// Prohodí R a B složku pixelů
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, data);
}
void CloseAVI(void)
{
DeleteObject(hBitmap);
DrawDibClose(hdd);
AVIStreamGetFrameClose(pgf);
AVIStreamRelease(pavi);
AVIFileExit();
}
BOOL Initialize (GL_Window* window, Keys* keys)
{
g_window = window;
g_keys = keys;
angle = 0.0f;
hdd = DrawDibOpen();
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
quadratic = gluNewQuadric();
gluQuadricNormals(quadratic, GLU_SMOOTH);
gluQuadricTexture(quadratic, GL_TRUE);
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
OpenAVI("data/face2.avi");
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
return TRUE;
}
void Deinitialize(void)
{
CloseAVI();
}
void Update(DWORD milliseconds)
{
if ((g_keys->keyDown[' ']) && !sp)
{
sp = TRUE;
effect++;
if (effect > 3)
{
effect = 0;
}
}
if (!g_keys->keyDown[' '])
{
sp = FALSE;
}
if ((g_keys->keyDown['B']) && !bp)
{
bp = TRUE;
bg = !bg;
}
if (!g_keys->keyDown['B'])
{
bp = FALSE;
}
if ((g_keys->keyDown['E']) && !ep)
{
ep = TRUE;
env = !env;
}
if (!g_keys->keyDown['E'])
{
ep = FALSE;
}
angle += (float)(milliseconds) / 60.0f;
next += milliseconds;
frame = next / mpf;
if (frame >= lastframe)
{
frame = 0;// Přetočí video na začátek
next = 0;// Nulování času
}
}
void onResize(int w, int h) {glMatrixMode(GL_PROJECTION);glLoadIdentity();glViewport(0, 0, w, h);gluPerspective(45,(double)w/(double)h,1,100);glMatrixMode(GL_MODELVIEW);}
void init(){glEnable(GL_DEPTH_TEST);glClearColor(1.0,1.0,1.0,1.0);glEnable(GL_LIGHTING);glEnable(GL_LIGHT0);}
void onDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnd();glutSwapBuffers();
}
int main (int argc, char **argv) {glutInit(&argc,argv);glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);glutInitWindowSize(640,480);glutInitWindowPosition(10,10);glutCreateWindow("OpenGL");glutDisplayFunc(init);glutIdleFunc(onDisplay);glutReshapeFunc(onResize);glutMainLoop();return 0;}