//
// C++ Implementation: me_opengl_video_surface
//
// Description:
//
//
// Author: Messenger of death <Messengerofdeath@gmail.com>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifdef HAVE_CONFIG_H
#include <conf_config.h>
#endif
#ifdef WIN32
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#endif

#include <GL/glew.h>
#include "video_GL_mogul.h"
#include <iostream>
#ifdef Revision
#undef Revision
#endif
#define Revision "GL_video_surface.cpp $Revision: 1.1 $"
		
OpenGL_Surface::OpenGL_Surface ( ) :
		Video_Surface(), _tex_id_(0)
{
}
OpenGL_Surface::~OpenGL_Surface()
{
	glDeleteTextures ( 1, (GLuint*)&_tex_id_ );
}
void OpenGL_Surface::_update_ ( )
{
	if(_tex_id_!=0)glDeleteTextures ( 1, (GLuint*)&_tex_id_ );
	glGenTextures(1, (GLuint*)&_tex_id_);
	
	glBindTexture ( GL_TEXTURE_2D, _tex_id_ );
			
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
	glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
	glTexImage2D ( GL_TEXTURE_2D, 0, 4, _w_, _h_, 0, GL_RGBA, GL_UNSIGNED_BYTE, _surface_);
	_need_update_=false;

}
