/*
 *  psychlops_g_image_Win32_GL.h
 *  Psychlops Standard Library (Universal)
 *
 *  Last Modified 2007/07/07 by Kenchi HOSOKAWA
 *  (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
 */



#include <stdlib.h>
#include <Math.h>


#define PSYCHLOPS_WINDOW_API_PLATFORM
#include "../psychlops_platform_selector.h"
#include "../../core/graphic/psychlops_g_image.h"


namespace Psychlops {

/*
	Image& Image::cache(bool on_off) {
		if(on_off) {
			int i;
			i=0;
			while(pow(2.0,++i)<width_) {}
			api_->tex_width = pow(2.0,i);
			i=0;
			while(pow(2.0,++i)<height_) {}
			api_->tex_height = pow(2.0,i);
			Image *tmp = new Image(api_->tex_width, api_->tex_height, pixcomp_, pixprec_);
			for(int y=0; y<height_; y++) line_direct_copy_(*this, *tmp, y);
			if(quickened_) {
				glEnable(GL_TEXTURE_2D);
				glBindTexture(GL_TEXTURE_2D, api_->VRAMoffset);
				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, api_->tex_width, api_->tex_height, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], tmp->getBitmapPtr());
				glDisable(GL_TEXTURE_2D);
			} else {
				glEnable(GL_TEXTURE_2D);
				glGenTextures(1, &api_->VRAMoffset);
				glBindTexture(GL_TEXTURE_2D, api_->VRAMoffset);
				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
//				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
				glTexImage2D(GL_TEXTURE_2D, 0, PixCompSize_[pixcomp_], api_->tex_width, api_->tex_height, 0, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], tmp->getBitmapPtr());
				glDisable(GL_TEXTURE_2D);
				quickened_ = true;

//				APIImageProperties::regist((int)Display::getWidth(), (int)Display::getHeight(), width_, height_, VRAMleft_, VRAMtop_);
//				glDisable(GL_BLEND);
//				glDrawBuffer(GL_AUX1);
//				for(int y=0; y<height_; y++) {
//					for(int x=0; x<width_; x++) {
//						Display::pix(x+VRAMleft_, y+VRAMtop_, getPix(x, y));
//					}
//				}
//				glDrawBuffer(GL_BACK);
//				glEnable(GL_BLEND);

			}
			glDrawBuffer(GL_AUX1);
			glColor4f(1.0,1.0,1.0,1.0);
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, api_->getTexIndex());
			glBegin(GL_QUADS);
				glTexCoord2d(0 , height_);
					glVertex2f(targetarea_.getLeft() , targetarea_.getTop());
				glTexCoord2d(width_ , height_);
					glVertex2f(targetarea_.getRight()+1, targetarea_.getTop());
				glTexCoord2d(width_ , 0);
					glVertex2f(targetarea_.getRight()+1, targetarea_.getBottom()+1);
				glTexCoord2d(0, 0);
					glVertex2f(targetarea_.getLeft() , targetarea_.getBottom()+1);
			glEnd();
			glDisable(GL_TEXTURE_2D);
			glDrawBuffer(GL_BACK);
			delete tmp;

		} else {
			if(quickened_) {
				glDeleteTextures(1, &(api_->VRAMoffset));
				api_->VRAMoffset = 0;
				quickened_ = false;
			}
		}
		return *this;
	}
*/

}	/*	<- namespace Psycholops 	*/

