Changeset 36

Show
Ignore:
Timestamp:
07/09/07 21:49:37 (1 year ago)
Author:
Deformative
Message:

Started Surfaces

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/yage/all.d

    r28 r36  
    1616    import yage.util.all; 
    1717    import yage.system.all; 
     18    import yage.gui.all; 
    1819} 
    1920 
  • trunk/src/yage/node/camera.d

    r32 r36  
    4343    float threshold = 2.25;     // minimum size of node in pixels before it's rendered. Stored as 1/(size^2) 
    4444 
    45     CameraTexture capture;        // The camera renders to this Texture 
     45    GPUTexture capture;       // The camera renders to this Texture 
    4646    Plane[6] frustum; 
    4747    Matrix inverse_absolute;    // Inverse of the camera's absolute matrix. 
     
    5959    this(BaseNode _parent) 
    6060    {   super(_parent); 
    61         capture = new CameraTexture(); 
     61        capture = new GPUTexture(); 
    6262        setResolution(xres, yres); 
    6363        setVisible(false); 
     
    147147 
    148148    /// Get the Texture that the camera renders to. 
    149     CameraTexture getTexture() 
     149    GPUTexture getTexture() 
    150150    {   return capture; 
    151151    } 
  • trunk/src/yage/resource/texture.d

    r32 r36  
    198198    protected uint height    = 0; 
    199199    protected char[] source; 
    200  
     200     
     201    uint requested_width   = 0; 
     202    uint requested_height  = 0; 
     203     
    201204    /// 
    202205    this() 
     
    317320 
    318321    /// 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){ 
    321323        // A special value of zero to stretch to the window size. 
    322324        if (width ==0) width  = Device.getWidth(); 
     
    332334        glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, this.width, this.height, 0); 
    333335        format = IMAGE_FORMAT_RGB; 
     336         
     337        requested_width  = width; 
     338        requested_height = height; 
    334339    } 
    335340} 
    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 : GPUTexture 
    343 {   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  
    2020import derelict.ogg.vorbisfile; 
    2121import yage.resource.texture; 
     22import yage.gui.surface; 
    2223import yage.system.log; 
    2324import yage.system.constant; 
     
    5253 
    5354    // The texture that is rendered to the screen. 
    54     static CameraTexture texture; 
    55  
     55    //static CameraTexture texture; 
     56     
    5657    public: 
    57  
    58  
     58     
     59    static Surface[] subs; 
     60     
    5961    /// Unload SDL at exit. 
    6062    static ~this() 
     
    176178 
    177179        // Enable texture coordinate arrays for each texture unit 
    178         if (Device.getSupport(DEVICE_MULTITEXTURE)) 
     180        /*if (Device.getSupport(DEVICE_MULTITEXTURE)) 
    179181            for (int i=Device.getLimit(DEVICE_MAX_TEXTURES)-1; i>=0; i--) 
    180182            {   glClientActiveTextureARB(GL_TEXTURE0_ARB + i); 
     
    184186                glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); 
    185187            } 
    186  
     188*/ 
    187189        // Input options 
    188190        SDL_EnableUNICODE(true); 
     
    274276 
    275277    /// Draw the current material to the screen. 
    276     static void render() 
    277     { glPushAttrib(0xFFFFFFFF);   // all attribs 
     278    static void render(){ 
     279      glPushAttrib(0xFFFFFFFF);   // all attribs 
    278280 
    279281        // Setup the viewport in orthogonal mode, 
     
    289291        glDisable(GL_DEPTH_TEST); 
    290292        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(); 
    313298 
    314299        SDL_GL_SwapBuffers(); 
     
    364349    {   width = _width; 
    365350        height = _height; 
    366  
     351         
     352        foreach(sub ;this.subs) sub.recalculate(width, height); 
     353         
    367354        // For some reason, SDL Linux requires a call to SDL_SetVideoMode for a screen resize that's 
    368355        // larger than the current screen. (need to try this with latest version of SDL, alsy try SDL lock surface)