OSDN Git Service

add JPG and TIFF Support via OpenCV for Image::load and Image::save
[psychlops/cpp.git] / psychlops / platform / win32gl / psychlops_g_image_win32gl.cpp
1 /*
2  *  psychlops_g_image_Win32_GL.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2007/07/07 by Kenchi HOSOKAWA
6  *  (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
7  */
8
9
10
11 #include <stdlib.h>
12 #include <Math.h>
13
14
15 #define PSYCHLOPS_WINDOW_API_PLATFORM
16 #include "../psychlops_platform_selector.h"
17 #include "../../core/graphic/psychlops_g_image.h"
18
19
20 namespace Psychlops {
21
22 /*
23         Image& Image::cache(bool on_off) {
24                 if(on_off) {
25                         int i;
26                         i=0;
27                         while(pow(2.0,++i)<width_) {}
28                         api_->tex_width = pow(2.0,i);
29                         i=0;
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);
34                         if(quickened_) {
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);
39                         } else {
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);
49                                 quickened_ = true;
50
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));
57 //                                      }
58 //                              }
59 //                              glDrawBuffer(GL_BACK);
60 //                              glEnable(GL_BLEND);
61
62                         }
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());
67                         glBegin(GL_QUADS);
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);
74                                 glTexCoord2d(0, 0);
75                                         glVertex2f(targetarea_.getLeft() , targetarea_.getBottom()+1);
76                         glEnd();
77                         glDisable(GL_TEXTURE_2D);
78                         glDrawBuffer(GL_BACK);
79                         delete tmp;
80
81                 } else {
82                         if(quickened_) {
83                                 glDeleteTextures(1, &(api_->VRAMoffset));
84                                 api_->VRAMoffset = 0;
85                                 quickened_ = false;
86                         }
87                 }
88                 return *this;
89         }
90 */
91
92 }       /*      <- namespace Psycholops         */
93