Example #1
0
File: main.c Project: abitvin/vineo
LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    switch( uMsg )
    {
        case WM_CLOSE: {
            PostQuitMessage( 0 ); break;
        }

        case WM_DESTROY: {
            return 0;
        }

        case WM_LBUTTONDOWN: {
            keys[MOUSE_LB] = 1; break;
        }

        case WM_LBUTTONUP: {
            keys[MOUSE_LB] = 0; break;
        }

        case WM_KEYDOWN: {
            keys[wParam] = 1; break;
        }

        case WM_KEYUP: {
            keys[wParam] = 0; break;
        }

        case WM_MOUSEMOVE:
        {
            mouse_x = LOWORD( lParam );
            mouse_y = HIWORD( lParam );
            break;
        }

        case WM_RBUTTONDOWN: {
            keys[MOUSE_RB] = 1; break;
        }

        case WM_RBUTTONUP: {
            keys[MOUSE_RB] = 0; break;
        }

        case WM_SIZE: {
			resizeScene( screen_w = LOWORD(lParam), screen_h = HIWORD(lParam) ); break;
		}

        default: {
            return DefWindowProc( hwnd, uMsg, wParam, lParam );
        }
    }

    return 0;
}
Example #2
0
void Viewport::initTimers()
{
	resizeTimer.setSingleShot(true);
	connect(&resizeTimer, SIGNAL(timeout()), this, SLOT(resizeScene()));

	QSignalMapper *mapper = new QSignalMapper();
	for (int i = 0; i < 2; ++i) {
		buffers[i].renderedLines = 0;
		buffers[i].renderTimer.setSingleShot(true);
		connect(&buffers[i].renderTimer, SIGNAL(timeout()),
		        mapper, SLOT(map()));
		mapper->setMapping(&buffers[i].renderTimer, i);
	}
	connect(mapper, SIGNAL(mapped(int)),
	        this, SLOT(continueDrawing(int)));
}
Example #3
0
void Scene::resizeCB(UResizeEvent& e)
{
  resizeScene(e, int(e.getView()->getWidth()), int(e.getView()->getHeight()));
}
Example #4
0
File: main.c Project: abitvin/vineo
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
    WNDCLASSEX wcex;
    HWND hwnd;
    HDC hDC;
    HGLRC hRC;
    MSG msg;
    BOOL bQuit = FALSE;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_OWNDC;
    wcex.lpfnWndProc = WindowProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = WINDOW_CLASS;
    wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);;


    if( !RegisterClassEx( &wcex )) {
        return 0;
    }

    hwnd = CreateWindowEx(
        0, WINDOW_CLASS, WINDOW_TITLE,
        //WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
        WS_OVERLAPPEDWINDOW, 30, 20,
        screen_w + GetSystemMetrics( SM_CYFRAME ) * 2,
        screen_h + GetSystemMetrics( SM_CYFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION ),
        NULL, NULL, hInstance, NULL
    );


    ShowWindow( hwnd, nCmdShow );
    enableOpenGL( hwnd, &hDC, &hRC );
    enableOpenAL();
    resizeScene( screen_w, screen_h );

    glEnable( GL_TEXTURE_2D );
    glClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
    glClearDepth( 1.0f );
	glEnable( GL_DEPTH_TEST );
	glDepthFunc( GL_LEQUAL );
    glShadeModel( GL_SMOOTH );
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );




    // FIXME NOPE...audio en video out of sync, packet queue is wel goed
    //char *file = "C:/Users/vin777/Documents/Dump/Films/Monsters.Vs.Aliens.DVDRiP.XviD-JUMANJi/jmj-mona.avi";

    // FIXME NOPE...geen audio codec gevonden
    //char *file = "C:/Users/vin777/Documents/Dump/Films/Monsters.Vs.Aliens.2009.1080p.BluRay.x264-CiNEFiLE.mkv";

    // FIXME OK...foutje in begin van de file maar voor de rest gaat het uitstekend
    //char *file = "C:/Users/vin777/Documents/Dump/Films/Transformers Revenge of the Fallen[2009]DvDrip[Eng]-FXG/Transformers Revenge of the Fallen[2009]DvDrip[Eng]-FXG.avi";

    // De avi file is ook niet helemaal perfect, loopt goed.
    // FIXME NOPE...foutje in begin file en video packet queue buffer altijd leeg?
    //char *file = "../stuff/video.avi";

    // FIXME UPDATE...OK! Stream had een pFormatCtx->start_time, werkt nu! Maar waarom is de audio packet queue nog vol aan het einde?
    // NOPE...audio en beeld out of sync, packet queue is wel goed
    //char *file = "../stuff/video.wmv";


    //char media[] = "C:/Users/vin777/Documents/Dump/Encode/fulco/howtotrainyourdragon-tlr2_h720p_fulco.mp4";
    //char media2[] = "C:/Users/vin777/Documents/Dump/Encode/fulco/julieandjulia-tlr1_h720p_fulco.mp4";
    //char media[] = "http://scfire-mtc-aa03.stream.aol.com:80/stream/1025";
    //char media[] = "http://72.26.204.18:6256#.aac";
    //char media[] = "../DUMP/image.png";
    //char media[] = "./stuff/video.gif";
    //char media2[] = "../DUMP/image.jpg";
    //char media[] = "http://tweakimg.net/g/if/v2/breadcrumb/award_2009_transparent.png";
    //char media2[] = "http://ccms.e-billboard.eu/webcam/?id=19#.jpg";
    //char media[] = "./stuff/music.mp3";



    int i;
    int num_vid = 5;

    char *media[] = {
        "C:/Users/vin777/Documents/Dump/Encode/fulco/howtotrainyourdragon-tlr2_h720p_fulco.mp4",
        "C:/Users/vin777/Documents/Dump/Encode/fulco/julieandjulia-tlr1_h720p_fulco.mp4",
        "C:/Users/vin777/Documents/Dump/Encode/fulco/aliceinwonderland-tsr1_h720p_fulco.mp4",
        "E:/vincent/data/snapshot_0/vincent/films/wake_up/Vincent_van_Ingen-Wake_Up-H264-AAC-720p.mov",
        "http://ccms.e-billboard.eu/webcam/?id=19#.jpg",
    };

    Vineo v[num_vid];

    for( i = 0; i < num_vid; i++ )
    {
        vineoInit( &v[i] );

        glBindTexture( GL_TEXTURE_2D, v[i].tex_gl );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

        vineoOpenAndDecodeThread( &v[i], media[i] );
    }

    float r = 0.0f;
    float x = 0.0f;
    float x_space = 3.0f;
    int num_box = 15;

    int64_t time = av_gettime();
    int64_t ptime = time;
    int64_t ctime = 0;
    int count = 0;
    int max_count = 200;



    while( !bQuit )
    {
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            if( msg.message == WM_QUIT )
            {
                bQuit = 1;
            }
            else
            {
                TranslateMessage( &msg );
                DispatchMessage( &msg );
            }
        }
        else
        {
            ptime = time;
            time = av_gettime();
            ctime += time - ptime;

            if( ++count == max_count )
            {
                float fps = (float)AV_TIME_BASE / (float)ctime * (float)max_count;
                char title[64];

                //printf( "fps: %f\n", fps );
                sprintf( title, "Vineo = OpenGL / OpenAL / FFmpeg, fps: %f", fps );

                SetWindowText( hwnd, title );

                ctime = 0;
                count = 0;
            }


            if( keys[VK_ESCAPE] ) {
                bQuit = 1;
            }


            if( keys[VK_ESCAPE] ) {
                PostQuitMessage( 0 );
            }


            if( keys['R'] )
            {
                for( i = 0; i < num_vid; i++ )
                {
                    vineoClose( &v[i] );
                    //v[i] = vineoNew();
                    vineoInit( &v[i] );

                    glBindTexture( GL_TEXTURE_2D, v[i].tex_gl );
                    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
                    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

                    //vineoOpen( v[i], media[i] );
                    //vineoPlay( v[i] );
                    vineoOpenAndDecodeThread( &v[i], media[i] );
                }
            }


            x += (float)( time - ptime ) / 1000000.0f;

            if( x > num_vid * x_space ) {
                x -= num_vid * x_space;
            }

            r += (float)( time - ptime ) / 100000.0f;

            for( i = 0; i < num_vid; i++ ) {
                vineoFlush( &v[i] );
            }



            glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
            glMatrixMode( GL_MODELVIEW );
            glLoadIdentity();


            // camera
            glRotatef( 45.0f, 0.0f, 1.0f, 0.0f );
            glTranslatef( -x, -0.8f, -8.0f );


            // spiegel reflectie
            for( i = 0; i < num_box; i++ )
            {
                if( !v[i%num_vid].is_frame_flushed ) {
                    continue;
                }

                glPushMatrix();
                    glBindTexture( GL_TEXTURE_2D, v[i%num_vid].tex_gl );
                    glColor3f( 1.0f, 1.0f, 1.0f );
                    glTranslatef( i * x_space, -1.2f, 0.0f );
                    glRotatef( r, 0.0f, 1.0f, 0.0f );
                    glScalef( 1.0f, -1.0f, 1.0f );
                    texCube();
                glPopMatrix();
            }


            // vloer
            glPushMatrix();
                glBindTexture( GL_TEXTURE_2D, 0 );
                glColor4f( 0.0f, 0.0f, 0.0f, 0.8f );
                glBegin( GL_QUADS );
                    glVertex3f( 100.0f, 0.0f,-100.0f );
                    glVertex3f(-100.0f, 0.0f,-100.0f );
                    glVertex3f(-100.0f, 0.0f, 100.0f );
                    glVertex3f( 100.0f, 0.0f, 100.0f );
                glEnd();
            glPopMatrix();


            // top
            for( i = 0; i < num_box; i++ )
            {
                if( !v[i%num_vid].is_frame_flushed ) {
                    continue;
                }

                glPushMatrix();
                    glBindTexture( GL_TEXTURE_2D, v[i%num_vid].tex_gl );
                    glColor3f( 1.0f, 1.0f, 1.0f );
                    glTranslatef( i * x_space, 1.2f, 0.0f );
                    glRotatef( r, 0.0f, 1.0f, 0.0f );
                    texCube();
                glPopMatrix();
            }

            SwapBuffers( hDC );

            PrintMemoryInfo( GetCurrentProcessId() );
        }
    }


    for( i = 0; i < num_vid; i++ ) {
        vineoClose( &v[i] );
    };

    disableOpenAL();
    disableOpenGL( hwnd, hDC, hRC );
    DestroyWindow( hwnd );
    return msg.wParam;
}
//------------------------------------------------------ EVENTS
void MSAParticleSystem3D::windowResized( ofResizeEventArgs&args )
{
    width = args.width;
    height = args.height;
    resizeScene();
}