mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add new texture constructor, set_size() method
This commit is contained in:
parent
72e396f06d
commit
7766b9ced2
@ -70,6 +70,20 @@ INLINE PixelBuffer::
|
|||||||
~PixelBuffer(void) {
|
~PixelBuffer(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INLINE void PixelBuffer::
|
||||||
|
set_size(int x_org, int y_org, int x_size, int y_size) {
|
||||||
|
if ((_xsize != x_size) || (_ysize != y_size) ||
|
||||||
|
(_xorg != x_org) || (_yorg != y_org)) {
|
||||||
|
make_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
_xsize = x_size;
|
||||||
|
_ysize = y_size;
|
||||||
|
_xorg = x_org;
|
||||||
|
_yorg = y_org;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PixelBuffer::set_xsize
|
// Function: PixelBuffer::set_xsize
|
||||||
// Access:
|
// Access:
|
||||||
|
@ -69,6 +69,30 @@ PixelBuffer(int xsize, int ysize, int components, int component_width,
|
|||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PixelBuffer::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description: create a pixel buffer with specified format but do not alloc CPU RAM for it
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PixelBuffer::
|
||||||
|
PixelBuffer(int xsize, int ysize, int components, int component_width, Type type, Format format,
|
||||||
|
bool bAllocateRAM) : ImageBuffer()
|
||||||
|
{
|
||||||
|
_xsize = xsize;
|
||||||
|
_ysize = ysize;
|
||||||
|
_xorg = 0;
|
||||||
|
_yorg = 0;
|
||||||
|
_border = 0;
|
||||||
|
_components = components;
|
||||||
|
_component_width = component_width;
|
||||||
|
_type = type;
|
||||||
|
_format = format;
|
||||||
|
if(bAllocateRAM)
|
||||||
|
_image = PTA_uchar::empty_array((unsigned int)(_xsize * _ysize * _components * _component_width));
|
||||||
|
else _image = PTA_uchar();
|
||||||
|
_loaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PixelBuffer::Copy Constructor
|
// Function: PixelBuffer::Copy Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -70,7 +70,10 @@ public:
|
|||||||
F_blue,
|
F_blue,
|
||||||
F_alpha,
|
F_alpha,
|
||||||
F_rgb, // any suitable RGB mode, whatever the hardware prefers
|
F_rgb, // any suitable RGB mode, whatever the hardware prefers
|
||||||
F_rgb5, // specifically, 5 bits per R,G,B channel
|
F_rgb5, // specifically, 5 bits per R,G,B channel.
|
||||||
|
// this is paired with T_unsigned_byte. really T_unsigned_byte
|
||||||
|
// should not be specified for this one, it should use
|
||||||
|
// T_unsigned_5bits or something
|
||||||
F_rgb8, // 8 bits per R,G,B channel
|
F_rgb8, // 8 bits per R,G,B channel
|
||||||
F_rgb12, // 12 bits per R,G,B channel
|
F_rgb12, // 12 bits per R,G,B channel
|
||||||
F_rgb332, // 3 bits per R & G, 2 bits for B
|
F_rgb332, // 3 bits per R & G, 2 bits for B
|
||||||
@ -88,6 +91,9 @@ public:
|
|||||||
PixelBuffer(void);
|
PixelBuffer(void);
|
||||||
PixelBuffer(int xsize, int ysize, int components,
|
PixelBuffer(int xsize, int ysize, int components,
|
||||||
int component_width, Type type, Format format);
|
int component_width, Type type, Format format);
|
||||||
|
PixelBuffer(int xsize, int ysize, int components,
|
||||||
|
int component_width, Type type, Format format,
|
||||||
|
bool bAllocateRAM);
|
||||||
PixelBuffer(const PixelBuffer ©);
|
PixelBuffer(const PixelBuffer ©);
|
||||||
void operator = (const PixelBuffer ©);
|
void operator = (const PixelBuffer ©);
|
||||||
|
|
||||||
@ -117,6 +123,7 @@ public:
|
|||||||
INLINE void set_ysize(int size);
|
INLINE void set_ysize(int size);
|
||||||
INLINE void set_xorg(int org);
|
INLINE void set_xorg(int org);
|
||||||
INLINE void set_yorg(int org);
|
INLINE void set_yorg(int org);
|
||||||
|
INLINE void set_size(int x_org, int y_org, int x_size, int y_size);
|
||||||
INLINE void set_format(Format format);
|
INLINE void set_format(Format format);
|
||||||
|
|
||||||
INLINE int get_xsize() const;
|
INLINE int get_xsize() const;
|
||||||
|
@ -138,3 +138,5 @@ INLINE void Texture::
|
|||||||
apply(GraphicsStateGuardianBase *gsg) {
|
apply(GraphicsStateGuardianBase *gsg) {
|
||||||
gsg->apply_texture(prepare(gsg));
|
gsg->apply_texture(prepare(gsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +124,28 @@ Texture() : ImageBuffer() {
|
|||||||
_anisotropic_degree = 1;
|
_anisotropic_degree = 1;
|
||||||
_keep_ram_image = false;
|
_keep_ram_image = false;
|
||||||
_pbuffer = new PixelBuffer;
|
_pbuffer = new PixelBuffer;
|
||||||
_has_requested_size = false;
|
// _has_requested_size = false;
|
||||||
|
_all_dirty_flags = 0;
|
||||||
|
memset(&_border_color,0,sizeof(Colorf));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Texture::
|
||||||
|
Texture(int xsize, int ysize, int components, int component_width, PixelBuffer::Type type,
|
||||||
|
PixelBuffer::Format format, bool bAllocateRAM) : ImageBuffer() {
|
||||||
|
_magfilter = FT_nearest;
|
||||||
|
_minfilter = FT_nearest;
|
||||||
|
_wrapu = WM_repeat;
|
||||||
|
_wrapv = WM_repeat;
|
||||||
|
_anisotropic_degree = 1;
|
||||||
|
_keep_ram_image = bAllocateRAM;
|
||||||
|
_pbuffer = new PixelBuffer(xsize,ysize,components,component_width,type,format,bAllocateRAM);
|
||||||
|
// _has_requested_size = false;
|
||||||
_all_dirty_flags = 0;
|
_all_dirty_flags = 0;
|
||||||
memset(&_border_color,0,sizeof(Colorf));
|
memset(&_border_color,0,sizeof(Colorf));
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ PUBLISHED:
|
|||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
Texture();
|
Texture();
|
||||||
|
Texture(int xsize, int ysize, int components, int component_width, PixelBuffer::Type type, PixelBuffer::Format format,
|
||||||
|
bool bAllocateRAM);
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
bool read(const Filename &name);
|
bool read(const Filename &name);
|
||||||
@ -158,6 +160,7 @@ public:
|
|||||||
// pixel buffer when needed. Know what you are doing!
|
// pixel buffer when needed. Know what you are doing!
|
||||||
PT(PixelBuffer) _pbuffer;
|
PT(PixelBuffer) _pbuffer;
|
||||||
|
|
||||||
|
/*
|
||||||
// If you request a region from the framebuffer that is not a power of 2,
|
// If you request a region from the framebuffer that is not a power of 2,
|
||||||
// we need to grab a larger region that is a power of 2 that contains the
|
// we need to grab a larger region that is a power of 2 that contains the
|
||||||
// requested region and set the pixel buffer size accordingly. We store
|
// requested region and set the pixel buffer size accordingly. We store
|
||||||
@ -165,7 +168,7 @@ public:
|
|||||||
bool _has_requested_size;
|
bool _has_requested_size;
|
||||||
int _requested_w;
|
int _requested_w;
|
||||||
int _requested_h;
|
int _requested_h;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Datagram stuff
|
// Datagram stuff
|
||||||
|
Loading…
x
Reference in New Issue
Block a user