2 * psychlops_g_image_Win32_GL.h
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2007/07/07 by Kenchi HOSOKAWA
6 * (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
15 #define PSYCHLOPS_WINDOW_API_PLATFORM
16 #include "../psychlops_platform_selector.h"
17 #include "../../core/graphic/psychlops_g_image.h"
23 Image& Image::cache(bool on_off) {
27 while(pow(2.0,++i)<width_) {}
28 api_->tex_width = pow(2.0,i);
30 while(pow(2.0,++i)<height_) {}
31 api_->tex_height = pow(2.0,i);
32 Image *tmp = new Image(api_->tex_width, api_->tex_height, pixcomp_, pixprec_);
33 for(int y=0; y<height_; y++) line_direct_copy_(*this, *tmp, y);
35 glEnable(GL_TEXTURE_2D);
36 glBindTexture(GL_TEXTURE_2D, api_->VRAMoffset);
37 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, api_->tex_width, api_->tex_height, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], tmp->getBitmapPtr());
38 glDisable(GL_TEXTURE_2D);
40 glEnable(GL_TEXTURE_2D);
41 glGenTextures(1, &api_->VRAMoffset);
42 glBindTexture(GL_TEXTURE_2D, api_->VRAMoffset);
43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
44 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
45 // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
46 // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
47 glTexImage2D(GL_TEXTURE_2D, 0, PixCompSize_[pixcomp_], api_->tex_width, api_->tex_height, 0, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], tmp->getBitmapPtr());
48 glDisable(GL_TEXTURE_2D);
51 // APIImageProperties::regist((int)Display::getWidth(), (int)Display::getHeight(), width_, height_, VRAMleft_, VRAMtop_);
52 // glDisable(GL_BLEND);
53 // glDrawBuffer(GL_AUX1);
54 // for(int y=0; y<height_; y++) {
55 // for(int x=0; x<width_; x++) {
56 // Display::pix(x+VRAMleft_, y+VRAMtop_, getPix(x, y));
59 // glDrawBuffer(GL_BACK);
60 // glEnable(GL_BLEND);
63 glDrawBuffer(GL_AUX1);
64 glColor4f(1.0,1.0,1.0,1.0);
65 glEnable(GL_TEXTURE_2D);
66 glBindTexture(GL_TEXTURE_2D, api_->getTexIndex());
68 glTexCoord2d(0 , height_);
69 glVertex2f(targetarea_.getLeft() , targetarea_.getTop());
70 glTexCoord2d(width_ , height_);
71 glVertex2f(targetarea_.getRight()+1, targetarea_.getTop());
72 glTexCoord2d(width_ , 0);
73 glVertex2f(targetarea_.getRight()+1, targetarea_.getBottom()+1);
75 glVertex2f(targetarea_.getLeft() , targetarea_.getBottom()+1);
77 glDisable(GL_TEXTURE_2D);
78 glDrawBuffer(GL_BACK);
83 glDeleteTextures(1, &(api_->VRAMoffset));
92 } /* <- namespace Psycholops */