libsoy
view src/widgets/Canvas.gs @ 125:d15af322d322
Canvas uses soy.textures.Texture, but no texture shows
| author | DavidCzech |
|---|---|
| date | Wed, 27 Jan 2010 23:56:01 -0800 |
| parents | 4442c1527a1a |
| children | be0cd1d4fec6 |
line source
1 /*
2 * libsoy - soy.widgets.Canvas
3 * Copyright (C) 2006,2007,2008,2009,2010 PySoy Group
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program; if not, see http://www.gnu.org/licenses
17 *
18 */
19 [indent=2]
20 uses
21 GLib
22 Gdk
23 GL
24 soy.textures
26 //namespace soy.widgets
28 class soy.widgets.Canvas : soy.widgets.Widget
30 texture : soy.textures.Texture
32 verts : array of GLfloat = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,\
33 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,\
34 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,\
35 0.0f, 1.0f, 0.0f, 0.0f, 1.0f }
37 faces : array of GLushort = { 0,1,2,2,3,0 }
39 vbuffer : GLint // Vertex Buffer
40 ibuffer : GLint // Index Buffer
42 construct ( )
43 texture = new soy.textures.Texture()
45 def override render ( ) : void
46 //
47 ///////////////////////////////////////
48 //
49 // don't bother rendering w/o a texture
50 //
52 print " Rending Canvas "
55 if texture == null
56 return
58 //
59 ///////////////////////////////////////
60 //
61 // Set the viewport to the current Widget position and size
62 //
63 //glViewport( (GL.GLint) Xpos, (GL.GLint) Ypos, (GL.GLint) width, (GL.GLint) height)
64 //
65 ///////////////////////////////////////
66 //
67 // Reset the projection and modelview matrix, set ortho rendering
68 //
69 glMatrixMode(GL_PROJECTION)
70 glLoadIdentity()
71 glOrtho(0.0, 1.0, 0.0, 1.0, -1, 1)
72 glMatrixMode(GL_MODELVIEW)
73 glLoadIdentity()
77 //glColor3f(1.0f, 0.0f, 0.0f);
79 glDisableClientState(GL_NORMAL_ARRAY) // We're not going to use Normals
80 //glDisableClientState(GL_TEXTURE_COORD_ARRAY) // Yes, but not now
82 texture.enable()
83 /*
84 glVertexPointer(3, GL_FLOAT, 20, verts)
85 glTexCoordPointer(2, GL_FLOAT, 20, verts + 12)
86 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, faces)
87 */
88 /*glBegin( GL_QUADS );
89 glTexCoord2d(0.0,0.0); glVertex2d(0.0,0.0);
90 glTexCoord2d(1.0,0.0); glVertex2d(1.0,0.0);
91 glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0);
92 glTexCoord2d(0.0,1.0); glVertex2d(0.0,1.0);
93 glEnd();
94 glFlush();*/
95 glEnableClientState(GL_NORMAL_ARRAY) // But remember to enable them for later...
96 //glEnableClientState(GL_TEXTURE_COORD_ARRAY)
98 print " End Rending Canvas "
