Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "Headers/glSamplerObject.h"

#include "Core/Headers/Console.h"
#include "Core/Headers/ParamHandler.h"
#include "Utility/Headers/Localization.h"
#include "Platform/Video/OpenGL/Headers/GLWrapper.h"
#include "Platform/Video/Textures/Headers/TextureDescriptor.h"

namespace Divide {
    
glSamplerObject::glSamplerObject(const SamplerDescriptor& descriptor) {
    DIVIDE_ASSERT(glfwExtensionSupported("GL_ARB_sampler_objects") == 1,
                  Locale::get("ERROR_NO_SAMPLER_SUPPORT"));

    glGenSamplers(1, &_samplerID);

    glSamplerParameterf(_samplerID, GL_TEXTURE_LOD_BIAS, descriptor.biasLOD());
    glSamplerParameterf(_samplerID, GL_TEXTURE_MIN_LOD, descriptor.minLOD());
    glSamplerParameterf(_samplerID, GL_TEXTURE_MAX_LOD, descriptor.maxLOD());
    glSamplerParameteri(
        _samplerID, GL_TEXTURE_MIN_FILTER,
        enum_to_uint(
            GLUtil::GL_ENUM_TABLE::glTextureFilterTable[enum_to_uint(descriptor
                                                            .minFilter())]));
    glSamplerParameteri(
        _samplerID, GL_TEXTURE_MAG_FILTER,
        enum_to_uint(
            GLUtil::GL_ENUM_TABLE::glTextureFilterTable[enum_to_uint(descriptor
                                                            .magFilter())]));
    glSamplerParameteri(
        _samplerID, GL_TEXTURE_WRAP_S,
        enum_to_uint(GLUtil::GL_ENUM_TABLE::glWrapTable[enum_to_uint(descriptor.wrapU())]));
    glSamplerParameteri(
        _samplerID, GL_TEXTURE_WRAP_T,
        enum_to_uint(GLUtil::GL_ENUM_TABLE::glWrapTable[enum_to_uint(descriptor.wrapV())]));
    glSamplerParameteri(
        _samplerID, GL_TEXTURE_WRAP_R,
        enum_to_uint(GLUtil::GL_ENUM_TABLE::glWrapTable[enum_to_uint(descriptor.wrapW())]));
    if (descriptor.wrapU() == TextureWrap::TEXTURE_CLAMP_TO_BORDER ||
        descriptor.wrapV() == TextureWrap::TEXTURE_CLAMP_TO_BORDER ||
        descriptor.wrapW() == TextureWrap::TEXTURE_CLAMP_TO_BORDER) {
        glSamplerParameterfv(_samplerID, GL_TEXTURE_BORDER_COLOR,
                             descriptor.borderColor());
    }

    if (descriptor._useRefCompare) {
        glSamplerParameteri(_samplerID, GL_TEXTURE_COMPARE_MODE,
                            enum_to_uint(GL_COMPARE_R_TO_TEXTURE));
        glSamplerParameteri(
            _samplerID, GL_TEXTURE_COMPARE_FUNC,
            enum_to_uint(
                GLUtil::GL_ENUM_TABLE::glCompareFuncTable[enum_to_uint(descriptor
                                                              ._cmpFunc)]));
    }

    if (descriptor.anisotropyLevel() > 1 && descriptor.generateMipMaps()) {
        GLint anisoLevel =
            std::min<I32>((GLint)descriptor.anisotropyLevel(),
                          ParamHandler::getInstance().getParam<GLint>(
                              "rendering.anisotropicFilteringLevel"));
        glSamplerParameterf(_samplerID, gl::GL_TEXTURE_MAX_ANISOTROPY_EXT,
                            anisoLevel);
    }
    // glSamplerParameterfv(_samplerID, GL_TEXTURE_BORDER_COLOR,
    // &vec4<F32>(0.0f).r));
}

glSamplerObject::~glSamplerObject() {
    if (_samplerID > 0 && _samplerID != GLUtil::_invalidObjectID) {
        glDeleteSamplers(1, &_samplerID);
        _samplerID = 0;
    }
}
};

Commits for Divide-Framework/trunk/Source Code/Platform/Video/OpenGL/Textures/glSamplerOject.cpp

Diff revisions: vs.
Revision Author Commited Message
364 Diff Diff IonutCava picture IonutCava Fri 06 Mar, 2015 16:55:21 +0000

[Ionut]
- Part 1 of type safe enum replacement (does not compile)

358 Diff Diff IonutCava picture IonutCava Sun 01 Mar, 2015 22:44:38 +0000

[Ionut]
- Fixed some OpenGL initialization issues and function calls (no proper support for DSA yet)
- Cleanup up the Sound and Physics Wrappers
- Some readability improvements here and there

354 Diff Diff IonutCava picture IonutCava Fri 20 Feb, 2015 17:17:37 +0000

[Ionut]
- Replaced GLEW with glbinding (requires a CEGUI recompile. It currently crashes)
- Replaced most “SceneGraphNode* const sgn” expressions with "SceneGraphNode& sgn"
- Replaced some pointers to kernel to references to kernel
- Fixed compilation issues with EASTL
- Removed NPOT -> POT texture conversion code. Modern GPUs handle NPOT textures perfectly fine

350 Diff Diff IonutCava picture IonutCava Tue 10 Feb, 2015 16:25:39 +0000

[Ionut]
- Simplified some Util-namespace level functions by using STL algorithms where possible
- Formatted the entire codebase using clang-format with the following style: "{BasedOnStyle: Google, IndentWidth: 4}"
- Attempted to make ProfileTimer thread-safe (temp fix until std::chrono works properly in Visual Studio)

334 IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

[Ionut]
- Reorganized the Hardware project and renamed to "Platform"
- Reorganized the Server project