Пример #1
0
static void gl_restart(void)
{
#ifdef HAVE_CG_MENU
   bool should_menu_render;
#endif
#ifdef RARCH_CONSOLE
   bool should_block_swap;
#endif
   gl_t *gl = driver.video_data;

   if (!gl)
	   return;

#ifdef RARCH_CONSOLE
   should_block_swap = gl->block_swap;
#endif
#ifdef HAVE_CG_MENU
   should_menu_render = gl->menu_render;
#endif

   gl_stop();
   gl_cg_invalidate_context();
   gl_start();

#ifdef HAVE_CG_MENU
   gl->menu_render = should_menu_render;
#endif

   gl->frame_count = 0;

#ifdef RARCH_CONSOLE
   gl->block_swap = should_block_swap;
   SET_TIMER_EXPIRATION(gl, 30);
#endif
}
Пример #2
0
/*!
	To set a valid raster position outside the viewport, first set a valid
    raster position inside the viewport, then call glBitmap with NULL
    as the bitmap parameter and with xmove and ymove set to
    the offsets of the new raster position. This technique is useful when
    panning an image around the viewport.
	(see http://www.opengl.org/sdk/docs/man/xhtml/glBitmap.xml and
	http://www.opengl.org/sdk/docs/man/xhtml/glDrawPixels.xml)
*/
void ImageView::GLDraw()
{	
#ifdef USE_OPEN_GL_WINDOW
	if (!valid())
		GLViewSetup();
#else
	gl_start();
#endif

	// Invert image
	//glPixelZoom(1.0f, -1.0f);
	glPixelZoom((float) m_scaling, (float) -m_scaling);

	// Set image origin
	glRasterPos2i(0, h());

	// Check that the raster position is valid
	GLboolean rasVal;

	glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &rasVal);

	if (!rasVal)
	{
		ShowError("Invalid raster position. No image will be shown");
	}

	// If image is scaled down, the view needs to be fully erased
	//if (m_zoom < 1)
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	
	m_mutex.Lock();

	if (m_curByteImage.is_contiguous() && m_curByteImage.size() > 0)
		glDrawPixels(m_curByteImage.ni(), m_curByteImage.nj(), GL_LUMINANCE,
			GL_UNSIGNED_BYTE, m_curByteImage.top_left_ptr());
	else if (m_curRGBImage.is_contiguous())
		glDrawPixels(m_curRGBImage.ni(), m_curRGBImage.nj(), GL_RGB,
			GL_UNSIGNED_BYTE, m_curRGBImage.top_left_ptr());
	else
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	m_mutex.Release();

	// Call the current vision system component (if there is one)
	// to draw over the current image
	if (m_pPainter)
	{
		glPushMatrix();
		glTranslated(m_offset.x, m_offset.y + h(), 0);
		glScaled(m_zoom, -m_zoom, 1);
		glColor4f(0, 0, 0, 1.0);
		m_pPainter->DrawWithMutex(m_painterInfo);
		glPopMatrix();
	}

#ifdef USE_OPEN_GL_WINDOW
	glFlush();
#else
	gl_finish();
#endif
}