/*
 *  psychlops_g_image_OSX.h
 *  Psychlops Standard Library (Universal)
 *
 *  Last Modified 2006/01/04 by Kenchi HOSOKAWA
 *  (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
 */

#include <ApplicationServices/ApplicationServices.h>
#include <CoreServices/CoreServices.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>


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


#include "psychlops_g_API_OSX.h"
#include "../../core/graphic/psychlops_g_image.h"



namespace Psychlops {



/*
	Image& Image::cache(bool on_off) {
		if(on_off) {
			if(quickened_) {
				glEnable(GL_TEXTURE_RECTANGLE_EXT);
				glBindTexture(GL_TEXTURE_RECTANGLE_EXT, api_->VRAMoffset);
				glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, width_, height_, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], getBitmapPtr());
				glDisable(GL_TEXTURE_RECTANGLE_EXT);
			} else {
				glEnable(GL_TEXTURE_RECTANGLE_EXT);
				glGenTextures(1, &api_->VRAMoffset);
				glBindTexture(GL_TEXTURE_RECTANGLE_EXT, api_->VRAMoffset);
				glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
				glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
				glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
				glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
				glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, PixCompSize_[pixcomp_], width_, height_, 0, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], getBitmapPtr());
				glDisable(GL_TEXTURE_RECTANGLE_EXT);
				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_RECTANGLE_EXT);
			glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 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_RECTANGLE_EXT);
			glDrawBuffer(GL_BACK);

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

}	/*	<- namespace Psycholops 	*/

