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

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

Add emacs mode magic line in preparation for indentation cleanup

File size: 1.7 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
17
18vrTexture1D::vrTexture1D(bool depth)
19: _width(0)
20{
21        _target = TT_TEXTURE_1D;
22        _wrapS =TW_CLAMP_TO_EDGE;
23}
24
25vrTexture1D::~vrTexture1D()
26{
27}
28
29void vrTexture1D::setPixels(COLORFORMAT colorFormat, DATATYPE type, int width, void* data)
30
31{
32    setPixels(TT_TEXTURE_1D, colorFormat,  colorFormat, type, width, data);
33}
34
35void vrTexture1D::setPixels(TEXTARGET target,  COLORFORMAT internalColorFormat, COLORFORMAT colorFormat, DATATYPE type, int width, void* data)
36{
37        _target = target;
38        _width = width;
39        _type = type;
40        _internalColorFormat = internalColorFormat;
41        _colorFormat = colorFormat;
42        _compCount = GetNumComponent(_colorFormat);
43
44        if (_objectID)
45        {
46                glDeleteTextures(1, &_objectID);
47        }
48
49        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
50        glGenTextures(1, &_objectID);
51        glBindTexture(_target, _objectID);
52
53        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
54        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
55        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
56
57        glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
58
59       
60}
61
62void vrTexture1D::updatePixels(void* data)
63{
64        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
65        glBindTexture(_target, _objectID);
66        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
67        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
68        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
69        glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
70}
71
Note: See TracBrowser for help on using the repository browser.