Skip to content

Commit 066cea1

Browse files
committed
Support loading luminance to texture and honour fliptexture attrib
Luminance texture is more space efficient
1 parent 8db0678 commit 066cea1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Geometry.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,21 +1883,30 @@ void Geometry::display(bool refresh)
18831883
//Load RGB/RGBA as texture
18841884
if (geom[index]->texwidth && geom[index]->texheight)
18851885
{
1886+
bool flip = geom[index]->draw->properties["fliptexture"];
18861887
//printf("TEX %d x %d RGB %d COLOURS %d TEXTURE %d\n", geom[index]->texwidth, geom[index]->texheight, geom[index]->render->rgb.size(), geom[index]->render->colours.size(), geom[index]->hasTexture());
18871888
//RGB as ubyte * 3
18881889
if (geom[index]->texwidth * geom[index]->texheight == geom[index]->render->rgb.size() * 3)
18891890
{
18901891
//printf(" - LOADING RGB %d to TEXTURE %d x %d\n", geom[index]->render->rgb.size(), geom[index]->texwidth, geom[index]->texheight);
1891-
geom[index]->texture->loadData(static_cast<GLubyte*>(geom[index]->render->rgb.ref()), geom[index]->texwidth, geom[index]->texheight, 3, false);
1892+
geom[index]->texture->loadData(static_cast<GLubyte*>(geom[index]->render->rgb.ref()), geom[index]->texwidth, geom[index]->texheight, 3, flip);
18921893
}
18931894
//RGBA as int32 (ubyte * 4)
18941895
else if (geom[index]->texwidth * geom[index]->texheight == geom[index]->render->colours.size())
18951896
{
18961897
//printf(" - LOADING RGBA %d to TEXTURE %d x %d\n", geom[index]->render->colours.size(), geom[index]->texwidth, geom[index]->texheight);
1897-
geom[index]->texture->loadData(static_cast<GLubyte*>(geom[index]->render->colours.ref()), geom[index]->texwidth, geom[index]->texheight, 4, false);
1898+
geom[index]->texture->loadData(static_cast<GLubyte*>(geom[index]->render->colours.ref()), geom[index]->texwidth, geom[index]->texheight, 4, flip);
18981899
//std::ofstream of("texout.png");
18991900
//write_png(of, 4, geom[index]->texwidth, geom[index]->texheight, geom[index]->render->colours.ref());
19001901
}
1902+
//LUM as ubyte * 1
1903+
else if (geom[index]->texwidth * geom[index]->texheight == geom[index]->render->luminance.size())
1904+
{
1905+
//printf(" - LOADING RGBA %d to TEXTURE %d x %d\n", geom[index]->render->colours.size(), geom[index]->texwidth, geom[index]->texheight);
1906+
geom[index]->texture->loadData(static_cast<GLubyte*>(geom[index]->render->luminance.ref()), geom[index]->texwidth, geom[index]->texheight, 1, flip);
1907+
//std::ofstream of("texout.png");
1908+
//write_png(of, 4, geom[index]->texwidth, geom[index]->texheight, geom[index]->render->luminance.ref());
1909+
}
19011910
}
19021911
}
19031912
}
@@ -2205,7 +2214,7 @@ Geom_Ptr Geometry::read(DrawingObject* draw, unsigned int n, lucGeometryDataType
22052214
void Geometry::read(Geom_Ptr geomdata, unsigned int n, lucGeometryDataType dtype, const void* data, int width, int height, int depth)
22062215
{
22072216
//Set width & height if provided
2208-
if (type != lucVolumeType && width && height && (dtype == lucRGBData || dtype == lucRGBAData))
2217+
if (type != lucVolumeType && width && height && (dtype == lucRGBData || dtype == lucRGBAData || dtype == lucLuminanceData))
22092218
{
22102219
//Set the texture width/height/depth
22112220
geomdata->texwidth = width;

0 commit comments

Comments
 (0)