source: trunk/src/gl/image.cc @ 13

Last change on this file since 13 was 13, checked in by epyon, 12 years ago
  • pure image functionality of texture_atlas split into image clas
File size: 847 bytes
Line 
1// Copyright (C) 2011 Kornel Kisielewicz
2// This file is part of NV Libraries.
3// For conditions of distribution and use, see copyright notice in nv.hh
4
5#include "nv/gl/image.hh"
6
7#include <cstring>
8
9using namespace nv;
10
11image::image( glm::ivec2 size, size_t depth )
12        : m_size( size ), m_depth( depth ), m_data( nullptr )
13{
14        m_data = new uint8[ m_size.x * m_size.y * m_depth ];
15}
16
17void image::fill( uint8 value )
18{
19        memset( m_data, value, m_size.x * m_size.y * m_depth );
20}
21
22void image::set_region( region r, const uint8 * data, size_t stride )
23{
24        if ( stride == 0 ) stride = r.size.x;
25
26    for( size_t i = 0; i < r.size.y; ++i )
27    {
28        memcpy( m_data+((r.pos.y+i)*m_size.x + r.pos.x ) * m_depth,
29                data + (i*stride), r.size.x * m_depth );
30    }
31}
32
33image::~image()
34{
35        delete[] m_data;
36}
37
Note: See TracBrowser for help on using the repository browser.