source: trunk/packages/vizservers/nanovis/vr3d/vrTexture1D.cpp @ 2824

Last change on this file since 2824 was 2824, checked in by ldelgass, 13 years ago

Remove cruft from vr3d lib

File size: 1.9 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#include <vr3d/vrTexture1D.h>
3
4#include <string.h>
5#include <math.h>
6#include <valarray>
7
8#ifdef _WIN32
9inline unsigned int log2(unsigned int x)
10{
11    unsigned int i = 0;
12    while ( ( x = ( x >> 1 ) ) != 0 ) i++;
13        return i;     
14}
15#endif
16
17vrTexture1D::vrTexture1D(bool depth):
18    _width(0)
19{
20    _target = TT_TEXTURE_1D;
21    _wrapS = TW_CLAMP_TO_EDGE;
22}
23
24vrTexture1D::~vrTexture1D()
25{
26}
27
28void vrTexture1D::setPixels(COLORFORMAT colorFormat, DATATYPE type,
29                            int width, void *data)
30{
31    setPixels(TT_TEXTURE_1D, colorFormat,  colorFormat, type, width, data);
32}
33
34void vrTexture1D::setPixels(TEXTARGET target,  COLORFORMAT internalColorFormat,
35                            COLORFORMAT colorFormat, DATATYPE type,
36                            int width, void* data)
37{
38    _target = target;
39    _width = width;
40    _type = type;
41    _internalColorFormat = internalColorFormat;
42    _colorFormat = colorFormat;
43    _compCount = GetNumComponent(_colorFormat);
44
45    if (_objectID)
46        {
47            glDeleteTextures(1, &_objectID);
48        }
49
50    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
51    glGenTextures(1, &_objectID);
52    glBindTexture(_target, _objectID);
53
54    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
55    glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
56    glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
57
58    glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
59}
60
61void vrTexture1D::updatePixels(void *data)
62{
63    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
64    glBindTexture(_target, _objectID);
65    glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
66    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
67    glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
68    glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
69}
Note: See TracBrowser for help on using the repository browser.