Changeset 2312 for trunk/tutorial


Ignore:
Timestamp:
Feb 1, 2013, 3:49:03 PM (8 years ago)
Author:
sam
Message:

gpu: support 1-component (luminance) textures.

Location:
trunk/tutorial
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tutorial/04_texture.cpp

    r2277 r2312  
    3737        m_vertices << vec2( 1.0,  1.0);
    3838
    39         m_heightmap = new uint8_t[4 * TEXTURE_WIDTH * 1];
     39        m_heightmap = new uint8_t[TEXTURE_WIDTH * 1];
    4040    }
    4141
     
    5151        /* Generate a new heightmap at the beginning */
    5252        if (m_frames == 0)
    53             memset(m_heightmap, 255, 4 * TEXTURE_WIDTH);
     53            memset(m_heightmap, 255, TEXTURE_WIDTH);
    5454
    5555        /* Scroll left */
    5656        for (int i = 0; i < TEXTURE_WIDTH - 1; i++)
    57             m_heightmap[4 * i] = m_heightmap[4 * i + 4];
     57            m_heightmap[i] = m_heightmap[i + 1];
    5858
    59         int height = m_heightmap[4 * (TEXTURE_WIDTH - 1)];
     59        int height = m_heightmap[TEXTURE_WIDTH - 1];
    6060        height = (height + 127 + 40 * lol::sin(m_frames * 0.03) + rand() % 97 - 38) / 2;
    6161        height = std::max(15, std::min(height, 240));
    62         m_heightmap[4 * (TEXTURE_WIDTH - 1)] = height;
     62        m_heightmap[TEXTURE_WIDTH - 1] = height;
    6363
    6464        /* Update frame counter */
     
    7373        if (!m_ready)
    7474        {
    75             m_texture = new Texture(ivec2(TEXTURE_WIDTH, 1), PixelFormat::A8R8G8B8);
     75            m_texture = new Texture(ivec2(TEXTURE_WIDTH, 1), PixelFormat::Y_8);
    7676
    7777            m_shader = Shader::Create(LOLFX_RESOURCE_NAME(04_texture));
     
    118118    System::Init(argc, argv);
    119119
    120     Application app("Tutorial 4: Texture", ivec2(640, 480), 60.0f);
     120    Application app("Tutorial 4: Texture", ivec2(1280, 720), 60.0f);
    121121
    122122    new TextureDemo();
  • trunk/tutorial/11_fractal.cpp

    r2277 r2312  
    443443             * so that we can upload four different subimages each frame. */
    444444            m_texture = new Texture(ivec2(m_size.x / 2, m_size.y * 2),
    445                                     PixelFormat::A8B8G8R8);
     445                                    PixelFormat::ABGR_8);
    446446
    447447            /* Ensure the texture data is complete at least once, otherwise
Note: See TracChangeset for help on using the changeset viewer.