2 * psychlops_g_canvas3d_prototype.cpp
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2005/10/05 by Kenchi HOSOKAWA
6 * (C) 2005 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
10 #include "../../../psychlops_core.h"
11 #include "../../../platform/gl/psychlops_g_GL_h.h"
13 #include "psychlops_g_canvas3d_prototype.h"
19 Canvas3D::Canvas3D(void) : has_instance_(false), APIsetColor(0) {
21 Canvas3D::Canvas3D(CanvasMode mode) : has_instance_(false), APIsetColor(0) {
24 Canvas3D::Canvas3D(int d_width, int d_height, int d_colordepth, double d_refreshrate, CanvasMode mode) : has_instance_(false), APIsetColor(0) {
25 set(d_width, d_height, d_colordepth, d_refreshrate, mode);
27 Canvas3D::~Canvas3D(void) {
31 static void setColor4Through(const Color &color) {
36 static void setColorClaer4Through(const Color &color) {
39 glClearColor(r,g,b,a);
42 void Canvas3D::popMatrixes() {
43 glMatrixMode(GL_MODELVIEW);
45 glMatrixMode(GL_PROJECTION);
48 void Canvas3D::loadOrthoProjection() {
49 glMatrixMode(GL_PROJECTION);
51 glOrtho(-0.375, Width-0.375, Height-0.375, -0.375, -1000, 1000);
52 glMatrixMode(GL_MODELVIEW);
54 // glDisable(GL_LIGHTING);
55 // glDisable(GL_DEPTH_TEST);
58 void Canvas3D::initAPIprop() {
62 APIsetColor = &(DirectGetColor::setColor4ub);
63 APIsetColorClear = &(DirectGetColor::setColorClear4ub);
66 APIsetColor = &(setColor4Through);
67 APIsetColorClear = &(setColorClaer4Through);
71 glMatrixMode(GL_PROJECTION);
73 glMatrixMode(GL_MODELVIEW);
75 loadOrthoProjection();
78 glDrawBuffer(GL_BACK);
79 glReadBuffer(GL_BACK);
81 GLclampf red=0.0, green=0.0, blue=0.0, alpha=1.0;
82 // default_drawing_mode_ = GL_POINTS;
83 glClearColor(red,green,blue,alpha);
90 void Canvas3D::initAPIattributes() {
91 glPushAttrib(GL_ALL_ATTRIB_BITS);
93 //// default settings ////
94 glShadeModel(GL_FLAT);
95 glEnable(GL_ALPHA_TEST);
97 glEnable(GL_LINE_STIPPLE);
98 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
99 /* glDisable(GL_POINT_SMOOTH);
100 glDisable(GL_LINE_SMOOTH);
101 glDisable(GL_POLYGON_SMOOTH);
102 glDisable(GL_DEPTH_TEST);
103 glDisable(GL_DITHER);
105 glDisable(GL_LIGHTING);
106 glDisable(GL_LOGIC_OP);
107 glDisable(GL_STENCIL_TEST);
108 glDisable(GL_TEXTURE_1D);
109 glDisable(GL_TEXTURE_2D);
110 */ glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
111 glPixelTransferi(GL_MAP_STENCIL, GL_FALSE);
112 glPixelTransferi(GL_RED_SCALE, 1);
113 glPixelTransferi(GL_RED_BIAS, 0);
114 glPixelTransferi(GL_GREEN_SCALE, 1);
115 glPixelTransferi(GL_GREEN_BIAS, 0);
116 glPixelTransferi(GL_BLUE_SCALE, 1);
117 glPixelTransferi(GL_BLUE_BIAS, 0);
118 glPixelTransferi(GL_ALPHA_SCALE, 1);
119 glPixelTransferi(GL_ALPHA_BIAS, 0);
120 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
121 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
122 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
123 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
124 glPixelStoref(GL_UNPACK_ALIGNMENT, 4);
125 glPixelStorei(GL_PACK_ALIGNMENT, 4);
126 glPixelStoref(GL_PACK_ALIGNMENT, 4);
127 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
130 void Canvas3D::flip(int nextframe) {
132 loadOrthoProjection();
134 glPushAttrib(GL_ALL_ATTRIB_BITS);
135 glDisable(GL_LIGHTING);
136 this->Canvas::flip(nextframe);
140 loadOrthoProjection();
146 } /* <- namespace Psycholops */