Example #1
0
// Constructor: init the texture, set starting positions for the object and set texture coordinates
//	Call base constructor to initialize inherited vars
Image::Image(int iHeight, int iWidth, const string& sImage) : Graphic(iHeight, iWidth)
{
	InitializeTexture(&m_pTexture, sImage);

	// Set initial geometry coords
	resetImg();

	m_pTextCoords[0][0] = 0;
	m_pTextCoords[0][1] = 0;
	m_pTextCoords[1][0] = 0;
	m_pTextCoords[1][1] = m_pTexture.height;
	m_pTextCoords[2][0] = m_pTexture.width;
	m_pTextCoords[2][1] = m_pTexture.height;
	m_pTextCoords[3][0] = m_pTexture.width;
	m_pTextCoords[3][1] = 0;
}
Example #2
0
/*
---------------------------------------------------------------------------------------
- Opens An AVI File (szFile)
---------------------------------------------------------------------------------------
*/
bool AviVideoRenderer::OpenAVI(const char * szFile)
{
	// Opens The AVI Stream
	if (AVIStreamOpenFromFileA(&_AVR_pavi, szFile, streamtypeVIDEO, 0, OF_READ, NULL) !=0)
		return false;

	AVIStreamInfo(_AVR_pavi, &_AVR_psi, sizeof(_AVR_psi));						// Reads Information About The Stream Into psi
	_video_width=_AVR_psi.rcFrame.right-_AVR_psi.rcFrame.left;					// Width Is Right Side Of Frame Minus Left
	_video_height=_AVR_psi.rcFrame.bottom-_AVR_psi.rcFrame.top;					// Height Is Bottom Of Frame Minus Top

	_endFrame=AVIStreamLength(_AVR_pavi);							// The Last Frame Of The Stream

	_timeperframe=AVIStreamSampleToTime(_AVR_pavi,_endFrame)/_endFrame;		// Calculate Rough Milliseconds Per Frame


	int sizet = 1024;
	if((_video_width < 128) && (_video_height < 128))
		sizet = 128;
	else if((_video_width < 256) && (_video_height < 256))
		sizet = 256;
	else if((_video_width < 512) && (_video_height < 512))
		sizet = 512;

	_widths.push_back(sizet);
	_heights.push_back(sizet);

	// initialize the host texture
	InitializeTexture();


	_AVR_bmih.biSize = sizeof (BITMAPINFOHEADER);					// Size Of The BitmapInfoHeader
	_AVR_bmih.biPlanes = 1;											// Bitplanes
	_AVR_bmih.biBitCount = 24;										// Bits Format We Want (24 Bit, 3 Bytes)
	_AVR_bmih.biWidth = _widths[0];									// Width We Want
	_AVR_bmih.biHeight = _heights[0];								// Height We Want
	_AVR_bmih.biCompression = BI_RGB;								// Requested Mode = RGB

	_AVR_hBitmap = CreateDIBSection (_AVR_hdc, (BITMAPINFO*)(&_AVR_bmih), DIB_RGB_COLORS, (void**)(&_img_data), NULL, NULL);
	SelectObject (_AVR_hdc, _AVR_hBitmap);							// Select hBitmap Into Our Device Context (hdc)

	_AVR_pgf=AVIStreamGetFrameOpen(_AVR_pavi, NULL);				// Create The PGETFRAME	Using Our Request Mode


	_avi_opened = true;

	return(_AVR_pgf!=NULL);
}
Example #3
0
    GraphicsBenchmarkFrame()
        : wxFrame(NULL, wxID_ANY, "wxWidgets Graphics Benchmark")
    {
        SetClientSize(opts.width, opts.height);

#if wxUSE_GLCANVAS
        m_glCanvas = NULL;
        m_glContext = NULL;

        if ( opts.useGL )
        {
            m_glCanvas = new wxGLCanvas(this, wxID_ANY, NULL,
                                        wxPoint(0, 0),
                                        wxSize(opts.width, opts.height));
            m_glContext = new wxGLContext(m_glCanvas);
            m_glContext->SetCurrent(*m_glCanvas);

            glViewport(0, 0, opts.width, opts.height);
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(-1, 1, -1, 1, -1, 1);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();

            InitializeTexture(opts.width, opts.height);

            m_glCanvas->Connect(
                wxEVT_PAINT,
                wxPaintEventHandler(GraphicsBenchmarkFrame::OnGLRender),
                NULL,
                this
            );
        }
        else // Not using OpenGL
#endif // wxUSE_GLCANVAS
        {
            Connect(wxEVT_PAINT,
                    wxPaintEventHandler(GraphicsBenchmarkFrame::OnPaint));
        }

        Connect(wxEVT_SIZE, wxSizeEventHandler(GraphicsBenchmarkFrame::OnSize));

        m_bitmapARGB.Create(64, 64, 32);
        m_bitmapARGB.UseAlpha(true);
        m_bitmapRGB.Create(64, 64, 24);

        m_renderer = NULL;
        if ( opts.useGC )
        {
#ifdef __WXMSW__
            if ( opts.renderer == GraphicsBenchmarkOptions::GDIPlus )
                m_renderer = wxGraphicsRenderer::GetGDIPlusRenderer();
            else if ( opts.renderer == GraphicsBenchmarkOptions::Direct2D )
                m_renderer = wxGraphicsRenderer::GetDirect2DRenderer();
            else if ( opts.renderer == GraphicsBenchmarkOptions::Cairo )
                m_renderer = wxGraphicsRenderer::GetCairoRenderer();
            // Check if selected renderer is operational.
            if ( m_renderer )
            {
                wxBitmap bmp(16, 16);
                wxMemoryDC memDC(bmp);
                wxGraphicsContext* gc = m_renderer->CreateContext(memDC);
                if ( !gc )
                {
                    wxPrintf("Couldn't initialize '%s' graphics renderer.\n", m_renderer->GetName().c_str());
                    m_renderer = NULL;
                }
                delete gc;
            }
#endif // __WXMSW__

            if( !m_renderer )
                m_renderer = wxGraphicsRenderer::GetDefaultRenderer();
        }

        Show();
    }
Example #4
0
void QFFmpegGLWidget::paintGL()
{
    //return;


if(!isShaderInited)
{
    isShaderInited=true;
    glDeleteTextures(3, m_textureIds);

    glGenTextures(3, m_textureIds);

    glActiveTexture(GL_TEXTURE0);
    InitializeTexture( m_textureIds[0], width, height);
    glActiveTexture(GL_TEXTURE1);
    InitializeTexture( m_textureIds[1], width / 2, height / 2);
    glActiveTexture(GL_TEXTURE2);
    InitializeTexture( m_textureIds[2], width / 2, height / 2);




}
    //QPainter p;
    //p.begin(this);
    //p.beginNativePainting();
    glClearColor(m_background.redF(), m_background.greenF(), m_background.blueF(), m_transparent ? 0.0f : 1.0f);
    //glViewport(0, 0, WIDTH, HEIGHT);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    //  glFrontFace(GL_CW);
    // glCullFace(GL_FRONT);
    //  glEnable(GL_CULL_FACE);
    // glEnable(GL_DEPTH_TEST);
    //qDebug()<<"C===========";

    //glBindTexture(GL_TEXTURE_2D, m_textureIds[0]);
    //glTexImage2D(GL_TEXTURE_2D, 0, 4, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);


    //m_texture->bind();
    //glColor3f(1.0f,0.0f,0.0f);
    /*  glBegin(GL_QUADS);

    // 前面

    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, -1.0f,  0.0f);
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, -1.0f,  0.0f);
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  0.0f);
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  0.0f);


    glEnd();
*/

    if(width ==0 || height ==0)return;
    m_programA->bind();



    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, m_textureIds[0]);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_LUMINANCE,
                    GL_UNSIGNED_BYTE, buffer[bufIndex]);

    int i=m_programA->uniformLocation("Ytex");
    glUniform1i(i, 0);

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, m_textureIds[1]);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width / 2, height / 2, GL_LUMINANCE,
                    GL_UNSIGNED_BYTE, (char *) buffer[bufIndex] + width * height);

    i=m_programA->uniformLocation("Utex");
    glUniform1i(i, 1);

    glActiveTexture(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, m_textureIds[2]);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width / 2, height / 2, GL_LUMINANCE,
                    GL_UNSIGNED_BYTE, (char *) buffer[bufIndex] + width * height * 5 / 4);


    i=m_programA->uniformLocation("Vtex");
    glUniform1i(i, 2);


    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, g_indices);
    //glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    m_programA->release();

    bufIndex++;
    if(bufIndex>=BUF_SIZE)
        bufIndex=0;
    //   p.endNativePainting();
    //   p.end();

}
Example #5
0
 virtual void InitializeTexturesSection(const int& screenWidth, const int& screenHeight)
 {
     Postprocess::InitializeTexturesSection(screenWidth, screenHeight);
     InitializeTexture(speedTextureID, speedTexture, 
         GL_COLOR_ATTACHMENT1, "speedTexture", screenWidth, screenHeight);
 }