-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fe183f
commit c97a2d3
Showing
5 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
examples/02_AdvancedExamples/11_AssimpModel/ReflectParaBuffer.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Created by wjl on 21-4-10. | ||
// | ||
|
||
#include "ReflectParaBuffer.h" | ||
|
||
BEGIN_NAMESPACE(VulkanEngine) | ||
|
||
void ReflectParaBuffer::reflect() { | ||
if(getReflect() <= 0.f){ | ||
setReflect(1.f); | ||
} | ||
else{ | ||
setReflect(0.f); | ||
} | ||
} | ||
|
||
void ReflectParaBuffer::prepareUniformBuffers() { | ||
VK_CHECK_RESULT(m_context->vulkanDevice->createBuffer( | ||
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, | ||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, | ||
&m_uniformBuffer, sizeof(m_para), &m_para)); | ||
VK_CHECK_RESULT(m_uniformBuffer.map()); | ||
updateUniformBuffers(); | ||
} | ||
|
||
void ReflectParaBuffer::updateUniformBuffers() { | ||
memcpy(m_uniformBuffer.mapped, &m_para, sizeof(m_para)); | ||
} | ||
|
||
END_NAMESPACE(VulkanEngine) |
34 changes: 34 additions & 0 deletions
34
examples/02_AdvancedExamples/11_AssimpModel/ReflectParaBuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Created by wjl on 21-4-10. | ||
// | ||
|
||
#ifndef LEARNVULKAN_REFLECTPARABUFFER_H | ||
#define LEARNVULKAN_REFLECTPARABUFFER_H | ||
|
||
#include "VulkanBuffer.h" | ||
|
||
BEGIN_NAMESPACE(VulkanEngine) | ||
|
||
class ReflectParaBuffer : public VulkanBuffer { | ||
public: | ||
struct ReflectPara{ | ||
glm::vec4 para; | ||
} m_para; | ||
|
||
public: | ||
ReflectParaBuffer() = default; | ||
~ReflectParaBuffer() = default; | ||
|
||
void setReflect(float value) { m_para.para[0] = value; } | ||
|
||
float getReflect() { return m_para.para[0];} | ||
|
||
void reflect(); | ||
|
||
virtual void prepareUniformBuffers() override; | ||
virtual void updateUniformBuffers() override ; | ||
}; | ||
|
||
END_NAMESPACE(VulkanEngine) | ||
|
||
#endif //LEARNVULKAN_REFLECTPARABUFFER_H |