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 "Core/Resources/Headers/ResourceCache.h"
#include "Core/Headers/ParamHandler.h"
#include "Environment/Water/Headers/Water.h"
#include "Platform/Video/Headers/GFXDevice.h"
#include "Geometry/Material/Headers/Material.h"

namespace Divide {

template <>
bool ImplResourceLoader<WaterPlane>::load(WaterPlane* const res,
                                          const stringImpl& name) {
    ParamHandler& param = ParamHandler::getInstance();
    res->setState(ResourceState::RES_LOADING);

    SamplerDescriptor defaultSampler;
    defaultSampler.setWrapMode(TextureWrap::REPEAT);
    defaultSampler.toggleMipMaps(false);
    ResourceDescriptor waterMaterial("waterMaterial_" + name);
    ResourceDescriptor waterShader("water_" + name);
    ResourceDescriptor waterTexture("waterTexture_" + name);
    ResourceDescriptor waterTextureDUDV("waterTextureDUDV_" + name);
    waterTexture.setResourceLocation(
        param.getParam<stringImpl>("assetsLocation") +
        "/misc_images/terrain_water_NM.jpg");
    waterTexture.setPropertyDescriptor(defaultSampler);
    waterTextureDUDV.setResourceLocation(
        param.getParam<stringImpl>("assetsLocation") +
        "/misc_images/water_dudv.jpg");
    waterTextureDUDV.setPropertyDescriptor(defaultSampler);

    Texture* waterNM = CreateResource<Texture>(waterTexture);
    assert(waterNM != nullptr);

    ShaderProgram* waterShaderProgram =
        CreateResource<ShaderProgram>(waterShader);
    waterShaderProgram->Uniform("texWaterNoiseNM", ShaderProgram::TextureUsage::UNIT0);
    waterShaderProgram->Uniform("texWaterReflection", ShaderProgram::TextureUsage::UNIT1);
    waterShaderProgram->Uniform("texWaterRefraction", 2);
    waterShaderProgram->Uniform("texWaterNoiseDUDV", 3);
    assert(waterShaderProgram != nullptr);

    Material* waterMat = CreateResource<Material>(waterMaterial);
    assert(waterMat != nullptr);
    // The material is responsible for the destruction of the textures and
    // shaders it receives!!!!
    res->setMaterialTpl(waterMat);

    waterMat->dumpToFile(false);
    waterMat->setShadingMode(Material::ShadingMode::BLINN_PHONG);
    waterMat->setTexture(ShaderProgram::TextureUsage::UNIT0, waterNM);
    waterMat->setShaderProgram(waterShaderProgram->getName(), RenderStage::DISPLAY,
                               true);
    waterMat->setShaderProgram("depthPass.PrePass", RenderStage::Z_PRE_PASS, true);

    U32 hash = waterMat->getRenderStateBlock(RenderStage::DISPLAY);
    RenderStateBlock waterMatDesc(GFX_DEVICE.getRenderStateBlock(hash));
    waterMatDesc.setCullMode(CullMode::NONE);
    waterMat->setRenderStateBlock(waterMatDesc.getHash(), RenderStage::DISPLAY);

    return true;
}

template<>
WaterPlane* ImplResourceLoader<WaterPlane>::operator()() {
    WaterPlane* ptr = MemoryManager_NEW WaterPlane();

    if (!load(ptr, _descriptor.getName())) {
        MemoryManager::DELETE(ptr);
    }

    return ptr;
}

};

Commits for Divide-Framework/trunk/Source Code/Core/Resources/ConcreteLoaders/WaterPlaneLoaderImpl.cpp

Diff revisions: vs.
Revision Author Commited Message
557 Diff Diff IonutCava picture IonutCava Tue 10 Nov, 2015 12:00:20 +0000

[IonutCava]
- Gather all rendering calls from glVertexArray and glGenericVertexData into a single function in glResources: submitRenderCommand.
— This allows both classes to interpret GenericDrawCommands in the same way
- Use unsigned ints for all hasehs instead of size_t to avoid negative number hashes (useful for debugging)

460 Diff Diff IonutCava picture IonutCava Tue 02 Jun, 2015 22:11:41 +0000

[Ionut]
- Linux port work

437 Diff Diff IonutCava picture IonutCava Thu 14 May, 2015 21:21:04 +0000

[Ionut]
- Merged RenderStateBlock and RenderStateBlockDescriptor classes

390 Diff Diff IonutCava picture IonutCava Thu 26 Mar, 2015 22:41:09 +0000

[Ionut]
- Renamed most enum values to shorter names (possible due to enum-class type safety)
- Removed to redundant state change cases (glCullFace when CULL_MODE_NONE was used, and glLineWidth that didn’t have redundancy checks)
- Added a hacky SceneGraphNode render call count to skip the first 3 draw calls so that the data buffers have time to update properly (solves flickering and erroneous rendering when moving camera to include a new node)

382 Diff Diff IonutCava picture IonutCava Sun 22 Mar, 2015 21:04:05 +0000

[Ionut]
- Re-enabled persistently mapped buffered
- Worked around various Material issues with shader generation
- Fixed a buffer destruction issues in GFXDevice (shade buffers deleted after the rendering context was destroyed)

377 Diff Diff IonutCava picture IonutCava Wed 18 Mar, 2015 17:24:16 +0000

[Ionut]
- Cleanup and optimizations:
— texture handles do not need to be atomic integers (only changed on construction and destruction of texture objects)
— simplified the RenderStage enum system
— replaced some hash maps from Material class with static arrays

371 Diff Diff IonutCava picture IonutCava Sat 14 Mar, 2015 21:18:52 +0000

[Ionut]
- More updates to the DSA style OpenGL API implementation

366 Diff Diff IonutCava picture IonutCava Tue 10 Mar, 2015 16:56:30 +0000

[Ionut]
- More type safe enum replacement

365 Diff Diff IonutCava picture IonutCava Sun 08 Mar, 2015 21:26:10 +0000

[Ionut]
- More enum-related type safety changes

350 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)