OSDN Git Service

first
[psychlops/cpp.git] / psychlops / platform / osx / psychlops_g_image_OSX.cpp
1 /*
2  *  psychlops_g_image_OSX.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2006/01/04 by Kenchi HOSOKAWA
6  *  (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
7  */
8
9 #include <ApplicationServices/ApplicationServices.h>
10 #include <CoreServices/CoreServices.h>
11 #include <OpenGL/OpenGL.h>
12 #include <OpenGL/gl.h>
13
14
15 #include <stdlib.h>
16 #include <Math.h>
17 #include <iostream>
18
19
20 #include "psychlops_g_API_OSX.h"
21 #include "../../core/graphic/psychlops_g_image.h"
22
23
24
25 namespace Psychlops {
26
27
28
29 /*
30         Image& Image::cache(bool on_off) {
31                 if(on_off) {
32                         if(quickened_) {
33                                 glEnable(GL_TEXTURE_RECTANGLE_EXT);
34                                 glBindTexture(GL_TEXTURE_RECTANGLE_EXT, api_->VRAMoffset);
35                                 glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, width_, height_, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], getBitmapPtr());
36                                 glDisable(GL_TEXTURE_RECTANGLE_EXT);
37                         } else {
38                                 glEnable(GL_TEXTURE_RECTANGLE_EXT);
39                                 glGenTextures(1, &api_->VRAMoffset);
40                                 glBindTexture(GL_TEXTURE_RECTANGLE_EXT, api_->VRAMoffset);
41                                 glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
42                                 glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
43                                 glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
44                                 glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
45                                 glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, PixCompSize_[pixcomp_], width_, height_, 0, APIImageProperties::PixCompGL_[pixcomp_], APIImageProperties::PixPrecGL_[pixprec_], getBitmapPtr());
46                                 glDisable(GL_TEXTURE_RECTANGLE_EXT);
47                                 quickened_ = true;
48
49 //                              APIImageProperties::regist((int)Display::getWidth(), (int)Display::getHeight(), width_, height_, VRAMleft_, VRAMtop_);
50 //                              glDisable(GL_BLEND);
51 //                              glDrawBuffer(GL_AUX1);
52 //                              for(int y=0; y<height_; y++) {
53 //                                      for(int x=0; x<width_; x++) {
54 //                                              Display::pix(x+VRAMleft_, y+VRAMtop_, getPix(x, y));
55 //                                      }
56 //                              }
57 //                              glDrawBuffer(GL_BACK);
58 //                              glEnable(GL_BLEND);
59                         }
60                         glDrawBuffer(GL_AUX1);
61                         glColor4f(1.0,1.0,1.0,1.0);
62                         glEnable(GL_TEXTURE_RECTANGLE_EXT);
63                         glBindTexture(GL_TEXTURE_RECTANGLE_EXT, api_->getTexIndex());
64                         glBegin(GL_QUADS);
65                                 glTexCoord2d(0 , height_);
66                                         glVertex2f(targetarea_.getLeft() , targetarea_.getTop());
67                                 glTexCoord2d(width_ , height_);
68                                         glVertex2f(targetarea_.getRight()+1 , targetarea_.getTop());
69                                 glTexCoord2d(width_ , 0);
70                                         glVertex2f(targetarea_.getRight()+1, targetarea_.getBottom()+1);
71                                 glTexCoord2d(0, 0);
72                                         glVertex2f(targetarea_.getLeft() , targetarea_.getBottom()+1);
73                         glEnd();
74                         glDisable(GL_TEXTURE_RECTANGLE_EXT);
75                         glDrawBuffer(GL_BACK);
76
77                 } else {
78                         glDeleteTextures(1, &(api_->VRAMoffset));
79                         quickened_ = false;
80                 }
81                 return *this;
82         }
83 */
84
85 }       /*      <- namespace Psycholops         */
86