matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
491 stars 72 forks source link

Loading textures #95

Closed MaikKlein closed 9 years ago

MaikKlein commented 9 years ago
  Texture tex;
  gl.Bound(sv::_2D, tex)
    .Image2D(images::LoadTexture("/home/maik/Documents/fox.png"))
    .MinFilter(sv::Linear)
    .MagFilter(sv::Linear)
    .Anisotropy(2.0f)
    .WrapS(sv::Repeat)
    .WrapT(sv::Repeat);

Unfortuneatly that doesn't work for me. For same reason this line throws every time

    if(!file.good())
        throw std::runtime_error("Unable to open image: "+name);

I linked with libpng 1.6.15, but it's not a big deal, I wanted to use stb image anyway.

The problem is I am too stupid to figure out how load a texture manually. The function signature is

    const BoundObjOps& Image2D(
        GLint level,
        PixelDataInternalFormat internal_format,
        GLsizei width,
        GLsizei height,
        GLint border,
        PixelDataFormat format,
        ExplicitOps::Property::PixDataType type,
        const void * data
    ) const

But what is ExplicitOps::Property::PixDataType? What value do I need to pass in there?

It is defined as

    typedef OneOf<
        GLenum,
        std::tuple<
            DataType,
            PixelDataType
        >
    > PixDataType;
matus-chochlik commented 9 years ago

The OneOf template accepts any value from any of the enumeration types in the tuple, in this case DataType [1] or PixelDataType [2]

[1] http://matus-chochlik.github.io/oglplus/doc/oglplus/quickref/data_type.html [2] http://matus-chochlik.github.io/oglplus/doc/oglplus/quickref/pixel_data.html

HTH