Changeset 36
- Timestamp:
- 07/09/07 21:49:37 (1 year ago)
- Files:
-
- trunk/src/yage/all.d (modified) (1 diff)
- trunk/src/yage/gui (added)
- trunk/src/yage/gui/all.d (added)
- trunk/src/yage/gui/surface.d (added)
- trunk/src/yage/node/camera.d (modified) (3 diffs)
- trunk/src/yage/resource/texture.d (modified) (3 diffs)
- trunk/src/yage/system/device.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/yage/all.d
r28 r36 16 16 import yage.util.all; 17 17 import yage.system.all; 18 import yage.gui.all; 18 19 } 19 20 trunk/src/yage/node/camera.d
r32 r36 43 43 float threshold = 2.25; // minimum size of node in pixels before it's rendered. Stored as 1/(size^2) 44 44 45 CameraTexture capture; // The camera renders to this Texture45 GPUTexture capture; // The camera renders to this Texture 46 46 Plane[6] frustum; 47 47 Matrix inverse_absolute; // Inverse of the camera's absolute matrix. … … 59 59 this(BaseNode _parent) 60 60 { super(_parent); 61 capture = new CameraTexture();61 capture = new GPUTexture(); 62 62 setResolution(xres, yres); 63 63 setVisible(false); … … 147 147 148 148 /// Get the Texture that the camera renders to. 149 CameraTexture getTexture()149 GPUTexture getTexture() 150 150 { return capture; 151 151 } trunk/src/yage/resource/texture.d
r32 r36 198 198 protected uint height = 0; 199 199 protected char[] source; 200 200 201 uint requested_width = 0; 202 uint requested_height = 0; 203 201 204 /// 202 205 this() … … 317 320 318 321 /// Copy the the contents of the framebuffer into this Texture. 319 void loadFrameBuffer(uint width, uint height) 320 { 322 void loadFrameBuffer(uint width, uint height){ 321 323 // A special value of zero to stretch to the window size. 322 324 if (width ==0) width = Device.getWidth(); … … 332 334 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, this.width, this.height, 0); 333 335 format = IMAGE_FORMAT_RGB; 336 337 requested_width = width; 338 requested_height = height; 334 339 } 335 340 } 336 337 /**338 * A Texture that is used as a rendering target by a Camera.339 * Since not all video hardware supports non-power of two sized Textures,340 * Textures are oversized to the next power of two when necessary.341 * It is then necessary to store the size the texture wishes it was. */342 class CameraTexture : GPUTexture343 { uint requested_width = 0;344 uint requested_height = 0;345 346 ///347 this()348 { super();349 }350 351 /// loadFrameBuffer is overridden to set requested_width and requested_height.352 void loadFrameBuffer(uint _width, uint _height)353 { super.loadFrameBuffer(_width, _height);354 requested_width =_width;355 requested_height =_height;356 }357 }trunk/src/yage/system/device.d
r34 r36 20 20 import derelict.ogg.vorbisfile; 21 21 import yage.resource.texture; 22 import yage.gui.surface; 22 23 import yage.system.log; 23 24 import yage.system.constant; … … 52 53 53 54 // The texture that is rendered to the screen. 54 static CameraTexture texture;55 55 //static CameraTexture texture; 56 56 57 public: 57 58 58 59 static Surface[] subs; 60 59 61 /// Unload SDL at exit. 60 62 static ~this() … … 176 178 177 179 // Enable texture coordinate arrays for each texture unit 178 if (Device.getSupport(DEVICE_MULTITEXTURE))180 /*if (Device.getSupport(DEVICE_MULTITEXTURE)) 179 181 for (int i=Device.getLimit(DEVICE_MAX_TEXTURES)-1; i>=0; i--) 180 182 { glClientActiveTextureARB(GL_TEXTURE0_ARB + i); … … 184 186 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); 185 187 } 186 188 */ 187 189 // Input options 188 190 SDL_EnableUNICODE(true); … … 274 276 275 277 /// Draw the current material to the screen. 276 static void render() 277 {glPushAttrib(0xFFFFFFFF); // all attribs278 static void render(){ 279 glPushAttrib(0xFFFFFFFF); // all attribs 278 280 279 281 // Setup the viewport in orthogonal mode, … … 289 291 glDisable(GL_DEPTH_TEST); 290 292 glDisable(GL_LIGHTING); 291 292 // If a texture to render 293 float x, y; 294 if (texture !is null) 295 { glEnable(GL_TEXTURE_2D); 296 297 // If our texture is larger than the viewport, set the size of the quad to adjust. 298 x = texture.requested_width/cast(float)texture.getWidth(); 299 y = texture.requested_height/cast(float)texture.getHeight(); 300 301 // Draw a textured quad of our current material 302 Texture(texture, true, TEXTURE_FILTER_BILINEAR).bind(); 303 } 304 else 305 glDisable(GL_TEXTURE_2D); 306 307 glBegin(GL_QUADS); 308 glTexCoord2f(0, 0); glVertex2f(0, 1); 309 glTexCoord2f(x, 0); glVertex2f(1, 1); 310 glTexCoord2f(x, y); glVertex2f(1, 0); 311 glTexCoord2f(0, y); glVertex2f(0, 0); 312 glEnd(); 293 294 glEnable(GL_TEXTURE_2D); 295 296 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 297 foreach(sub; this.subs) sub.draw(); 313 298 314 299 SDL_GL_SwapBuffers(); … … 364 349 { width = _width; 365 350 height = _height; 366 351 352 foreach(sub ;this.subs) sub.recalculate(width, height); 353 367 354 // For some reason, SDL Linux requires a call to SDL_SetVideoMode for a screen resize that's 368 355 // larger than the current screen. (need to try this with latest version of SDL, alsy try SDL lock surface)
