├── Emerald ├── EERedBlackTree.cpp ├── EESegmentTree.cpp ├── EEBalancedBinaryTree.cpp ├── EEShader │ ├── EEFilterShader.hlsl │ ├── EELightShader.hlsl │ ├── EERippleSpread.hlsl │ ├── EERippleHelper.hlsl │ ├── EECameraBuffer.hlsl │ ├── EEObjectBuffer.hlsl │ ├── EEPoints2DShader.hlsl │ ├── EEAverageShader.hlsl │ ├── EERippleDisturb.hlsl │ ├── EEFontShader.hlsl │ ├── EEGrayShader.hlsl │ ├── EEContrastAndBrightShader.hlsl │ ├── EELine2DShader.hlsl │ ├── EEErodeShader.hlsl │ ├── EEDilateShader.hlsl │ ├── EECannyShader.hlsl │ ├── EEQuad2DShader.hlsl │ ├── EEBoxShader.hlsl │ ├── EERippleShader.hlsl │ ├── EEBlurShader.hlsl │ └── EEShaderHelper.hlsl ├── EESkipList.h ├── EESegmentTree.h ├── EEBalancedBinaryTree.h ├── EECore.h ├── EED3D.cpp ├── EEFont.cpp ├── EEHelper.h ├── EEInput.h ├── EEMath.cpp ├── EETimer.h ├── Demo │ ├── Blur.cpp │ ├── Test.cpp │ ├── Bitmap.cpp │ ├── Canny.cpp │ ├── Erode.cpp │ ├── Line2d.cpp │ ├── Music2.cpp │ ├── Music3.cpp │ ├── Points.cpp │ ├── Ripple.cpp │ ├── Slide.cpp │ ├── Thread.cpp │ ├── Average.cpp │ ├── DNSServer.cpp │ ├── FontTest.cpp │ ├── ListView.cpp │ ├── Music │ │ └── jx.mp3 │ ├── Picking.cpp │ ├── Progress.cpp │ ├── Recoder.cpp │ ├── TCPClient.cpp │ ├── TCPSever.cpp │ ├── UDPClient.cpp │ ├── UDPServer.cpp │ ├── YYClient.cpp │ ├── animation.cpp │ ├── LineEditor.cpp │ ├── Mesh │ │ └── model.jpg │ ├── ScrollView.cpp │ ├── TCPwithFont.cpp │ ├── CameraAction.cpp │ ├── AnimationEditor.cpp │ ├── AnimationEditor2.cpp │ ├── CharacterGenerator.cpp │ ├── ContrastAndBright.cpp │ ├── DIVAProject │ │ ├── DIVAMenu.cpp │ │ ├── DIVAFreeMode.cpp │ │ ├── DIVAMain.cpp │ │ ├── DIVAMusicListView.h │ │ ├── DIVAManager.h │ │ ├── DIVAMusicListView.cpp │ │ ├── DIVAMusicList.h │ │ ├── DIVAMenu.h │ │ ├── DIVAFreeMode.h │ │ ├── DIVAConfig.h │ │ ├── DIVAManager.cpp │ │ ├── DIVAMap.h │ │ ├── DIVAConfig.cpp │ │ └── DIVAMusicList.cpp │ ├── NeuralNetworks.cpp │ ├── Music.cpp │ ├── 源1.cpp │ ├── SecureHashAlgorithm.cpp │ ├── Video.cpp │ ├── Algorithm.cpp │ └── GeneTest.cpp ├── EECurve2D.cpp ├── EEGeometry.h ├── EEHelper.cpp ├── EELine2D.cpp ├── EEQuad2D.cpp ├── EESystem.cpp ├── EETimer.cpp ├── EEObject3D.cpp ├── EEPoints2D.cpp ├── Include │ └── G729a.h ├── Lib │ └── G729aR.lib ├── EEFont │ ├── EEFont.dds │ └── EEFontdata.txt ├── EERedBlackTree.h ├── EEScrollView.cpp ├── EESecureHashAlgorithm.h ├── hosts ├── EEGUI.cpp ├── EEGeometry.cpp ├── EEMemoryLeak.cpp ├── EESlider.h ├── EEIntervalTree.cpp ├── EESmartPtr.cpp ├── EEMemoryLeak.h ├── EEAlgorithm.h ├── EEObject2D.h ├── EEGUI.h ├── EESort.h ├── EEWaveCoder.h ├── EEScene.h ├── EEEffect.h ├── EECharacterGenerator.h ├── EETextEditor.h ├── EELineEditor.h ├── EEComboBox.h ├── EEObject2D.cpp ├── EEObject3D.h ├── EEListView.h ├── EETextBrowser.h ├── EEHash.h ├── EEColor.h ├── EEGray.h ├── EEIntBoard.h ├── DirectXTex │ ├── Shaders │ │ └── CompileShaders.cmd │ ├── scoped.h │ └── BCDirectCompute.h ├── EEAverage.h ├── EEBlur.h ├── EEFloatBoard.h ├── EEErode.h ├── EEDilate.h ├── EESphere.h ├── EEGrid.h ├── EECanny.h ├── EEList.h ├── EEThread.h ├── EESlide.h ├── EEPolyhedron.h ├── EEButton.h ├── EEBox.h ├── EELineBrowser.h ├── EECylinder.h ├── EELine2D.h ├── EEMagicButton.h ├── EESocket.h ├── EEContrastAndBright.h ├── EERecorder.h ├── EEPoints2D.h ├── EECollision.h ├── EEScrollView.h ├── EEProgressBar.h ├── EECurve2D.h ├── EEEffect.cpp ├── EESort.cpp ├── EEUDP.h ├── EETCP.h ├── EEAction.h ├── Emerald.h ├── EEShaderState.h ├── EEScene.cpp ├── EETextEditor.cpp ├── EESystem.h ├── EEVideo.h ├── EEColor.cpp ├── EEBitmap.h ├── EERipple.h ├── EELineEditor.cpp ├── EEGeneticAlgorithm.h ├── EED3D.h ├── EECollision.cpp ├── EEWaveCoder.cpp ├── EEComboBox.cpp ├── EECharacterGenerator.cpp ├── EETextBrowser.cpp ├── EETexture.h ├── EEQuad2D.h ├── EEAnimation.h ├── EENeuralNetworks.h ├── EEListView.cpp ├── EEList.cpp ├── EESlide.cpp ├── EEThread.cpp └── EESmartPtr.h ├── etc ├── dilate0.jpg ├── dilate1.jpg ├── dilate2.jpg └── ripple.jpg ├── README.md ├── Emerald.sln ├── .gitattributes └── .gitignore /Emerald/EERedBlackTree.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Emerald/EESegmentTree.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Emerald/EEBalancedBinaryTree.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Emerald/EEShader/EEFilterShader.hlsl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Emerald/EESkipList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /Emerald/EESegmentTree.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /Emerald/EEBalancedBinaryTree.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /Emerald/EECore.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EECore.h -------------------------------------------------------------------------------- /etc/dilate0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/etc/dilate0.jpg -------------------------------------------------------------------------------- /etc/dilate1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/etc/dilate1.jpg -------------------------------------------------------------------------------- /etc/dilate2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/etc/dilate2.jpg -------------------------------------------------------------------------------- /etc/ripple.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/etc/ripple.jpg -------------------------------------------------------------------------------- /Emerald/EED3D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EED3D.cpp -------------------------------------------------------------------------------- /Emerald/EEFont.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEFont.cpp -------------------------------------------------------------------------------- /Emerald/EEHelper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEHelper.h -------------------------------------------------------------------------------- /Emerald/EEInput.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEInput.h -------------------------------------------------------------------------------- /Emerald/EEMath.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEMath.cpp -------------------------------------------------------------------------------- /Emerald/EETimer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EETimer.h -------------------------------------------------------------------------------- /Emerald/Demo/Blur.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Blur.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Test.cpp -------------------------------------------------------------------------------- /Emerald/EECurve2D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EECurve2D.cpp -------------------------------------------------------------------------------- /Emerald/EEGeometry.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEGeometry.h -------------------------------------------------------------------------------- /Emerald/EEHelper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEHelper.cpp -------------------------------------------------------------------------------- /Emerald/EELine2D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EELine2D.cpp -------------------------------------------------------------------------------- /Emerald/EEQuad2D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEQuad2D.cpp -------------------------------------------------------------------------------- /Emerald/EESystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EESystem.cpp -------------------------------------------------------------------------------- /Emerald/EETimer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EETimer.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Bitmap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Bitmap.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Canny.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Canny.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Erode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Erode.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Line2d.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Line2d.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Music2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Music2.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Music3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Music3.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Points.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Points.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Ripple.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Ripple.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Slide.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Slide.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Thread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Thread.cpp -------------------------------------------------------------------------------- /Emerald/EEObject3D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEObject3D.cpp -------------------------------------------------------------------------------- /Emerald/EEPoints2D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEPoints2D.cpp -------------------------------------------------------------------------------- /Emerald/Include/G729a.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Include/G729a.h -------------------------------------------------------------------------------- /Emerald/Lib/G729aR.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Lib/G729aR.lib -------------------------------------------------------------------------------- /Emerald/Demo/Average.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Average.cpp -------------------------------------------------------------------------------- /Emerald/Demo/DNSServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/DNSServer.cpp -------------------------------------------------------------------------------- /Emerald/Demo/FontTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/FontTest.cpp -------------------------------------------------------------------------------- /Emerald/Demo/ListView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/ListView.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Music/jx.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Music/jx.mp3 -------------------------------------------------------------------------------- /Emerald/Demo/Picking.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Picking.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Progress.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Progress.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Recoder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Recoder.cpp -------------------------------------------------------------------------------- /Emerald/Demo/TCPClient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/TCPClient.cpp -------------------------------------------------------------------------------- /Emerald/Demo/TCPSever.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/TCPSever.cpp -------------------------------------------------------------------------------- /Emerald/Demo/UDPClient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/UDPClient.cpp -------------------------------------------------------------------------------- /Emerald/Demo/UDPServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/UDPServer.cpp -------------------------------------------------------------------------------- /Emerald/Demo/YYClient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/YYClient.cpp -------------------------------------------------------------------------------- /Emerald/Demo/animation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/animation.cpp -------------------------------------------------------------------------------- /Emerald/EEFont/EEFont.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEFont/EEFont.dds -------------------------------------------------------------------------------- /Emerald/EERedBlackTree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EERedBlackTree.h -------------------------------------------------------------------------------- /Emerald/EEScrollView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEScrollView.cpp -------------------------------------------------------------------------------- /Emerald/Demo/LineEditor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/LineEditor.cpp -------------------------------------------------------------------------------- /Emerald/Demo/Mesh/model.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/Mesh/model.jpg -------------------------------------------------------------------------------- /Emerald/Demo/ScrollView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/ScrollView.cpp -------------------------------------------------------------------------------- /Emerald/Demo/TCPwithFont.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/TCPwithFont.cpp -------------------------------------------------------------------------------- /Emerald/Demo/CameraAction.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/CameraAction.cpp -------------------------------------------------------------------------------- /Emerald/EESecureHashAlgorithm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EESecureHashAlgorithm.h -------------------------------------------------------------------------------- /Emerald/Demo/AnimationEditor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/AnimationEditor.cpp -------------------------------------------------------------------------------- /Emerald/Demo/AnimationEditor2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/AnimationEditor2.cpp -------------------------------------------------------------------------------- /Emerald/Demo/CharacterGenerator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/CharacterGenerator.cpp -------------------------------------------------------------------------------- /Emerald/Demo/ContrastAndBright.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/ContrastAndBright.cpp -------------------------------------------------------------------------------- /Emerald/EEShader/EELightShader.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEShader/EELightShader.hlsl -------------------------------------------------------------------------------- /Emerald/EEShader/EERippleSpread.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/EEShader/EERippleSpread.hlsl -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMenu.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/DIVAProject/DIVAMenu.cpp -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAFreeMode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjarz/Emerald/HEAD/Emerald/Demo/DIVAProject/DIVAFreeMode.cpp -------------------------------------------------------------------------------- /Emerald/hosts: -------------------------------------------------------------------------------- 1 | 203.208.46.146 dl.google.com 2 | 203.208.46.146 dl-ssl.google.com 3 | 61.135.169.121 www.baidu.com 4 | 10.3.18.66 bbs.byr.cn 5 | 0.0.0.0 www.csdn.net -------------------------------------------------------------------------------- /Emerald/EEGUI.cpp: -------------------------------------------------------------------------------- 1 | #include "EEGUI.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | } -------------------------------------------------------------------------------- /Emerald/EEGeometry.cpp: -------------------------------------------------------------------------------- 1 | #include "EEGeometry.h" 2 | 3 | //---------------------------------------------------------------------------------------------------- 4 | namespace Emerald 5 | { 6 | 7 | } -------------------------------------------------------------------------------- /Emerald/EEShader/EERippleHelper.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_RIPPLEHELPER_H_ 2 | #define _EE_RIPPLEHELPER_H_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | 9 | #endif -------------------------------------------------------------------------------- /Emerald/EEMemoryLeak.cpp: -------------------------------------------------------------------------------- 1 | #include "EEMemoryLeak.h" 2 | 3 | #include 4 | 5 | int before_main() 6 | { 7 | //_CrtSetBreakAlloc(336); 8 | return 0; 9 | } 10 | int after_main() 11 | { 12 | _CrtDumpMemoryLeaks(); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Emerald/EESlider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SLIDER_H_ 3 | #define _EE_SLIDER_H_ 4 | 5 | #include 6 | #include "EEQuad2D.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | 12 | } 13 | 14 | 15 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMain.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | #include "DIVAManager.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | int main(int _argc, char** _argv) 7 | { 8 | DIVAManager manager; 9 | manager.Process(); 10 | 11 | return 0; 12 | } 13 | #endif -------------------------------------------------------------------------------- /Emerald/EEIntervalTree.cpp: -------------------------------------------------------------------------------- 1 | #include "EEIntervalTree.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | // EEIntervalTree 8 | //---------------------------------------------------------------------------------------------------- 9 | 10 | 11 | } -------------------------------------------------------------------------------- /Emerald/EESmartPtr.cpp: -------------------------------------------------------------------------------- 1 | #include "EESmartPtr.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | //EESmartPtr 8 | //---------------------------------------------------------------------------------------------------- 9 | 10 | 11 | 12 | 13 | 14 | 15 | } -------------------------------------------------------------------------------- /Emerald/EEMemoryLeak.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_MEMORYLEAK_H_ 3 | #define _EE_MEMORYLEAK_H_ 4 | 5 | #ifdef _EE_MEMORYLEAK_ON_ 6 | 7 | int before_main(); 8 | int after_main(); 9 | 10 | #pragma data_seg(".CRT$XIU") 11 | static int(*before[])() = { before_main }; 12 | #pragma data_seg(".CRT$XPU") 13 | static int(*after[])() = { after_main }; 14 | #pragma data_seg() 15 | 16 | #endif 17 | 18 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/NeuralNetworks.cpp: -------------------------------------------------------------------------------- 1 | // Demo 2 | #if 0 3 | #include "../Emerald.h" 4 | 5 | 6 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 7 | int main(int _argc, char** _argv) 8 | { 9 | EENeuralNetworks networks; 10 | networks.Generate(2, 1, {3, 5}); 11 | std::vector result = networks.Stimulate({ 0.5, 0.5 }); 12 | 13 | return 0; 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /Emerald/EEAlgorithm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_ALGORITHM_H_ 3 | #define _EE_ALGORITHM_H_ 4 | 5 | #include "EEMath.h" 6 | #include "EEBalancedBinaryTree.h" 7 | #include "EERedBlackTree.h" 8 | #include "EEIntervalTree.h" 9 | #include "EESegmentTree.h" 10 | #include "EERouletteWheel.h" 11 | #include "EEHash.h" 12 | #include "EEGeneticAlgorithm.h" 13 | #include "EENeuralNetworks.h" 14 | #include "EESecureHashAlgorithm.h" 15 | 16 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EECameraBuffer.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_CAMERABUFFER_HLSL_ 2 | #define _EE_CAMERABUFFER_HLSL_ 3 | 4 | #include "EEShaderHelper.hlsl" 5 | 6 | cbuffer CameraBuffer : register(b1) 7 | { 8 | row_major matrix cb_orthoLHMatrix : packoffset(c0); 9 | row_major matrix cb_perspectiveFovLHMatrix : packoffset(c4); 10 | row_major matrix cb_viewMatrix : packoffset(c8); 11 | float3 cb_eyePos : packoffset(c12); 12 | float cb_tmp0 : packoffset(c12.w); 13 | }; 14 | 15 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMusicListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../Emerald.h" 4 | #include "DIVAMusicList.h" 5 | 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | class DIVAMusicListView : public EEListView 9 | { 10 | public: 11 | DIVAMusicListView(const Rect_Float& _area); 12 | 13 | private: 14 | bool Initialize(); 15 | void Shutdown(); 16 | 17 | private: 18 | DIVAMusicList m_musicList; 19 | }; -------------------------------------------------------------------------------- /Emerald/Demo/Music.cpp: -------------------------------------------------------------------------------- 1 | // Music Demo 2 | #if 0 3 | #include "../Emerald.h" 4 | 5 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 6 | int main(int _argc, char** _argv) 7 | { 8 | EEMusic music; 9 | music.AsyncLoadMusic("Music/zhntn.mp3"); 10 | music.SetFrequencyRatio(1.5f); 11 | music.Start(); 12 | 13 | //music.Open("Music/zhntn.mp3"); 14 | //music.Play(); 15 | //music.Play(0.5, 0.1, 2); 16 | 17 | system("pause"); 18 | return 0; 19 | } 20 | #endif -------------------------------------------------------------------------------- /Emerald/EEObject2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_OBJECT2D_H_ 3 | #define _EE_OBJECT2D_H_ 4 | 5 | #include "EEObject.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | class EEObject2D : public EEObject 11 | { 12 | public: 13 | EEObject2D(); 14 | EEObject2D(const FLOAT3& _position); 15 | 16 | public: 17 | virtual MATRIX GetViewMatrix(); 18 | virtual MATRIX GetProjectionMatrix(); 19 | }; 20 | 21 | } 22 | 23 | #endif -------------------------------------------------------------------------------- /Emerald/EEGUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_GUI_H_ 3 | #define _EE_GUI_H_ 4 | 5 | #include "EEScene.h" 6 | #include "EEButton.h" 7 | #include "EEMagicButton.h" 8 | #include "EEProgressbar.h" 9 | #include "EELineBrowser.h" 10 | #include "EELineEditor.h" 11 | #include "EETextBrowser.h" 12 | #include "EETextEditor.h" 13 | #include "EEIntBoard.h" 14 | #include "EESlide.h" 15 | #include "EEFloatBoard.h" 16 | #include "EEAnimation.h" 17 | #include "EEComboBox.h" 18 | #include "EEList.h" 19 | #include "EEScrollView.h" 20 | #include "EEListView.h" 21 | 22 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEObjectBuffer.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_OBJECTBUFFER_HLSL_ 2 | #define _EE_OBJECTBUFFER_HLSL_ 3 | 4 | cbuffer ObjectBuffer : register(b0) 5 | { 6 | row_major matrix cb_worldMatrix : packoffset(c0); 7 | row_major matrix cb_worldViewProjMatrix : packoffset(c4); 8 | row_major matrix cb_rotationMatrix : packoffset(c8); 9 | float4 cb_color : packoffset(c12); 10 | int cb_texIndex : packoffset(c13.x); 11 | int cb_isUseColor : packoffset(c13.y); 12 | int cb_isUseTex : packoffset(c13.z); 13 | float cb_alpha : packoffset(c13.w); 14 | }; 15 | 16 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/源1.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | #include "../Emerald.h" 3 | #include 4 | #include 5 | #include 6 | 7 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 8 | int main(int _argc, char** _argv) 9 | { 10 | /* 11 | int i[6] = { 1, 2, 3, 4, 5 }; 12 | int j[6] = { 1, 2, 4, 4, 5 }; 13 | int *k = new int(4); 14 | __m128i tmp = _mm_mullo_epi32(*(__m128i*)i, *(__m128i*)&j[0]); 15 | tmp.m128i_i32[0]; 16 | //_mm_mulhi_epi16(*xmm0, *xmm1); 17 | */ 18 | 19 | return 0; 20 | } 21 | #endif 22 | 23 | /**/ -------------------------------------------------------------------------------- /Emerald/EESort.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SORT_HH_ 3 | #define _EE_SORT_HH_ 4 | 5 | #include 6 | #include "EEObject.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //EESort_APIs 12 | //---------------------------------------------------------------------------------------------------- 13 | void EEBubbleSort(std::vector& _objects, bool _isInverse = false); 14 | void EEInsertSort(std::vector& _objects, EEObject* _object, bool _isInverse = false); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _EE_MEMORYLEAK_ON_ 4 | #include "../../Emerald.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include "DIVAConfig.h" 10 | using namespace std; 11 | 12 | 13 | //---------------------------------------------------------------------------------------------------- 14 | class DIVAManager 15 | { 16 | public: 17 | DIVAManager(); 18 | virtual ~DIVAManager(); 19 | 20 | bool Process(); 21 | 22 | private: 23 | bool Initialize(); 24 | 25 | private: 26 | // state 27 | DIVAState m_state; 28 | int m_currentMusic; 29 | int m_currentDegree; 30 | 31 | // data 32 | }; -------------------------------------------------------------------------------- /Emerald/EEShader/EEPoints2DShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_POINTS2D_SHADER_H_ 2 | #define _EE_POINTS2D_SHADER_H_ 3 | 4 | #include "EEObjectBuffer.hlsl" 5 | #include "EECameraBuffer.hlsl" 6 | 7 | struct PointsVIn 8 | { 9 | float3 pos: POSITION; 10 | }; 11 | 12 | struct PointsVOut 13 | { 14 | float4 pos: SV_POSITION; 15 | }; 16 | 17 | PointsVOut PointsVS(PointsVIn _vIn) 18 | { 19 | PointsVOut vOut; 20 | vOut.pos = mul(float4(_vIn.pos, 1.0f), cb_worldViewProjMatrix); 21 | return vOut; 22 | } 23 | 24 | [earlydepthstencil] 25 | void PointsPS(PointsVOut _pIn, out float4 _finalColor :SV_TARGET) 26 | { 27 | _finalColor = cb_color; 28 | 29 | _finalColor.w = _finalColor.w * cb_alpha; 30 | } 31 | 32 | 33 | 34 | #endif -------------------------------------------------------------------------------- /Emerald/EEWaveCoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_WAVECODER_H_ 3 | #define _EE_WAVECODER_H_ 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | // EEWaveCoder 9 | //---------------------------------------------------------------------------------------------------- 10 | class EEWaveCoder 11 | { 12 | protected: 13 | static bool InitializeWaveCoder(); 14 | 15 | protected: 16 | static bool s_isWaveCoderInitialized; 17 | 18 | public: 19 | EEWaveCoder(); 20 | virtual ~EEWaveCoder(); 21 | 22 | static bool WaveEncode(char *_dataIn, int _inLen, char *_dataOut, int *_outLen); 23 | static bool WaveDecode(char *_dataIn, int _inLen, char *_dataOut, int *_outLen); 24 | }; 25 | } 26 | 27 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMusicListView.cpp: -------------------------------------------------------------------------------- 1 | #include "DIVAMusicListView.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | DIVAMusicListView::DIVAMusicListView(const Rect_Float& _area) 6 | : 7 | EEListView(_area), 8 | m_musicList() 9 | { 10 | Initialize(); 11 | } 12 | 13 | //---------------------------------------------------------------------------------------------------- 14 | bool DIVAMusicListView::Initialize() 15 | { 16 | for (DIVAMusicInfo musicInfo : *m_musicList.GetMusicList()) 17 | { 18 | Sleep(0); // Todo 19 | } 20 | 21 | return true; 22 | } 23 | 24 | //---------------------------------------------------------------------------------------------------- 25 | void DIVAMusicListView::Shutdown() 26 | { 27 | 28 | } -------------------------------------------------------------------------------- /Emerald/EEScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SCENE_H_ 3 | #define _EE_SCENE_H_ 4 | 5 | #include 6 | #include 7 | #include "EEGeometry.h" 8 | 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | namespace Emerald 12 | { 13 | // EEScne 14 | //---------------------------------------------------------------------------------------------------- 15 | class EEScene : public EEObject 16 | { 17 | public: 18 | EEScene(); 19 | EEScene(const EEScene &_scene); 20 | virtual ~EEScene(); 21 | 22 | virtual bool Update(); 23 | virtual bool Render(); 24 | void AddObject(EEObject* _object); 25 | void RemoveObject(EEObject* _object); 26 | 27 | protected: 28 | std::vector m_objects; 29 | }; 30 | } 31 | 32 | 33 | #endif -------------------------------------------------------------------------------- /Emerald/EEEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_EFFECT_H_ 3 | #define _EE_EFFECT_H_ 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | //EEEffect 9 | //---------------------------------------------------------------------------------------------------- 10 | class EEEffect 11 | { 12 | public: 13 | EEEffect(); 14 | EEEffect(EEEffect& _effect); 15 | virtual ~EEEffect(); 16 | 17 | virtual bool Update(); 18 | virtual bool Render(); 19 | virtual bool Process(); 20 | 21 | protected: 22 | bool m_isAlive; 23 | 24 | }; 25 | 26 | //EEEffect_APIs 27 | //---------------------------------------------------------------------------------------------------- 28 | bool EEProcess(EEEffect* _effect); 29 | } 30 | 31 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/SecureHashAlgorithm.cpp: -------------------------------------------------------------------------------- 1 | // SHA Demo 2 | #if 1 3 | #include "../Emerald.h" 4 | 5 | 6 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 7 | int main(int _argc, char** _argv) 8 | { 9 | std::string test("Hello world"); 10 | std::cout << EESecureHashAlgorithm::SHA_1(test) << std::endl; 11 | std::cout << EESecureHashAlgorithm::SHA_2_224(test) << std::endl; 12 | std::cout << EESecureHashAlgorithm::SHA_2_256(test) << std::endl; 13 | std::cout << EESecureHashAlgorithm::SHA_2_384(test) << std::endl; 14 | std::cout << EESecureHashAlgorithm::SHA_2_512(test) << std::endl; 15 | std::cout << EESecureHashAlgorithm::SHA_2_512_224(test) << std::endl; 16 | std::cout << EESecureHashAlgorithm::SHA_2_512_256(test) << std::endl; 17 | 18 | system("pause"); 19 | return 0; 20 | } 21 | 22 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEAverageShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_AVERAGESHADER_HLSL_ 2 | #define _EE_AVERAGESHADER_HLSL_ 3 | 4 | // Average 5 | //---------------------------------------------------------------------------------------------------- 6 | cbuffer AverageBuffer : register(b3) 7 | { 8 | float cb_value : packoffset(c0.x); 9 | float cb_tmp31 : packoffset(c0.y); 10 | float cb_tmp32 : packoffset(c0.z); 11 | float cb_tmp33 : packoffset(c0.w); 12 | }; 13 | 14 | Texture2D g_input : register(cs, t0); 15 | RWTexture2D g_output : register(cs, u0); 16 | 17 | [numthreads(1, 1, 1)] 18 | void AverageCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 19 | { 20 | float4 data = g_input[uint2(0, 0)]; 21 | 22 | 23 | g_output[uint2(0, 0)] = data; 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/Video.cpp: -------------------------------------------------------------------------------- 1 | // Video Demo 2 | #if 0 3 | #define _EE_MEMORYLEAK_ON_ 4 | #include "../Emerald.h" 5 | 6 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 7 | int main(int _argc, char** _argv) 8 | { 9 | // _CrtSetBreakAlloc(134); 10 | EEDesc desc; 11 | desc.applicationName = L"Emerald"; 12 | desc.isFullScreen = false; 13 | desc.width = 800; 14 | desc.height = 450; 15 | desc.isSSAA = true; 16 | desc.isVsync = true; 17 | EEInitialize(desc); 18 | 19 | 20 | EEVideo video(Rect_Float(0, 0, (float)EEGetWidth(), (float)EEGetHeight())); 21 | if (!video.Open("Demo/Video/qsx.flv")) 22 | { 23 | return 0; 24 | } 25 | video.Play(); 26 | 27 | while (EERun()) 28 | { 29 | EEBeginScene(EEColor::BLACK); 30 | 31 | video.Process(); 32 | 33 | EEEndScene(); 34 | } 35 | 36 | EEShutdown(); 37 | return 0; 38 | } 39 | 40 | #endif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Emerald 3 | ========== 4 | A small graphics engine using DirectX 11 5 | 6 | Requirement 7 | ---------- 8 | ``` 9 | Microsoft DirectX SDK (June 2010) 10 | ``` 11 | ``` 12 | boost_1_58_0 13 | ``` 14 | ``` 15 | freetype-2.5.3 16 | ``` 17 | ``` 18 | ffmpeg-20141217 19 | ``` 20 | Usage 21 | ---------- 22 | ### include 23 | ``` 24 | #include "Emerald.h" 25 | ``` 26 | ### init 27 | ``` 28 | EEDesc desc; 29 | desc.applicationName = L"Emerald"; 30 | desc.isFullScreen = false; 31 | desc.width = 800; 32 | desc.height = 450; 33 | desc.isSSAA = true; 34 | desc.isVsync = false; 35 | EEInitialize(desc); 36 | ``` 37 | You could also do that in this way: 38 | ``` 39 | EEInitialize(); 40 | ``` 41 | ### run 42 | ``` 43 | while (EERun()) 44 | { 45 | EEBeginScene(EEColor::WHITE); 46 | // todo 47 | EEEndScene(); 48 | } 49 | ``` 50 | ### shutdown 51 | ``` 52 | EEShutdown(); 53 | ``` 54 | -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMusicList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "DIVAMap.h" 7 | using namespace std; 8 | 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | struct DIVAMusicInfo 12 | { 13 | public: 14 | string musicName; 15 | string musicPath; 16 | map musicMapsPath; 17 | map musicMaps; 18 | }; 19 | 20 | //---------------------------------------------------------------------------------------------------- 21 | class DIVAMusicList 22 | { 23 | public: 24 | DIVAMusicList(); 25 | 26 | vector* GetMusicList(); 27 | const DIVAMap* GetMap(unsigned int _listId, DIVADifficulty _difficulty); 28 | 29 | private: 30 | bool LoadMusicList(); 31 | 32 | private: 33 | vector m_musicList; 34 | }; -------------------------------------------------------------------------------- /Emerald/EEShader/EERippleDisturb.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_RIPPLEDISTURB_HLSL_ 2 | #define _EE_RIPPLEDISTURB_HLSL_ 3 | 4 | #include "EERippleHelper.hlsl" 5 | 6 | //Disturb 7 | //---------------------------------------------------------------------------------------------------- 8 | cbuffer DisturbBuffer : register(b3) 9 | { 10 | int2 cb_pos : packoffset(c0.x); 11 | int cb_range : packoffset(c0.z); 12 | int cb_weight : packoffset(c0.w); 13 | }; 14 | 15 | RWTexture2D g_output : register(cs, u0); 16 | 17 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 18 | void DisturbCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 19 | { 20 | if (pow(cb_pos.x - _threadID.x, 2) + pow(cb_pos.y - _threadID.y, 2) < pow(cb_range, 2)) 21 | { 22 | g_output[uint2(_threadID.x, _threadID.y)] += cb_weight; 23 | } 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /Emerald/EECharacterGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_CHARACTERGENERATOR_H_ 3 | #define _EE_CHARACTERGENERATOR_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "EEBitmap.h" 9 | #include "EEIntervalTree.h" 10 | 11 | 12 | //---------------------------------------------------------------------------------------------------- 13 | namespace Emerald 14 | { 15 | //---------------------------------------------------------------------------------------------------- 16 | class EECharacterGenerator 17 | { 18 | public: 19 | EECharacterGenerator(); 20 | ~EECharacterGenerator(); 21 | 22 | bool Generate(EEBitmap& _bitmap, std::vector& _result); 23 | bool Generate(EEBitmap& _bitmap, std::string& _result); 24 | 25 | protected: 26 | bool Initialize(); 27 | 28 | protected: 29 | EEIntervalTree characterTree; 30 | }; 31 | } 32 | 33 | 34 | 35 | #endif -------------------------------------------------------------------------------- /Emerald/EETextEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_TEXTEditor_H_ 3 | #define _EE_TEXTEditor_H_ 4 | 5 | #include "EEGeometry.h" 6 | #include "EEFont.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //EETextEditor 12 | //---------------------------------------------------------------------------------------------------- 13 | class EETextEditor : public EEQuad2D 14 | { 15 | protected: 16 | 17 | 18 | public: 19 | EETextEditor(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor); 20 | EETextEditor(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor); 21 | EETextEditor(const EETextEditor& _lineEditor); 22 | virtual ~EETextEditor(); 23 | 24 | virtual bool Update(); 25 | virtual bool Render(); 26 | 27 | protected: 28 | EEFont m_font; 29 | }; 30 | } 31 | 32 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../Emerald.h" 4 | #include "DIVAConfig.h" 5 | 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | class DIVAMenu 9 | { 10 | public: 11 | DIVAMenu(); 12 | virtual ~DIVAMenu(); 13 | 14 | DIVAState Process(); 15 | 16 | private: 17 | bool Initialize(); 18 | void Shutdown(); 19 | 20 | private: 21 | // state 22 | DIVAState m_state; 23 | 24 | // UI 25 | EEScene m_scene; 26 | EEQuad2D m_backgroundQuad; 27 | EEQuad2D m_logoQuad; 28 | EEQuad2D m_circle1Quad; 29 | EEQuad2D m_circle2Quad; 30 | EEQuad2D m_line1Quad; 31 | EEQuad2D m_line2Quad; 32 | EEQuad2D m_topQuad; 33 | EEQuad2D m_bottomQuad; 34 | EEQuad2D m_dpQuad; 35 | EEIntBoard m_dpBoard; 36 | EEParticleEmitter m_noteParticle; 37 | EEMagicButton m_freeModeButton; 38 | EEProgressbar m_musicBar; 39 | EEQuad2D m_musicBarArea; 40 | }; -------------------------------------------------------------------------------- /Emerald/EELineEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_LINEEditor_H_ 3 | #define _EE_LINEEditor_H_ 4 | 5 | #include "EEGeometry.h" 6 | #include "EEFont.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EELineEditor 12 | //---------------------------------------------------------------------------------------------------- 13 | class EELineEditor : public EEQuad2D 14 | { 15 | public: 16 | EELineEditor(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor); 17 | EELineEditor(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor); 18 | EELineEditor(const EELineEditor& _lineEditor); 19 | virtual ~EELineEditor(); 20 | 21 | virtual bool Update(); 22 | virtual bool Render(); 23 | 24 | const std::wstring& GetText(); 25 | 26 | protected: 27 | EEFont m_font; 28 | }; 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Emerald/EEShader/EEFontShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_FONTSHADER_HLSL_ 2 | #define _EE_FONTSHADER_HLSL_ 3 | 4 | #include "EEObjectBuffer.hlsl" 5 | #include "EECameraBuffer.hlsl" 6 | 7 | Texture2D g_tex0 : register(ps, t0); 8 | 9 | SamplerState texSampler 10 | { 11 | Filter = ANISOTROPIC; 12 | }; 13 | 14 | struct FontVIn 15 | { 16 | float3 pos: POSITION; 17 | float2 tex: TEXCOORD; 18 | }; 19 | 20 | struct FontVOut 21 | { 22 | float4 pos: SV_POSITION; 23 | float2 tex: TEXCOORD; 24 | }; 25 | 26 | FontVOut FontVS(FontVIn _vIn) 27 | { 28 | FontVOut vOut; 29 | vOut.pos = mul(float4(_vIn.pos, 1.0f), cb_worldViewProjMatrix); 30 | vOut.tex = _vIn.tex; 31 | return vOut; 32 | } 33 | 34 | [earlydepthstencil] 35 | void FontPS(FontVOut _pIn, out float4 _finalColor :SV_TARGET) 36 | { 37 | float4 sampledColor = g_tex0.Sample(texSampler, _pIn.tex); 38 | if (sampledColor.r == 0.0f) 39 | clip(-1); 40 | _finalColor = sampledColor * cb_color; 41 | _finalColor.w *= cb_alpha; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /Emerald/EEComboBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_COMBOBOX_H_ 3 | #define _EE_COMBOBOX_H_ 4 | 5 | #include "EEGeometry.h" 6 | #include "EELineBrowser.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEButtonType 12 | //---------------------------------------------------------------------------------------------------- 13 | class EEComboBox : public EELineBrowser 14 | { 15 | public: 16 | EEComboBox(const Rect_Float& _rect, const EEColor& _color, const EEColor& _fontColor); 17 | virtual ~EEComboBox(); 18 | 19 | virtual bool Update(); 20 | virtual bool Render(); 21 | bool AddItem(const std::wstring& _str, std::function _funcPtr = []{}); 22 | 23 | virtual void OnMouseClicked(const Point& _pos); 24 | 25 | protected: 26 | bool m_isSelecting; 27 | std::vector m_options; 28 | int m_selected; 29 | bool m_isSelectedDirty; 30 | }; 31 | } 32 | 33 | #endif -------------------------------------------------------------------------------- /Emerald/EEObject2D.cpp: -------------------------------------------------------------------------------- 1 | #include "EEObject2D.h" 2 | #include"EECore.h" 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | //---------------------------------------------------------------------------------------------------- 8 | EEObject2D::EEObject2D() 9 | : 10 | EEObject() 11 | { 12 | 13 | } 14 | 15 | //---------------------------------------------------------------------------------------------------- 16 | EEObject2D::EEObject2D(const FLOAT3& _position) 17 | : 18 | EEObject(_position) 19 | { 20 | 21 | } 22 | 23 | //---------------------------------------------------------------------------------------------------- 24 | MATRIX EEObject2D::GetViewMatrix() 25 | { 26 | return MATRIX::IDENTITY; 27 | } 28 | 29 | //---------------------------------------------------------------------------------------------------- 30 | MATRIX EEObject2D::GetProjectionMatrix() 31 | { 32 | return EECore::s_EECore->GetOrthoLHMatrix(); 33 | } 34 | } -------------------------------------------------------------------------------- /Emerald/EEObject3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_OBJECT3D_H_ 3 | #define _EE_OBJECT3D_H_ 4 | 5 | #include "EEObject.h" 6 | #include "EECollision.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | class EEObject3D : public EEObject 12 | { 13 | protected: 14 | static bool Initialize(); 15 | 16 | protected: 17 | static bool s_isInitialized; 18 | static ID3D11InputLayout *s_objectIL; 19 | static ID3D11VertexShader *s_objectVS; 20 | static ID3D11PixelShader *s_objectPS; 21 | 22 | public: 23 | EEObject3D(); 24 | EEObject3D(const FLOAT3& _position); 25 | 26 | public: 27 | virtual MATRIX GetViewMatrix(); 28 | virtual MATRIX GetProjectionMatrix(); 29 | 30 | protected: 31 | // the vertex and index buffer of the box 32 | ID3D11Buffer *m_objectVB; 33 | int m_vertexCount; 34 | ID3D11Buffer *m_objectIB; 35 | int m_indexCount; 36 | // collision 37 | EEAxisAlignedBox m_axisAlignedBox; 38 | }; 39 | 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /Emerald/EEListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_LISTVIEW_H_ 3 | #define _EE_LISTVIEW_H_ 4 | 5 | #include "EESCrollView.h" 6 | #include "EEList.h" 7 | 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | // EEListView 13 | //---------------------------------------------------------------------------------------------------- 14 | class EEListView : public EEScrollView 15 | { 16 | public: 17 | EEListView(); 18 | EEListView(const Rect_Float& _area); 19 | EEListView(const EEListView& _listView); 20 | virtual ~EEListView(); 21 | 22 | virtual bool Update(); 23 | virtual bool Render(); 24 | virtual bool Process(); 25 | bool AddObject(EEObject* _object); 26 | bool AddObjectAt(EEObject* _object, int _index); 27 | bool RemoveObject(EEObject* _object); 28 | bool RemoveObjectAt(int _index); 29 | 30 | protected: 31 | bool SetContent(EEObject* _content); 32 | 33 | protected: 34 | EEList m_list; 35 | }; 36 | } 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEGrayShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_GRAYSHADER_HLSL_ 2 | #define _EE_GRAYSHADER_HLSL_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | // Gray 9 | //---------------------------------------------------------------------------------------------------- 10 | cbuffer GrayBuffer : register(b3) 11 | { 12 | float cb_value : packoffset(c0.x); 13 | float cb_tmp31 : packoffset(c0.y); 14 | float cb_tmp32 : packoffset(c0.z); 15 | float cb_tmp33 : packoffset(c0.w); 16 | }; 17 | 18 | Texture2D g_input : register(cs, t0); 19 | RWTexture2D g_output : register(cs, u0); 20 | 21 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 22 | void GrayCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 23 | { 24 | float4 value = g_input[uint2(_threadID.x, _threadID.y)]; 25 | float gray = value.x * 0.299 + value.y * 0.587 + value.z * 0.114; 26 | 27 | g_output[_threadID.xy] = float4(gray, gray, gray, value.w); 28 | } 29 | 30 | #endif -------------------------------------------------------------------------------- /Emerald/EETextBrowser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_TEXTBROWSER_H_ 3 | #define _EE_TEXTBROWSER_H_ 4 | 5 | #include "EEGeometry.h" 6 | #include "EEFont.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EETextBrowser 12 | //---------------------------------------------------------------------------------------------------- 13 | class EETextBrowser : public EEQuad2D 14 | { 15 | public: 16 | EETextBrowser(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor); 17 | EETextBrowser(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor); 18 | EETextBrowser(const EETextBrowser& _textBrowser); 19 | virtual ~EETextBrowser(); 20 | 21 | virtual bool Update(); 22 | virtual bool Render(); 23 | bool AddText(wchar_t _text); 24 | bool AddText(const wchar_t* _text); 25 | 26 | void SetText(const std::wstring& _text); 27 | 28 | const std::wstring& GetText(); 29 | 30 | protected: 31 | EEFont m_font; 32 | }; 33 | } 34 | 35 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEContrastAndBrightShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_GRAYSHADER_HLSL_ 2 | #define _EE_GRAYSHADER_HLSL_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | // ContrastAndBright (f(x) * (c * 0.01f) + b) 9 | //---------------------------------------------------------------------------------------------------- 10 | cbuffer ContrastAndBrightBuffer : register(b3) 11 | { 12 | float cb_contrast : packoffset(c0.x); 13 | float cb_bright : packoffset(c0.y); 14 | float cb_tmp32 : packoffset(c0.z); 15 | float cb_tmp33 : packoffset(c0.w); 16 | }; 17 | 18 | Texture2D g_input : register(cs, t0); 19 | RWTexture2D g_output : register(cs, u0); 20 | 21 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 22 | void ContrastAndBrightCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 23 | { 24 | float4 value = g_input[uint2(_threadID.x, _threadID.y)]; 25 | 26 | g_output[uint2(_threadID.x, _threadID.y)] = value * (cb_contrast * 0.01f) + cb_bright; 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /Emerald/EEHash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_HASH_H_ 3 | #define _EE_HASH_H_ 4 | 5 | 6 | //---------------------------------------------------------------------------------------------------- 7 | namespace Emerald 8 | { 9 | unsigned int RSHash(char* _str, unsigned int _len); 10 | unsigned int JSHash(char* _str, unsigned int _len); 11 | unsigned int PJWHash(char* _str, unsigned int _len); 12 | unsigned int ELFHash(char* _str, unsigned int _len); 13 | unsigned int BKDRHash(char* _str, unsigned int _len); 14 | unsigned int SDBMHash(char* _str, unsigned int _len); 15 | unsigned int DJBHash(char* _str, unsigned int _len); 16 | unsigned int DEKHash(char* _str, unsigned int _len); 17 | unsigned int BPHash(char* _str, unsigned int _len); 18 | unsigned int FNVHash(char* _str, unsigned int _len); 19 | unsigned int APHash(char* _str, unsigned int _len); 20 | unsigned int HFLPHash(char* _str, unsigned int _len); 21 | unsigned int HFHash(char* _str, unsigned int _len); 22 | unsigned int StrHash(char* _str, unsigned int _len); 23 | unsigned int TianlHash(char* _str, unsigned int _len); 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /Emerald.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Emerald", "Emerald\Emerald.vcxproj", "{EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}.Debug|Win32.Build.0 = Debug|Win32 16 | {EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}.Debug|Win32.Deploy.0 = Debug|Win32 17 | {EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}.Release|Win32.ActiveCfg = Release|Win32 18 | {EEF4FDD6-62DA-454E-BD29-EC501C1E11BB}.Release|Win32.Build.0 = Release|Win32 19 | EndGlobalSection 20 | GlobalSection(SolutionProperties) = preSolution 21 | HideSolutionNode = FALSE 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAFreeMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../Emerald.h" 4 | #include "DIVAConfig.h" 5 | #include "DIVAMusicListView.h" 6 | 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | class DIVAFreeMode 10 | { 11 | public: 12 | DIVAFreeMode(); 13 | virtual ~DIVAFreeMode(); 14 | 15 | DIVAState Process(); 16 | 17 | private: 18 | bool Initialize(); 19 | void Shutdown(); 20 | 21 | bool SetDifficulty(int _difficulty); 22 | 23 | private: 24 | // state 25 | DIVAState m_state; 26 | int m_difficulty; 27 | 28 | // UI 29 | EEScene m_scene; 30 | EESlide m_backgroundSlide; 31 | EESlide m_circleSlide; 32 | EESlide m_line1Slide; 33 | EESlide m_line2Slide; 34 | EESlide m_starSlide; 35 | EEQuad2D m_itemZoneQuad; 36 | EEButton m_itemButton; 37 | EEQuad2D m_topQuad; 38 | EEQuad2D m_bottomQuad; 39 | EEQuad2D m_difficultyFrame1Quad; 40 | EEQuad2D m_difficultyFrame2Quad; 41 | EEButton m_easyButton; 42 | EEButton m_normalButton; 43 | EEButton m_hardButton; 44 | EEButton m_extremeButton; 45 | DIVAMusicListView m_listView; 46 | }; -------------------------------------------------------------------------------- /Emerald/EEColor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_COLOR_H_ 3 | #define _EE_COLOR_H_ 4 | 5 | #include "EEMath.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | //EEColor 11 | //---------------------------------------------------------------------------------------------------- 12 | class EEColor : public FLOAT4 13 | { 14 | public: 15 | static const EEColor BLACK; 16 | static const EEColor WHITE; 17 | static const EEColor RED; 18 | static const EEColor GREEN; 19 | static const EEColor BLUE; 20 | static const EEColor YELLOW; 21 | static const EEColor CYAN; 22 | static const EEColor MAGENTA; 23 | static const EEColor SILVER; 24 | static const EEColor COLORS[9]; 25 | static const EEColor LUCENCY; 26 | 27 | public: 28 | EEColor(); 29 | EEColor(FLOAT _red, FLOAT _green, FLOAT _yellow, FLOAT _alpha); 30 | EEColor(const FLOAT4& _color); 31 | EEColor(const EEColor& _color); 32 | virtual ~EEColor(); 33 | 34 | bool SetColor(const FLOAT4& _color); 35 | 36 | const FLOAT4& GetColor(); 37 | }; 38 | } 39 | 40 | #endif -------------------------------------------------------------------------------- /Emerald/EEGray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_GRAY_H_ 3 | #define _EE_GRAY_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEGrayBufferDesc 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EEGrayBufferDesc 14 | { 15 | int value; 16 | float tmp1; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EEGrayC 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEGrayC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeGrayC(); 27 | 28 | protected: 29 | static bool s_isGrayCInitialized; 30 | static ID3D11Buffer *s_grayBuffer; 31 | static ID3D11ComputeShader *s_grayCS; 32 | 33 | public: 34 | EEGrayC(EETexture& _target); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | 39 | protected: 40 | EETexture m_target; 41 | EETexture m_backup; 42 | }; 43 | } 44 | 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EEIntBoard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_INTBOARD_H_ 3 | #define _EE_INTBOARD_H_ 4 | 5 | #include 6 | #include "EEQuad2D.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //EEIntBoard 12 | //---------------------------------------------------------------------------------------------------- 13 | class EEIntBoard : public EEQuad2D 14 | { 15 | public: 16 | EEIntBoard(const Rect_Float& _boardRect, int _range); 17 | EEIntBoard(const Rect_Float& _boardRect, int _range, EETexture* _textures); 18 | EEIntBoard(const EEIntBoard& _intBoard); 19 | virtual ~EEIntBoard(); 20 | 21 | virtual bool Update(); 22 | virtual bool Render(); 23 | 24 | bool SetValue(int _value); 25 | bool SetRange(int _range); 26 | bool SetNumTextures(EETexture* _textures); 27 | 28 | int GetValue(); 29 | int GetRange(); 30 | 31 | protected: 32 | int m_range; 33 | bool m_isRangeDirty; 34 | int m_value; 35 | bool m_isValueDirty; 36 | std::vector m_num; 37 | EETexture m_numTexs[10]; 38 | }; 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /Emerald/DirectXTex/Shaders/CompileShaders.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 3 | rem ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 4 | rem THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 5 | rem PARTICULAR PURPOSE. 6 | rem 7 | rem Copyright (c) Microsoft Corporation. All rights reserved. 8 | 9 | setlocal 10 | set error=0 11 | 12 | call :CompileShader BC7Encode TryMode456CS 13 | call :CompileShader BC7Encode TryMode137CS 14 | call :CompileShader BC7Encode TryMode02CS 15 | call :CompileShader BC7Encode EncodeBlockCS 16 | 17 | call :CompileShader BC6HEncode TryModeG10CS 18 | call :CompileShader BC6HEncode TryModeLE10CS 19 | call :CompileShader BC6HEncode EncodeBlockCS 20 | 21 | echo. 22 | 23 | if %error% == 0 ( 24 | echo Shaders compiled ok 25 | ) else ( 26 | echo There were shader compilation errors! 27 | ) 28 | 29 | endlocal 30 | exit /b 31 | 32 | :CompileShader 33 | set fxc=fxc /nologo %1.hlsl /Tcs_4_0 /Zpc /Qstrip_reflect /Qstrip_debug /E%2 /FhCompiled\%1_%2.inc /Vn%1_%2 34 | echo. 35 | echo %fxc% 36 | %fxc% || set error=1 37 | exit /b 38 | -------------------------------------------------------------------------------- /Emerald/Demo/Algorithm.cpp: -------------------------------------------------------------------------------- 1 | // Demo 2 | #if 0 3 | #include "../Emerald.h" 4 | 5 | 6 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 7 | int main(int _argc, char** _argv) 8 | { 9 | EEIntervalTree tree; 10 | tree.Insert(1.f, 2.f, 1); 11 | tree.Insert(2.f, 3.f, 2); 12 | tree.Insert(3.f, 4.f, 3); 13 | tree.Insert(4.f, 5.f, 4); 14 | tree.Insert(5.f, 6.f, 5); 15 | std::vector data; 16 | tree.FindData(3.f, 4.f, data); 17 | 18 | EERedBlackTree rbTree; 19 | rbTree.Insert(6.f, 1); 20 | rbTree.Insert(3.f, 1); 21 | rbTree.Insert(5.f, 1); 22 | rbTree.Insert(2.f, 1); 23 | rbTree.Insert(20.f, 1); 24 | rbTree.Insert(1.f, 1); 25 | rbTree.Delete(5.f, 1); 26 | std::vector rbData; 27 | rbTree.GetData(rbData); 28 | for (auto& rbTmp : rbTree) 29 | { 30 | rbData.push_back(rbTmp); 31 | } 32 | 33 | EERouletteWheel rouletteWheel; 34 | rouletteWheel.Insert(50, 1); 35 | rouletteWheel.Insert(30, 2); 36 | rouletteWheel.Insert(10, 3); 37 | int rwResult = 0; 38 | rouletteWheel.Select(-30, rwResult); 39 | rouletteWheel.Delete(10, 3); 40 | 41 | return 0; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /Emerald/EEAverage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_AVERAGE_H_ 3 | #define _EE_AVERAGE_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEAverageBufferDesc 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EEAverageBufferDesc 14 | { 15 | int value; 16 | float tmp1; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EEAverage 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEAverageC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeAverageC(); 27 | 28 | protected: 29 | static bool s_isAverageCInitialized; 30 | static ID3D11Buffer *s_averageBuffer; 31 | static ID3D11ComputeShader *s_averageCS; 32 | 33 | public: 34 | EEAverageC(); 35 | EEAverageC(const EETexture& _src); 36 | 37 | virtual bool Update(); 38 | virtual bool Render(); 39 | 40 | protected: 41 | EETexture m_target; 42 | EETexture m_backup; 43 | }; 44 | 45 | } 46 | 47 | 48 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EELine2DShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_LINE2D_SHADER_H_ 2 | #define _EE_LINE2D_SHADER_H_ 3 | 4 | #include "EEObjectBuffer.hlsl" 5 | #include "EECameraBuffer.hlsl" 6 | 7 | Texture2DArray g_tex0 : register(ps, t0); 8 | 9 | SamplerState texSampler 10 | { 11 | Filter = ANISOTROPIC; 12 | }; 13 | 14 | struct LineVIn 15 | { 16 | float3 pos: POSITION; 17 | float2 tex: TEXCOORD; 18 | }; 19 | 20 | struct LineVOut 21 | { 22 | float4 pos: SV_POSITION; 23 | float2 tex: TEXCOORD; 24 | }; 25 | 26 | LineVOut LineVS(LineVIn _vIn) 27 | { 28 | LineVOut vOut; 29 | vOut.pos = mul(float4(_vIn.pos, 1.0f), cb_worldViewProjMatrix); 30 | vOut.tex = _vIn.tex; 31 | return vOut; 32 | } 33 | 34 | [earlydepthstencil] 35 | void LinePS(LineVOut _pIn, out float4 _finalColor :SV_TARGET) 36 | { 37 | if (cb_isUseColor && cb_isUseTex) 38 | _finalColor = g_tex0.Sample(texSampler, float3(_pIn.tex, cb_texIndex)) * cb_color; 39 | else if (cb_isUseColor) 40 | _finalColor = cb_color; 41 | else if (cb_isUseTex) 42 | _finalColor = g_tex0.Sample(texSampler, float3(_pIn.tex, cb_texIndex)); 43 | else 44 | _finalColor = cb_color; 45 | 46 | _finalColor.w = _finalColor.w * cb_alpha; 47 | } 48 | 49 | 50 | 51 | #endif -------------------------------------------------------------------------------- /Emerald/EEBlur.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_BLUR_H_ 3 | #define _EE_BLUR_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEBlurBufferDesc 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EEBlurBufferDesc 14 | { 15 | int value; 16 | float tmp1; 17 | float tmp2; 18 | float tmp3; 19 | 20 | }; 21 | //EEBlurC (/Gaussian blur) 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEBlurC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeBlurC(); 27 | 28 | protected: 29 | static bool s_isBlurCInitialized; 30 | static ID3D11Buffer *s_blurBuffer; 31 | static ID3D11ComputeShader *s_blurHorzCS; 32 | static ID3D11ComputeShader *s_blurVertCS; 33 | 34 | public: 35 | EEBlurC(EETexture& _target); 36 | 37 | virtual bool Update(); 38 | virtual bool Render(); 39 | 40 | protected: 41 | EETexture m_backup; 42 | EETexture m_tmp; 43 | EETexture m_target; 44 | }; 45 | 46 | } 47 | 48 | 49 | #endif -------------------------------------------------------------------------------- /Emerald/EEFloatBoard.h: -------------------------------------------------------------------------------- 1 | #ifndef _EE_FLOATBOARD_H_ 2 | #define _EE_FLOATBOARD_H_ 3 | 4 | #include 5 | #include "EEQuad2D.h" 6 | 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //EEFloatBoard 12 | //---------------------------------------------------------------------------------------------------- 13 | class EEFloatBoard : public EEQuad2D 14 | { 15 | public: 16 | EEFloatBoard(const Rect_Float& _boardRect, int _intRange, int _decimalRange, EETexture* _textures); 17 | EEFloatBoard(const EEFloatBoard& _floatBoard); 18 | virtual ~EEFloatBoard(); 19 | 20 | virtual bool Update(); 21 | virtual bool Render(); 22 | 23 | bool SetValue(float _value); 24 | bool SetIntRange(int _range); 25 | bool SetDecimalRange(int _range); 26 | bool SetRange(int _intRange, int _decimalRange); 27 | 28 | float GetValue(); 29 | int GetIntRange(); 30 | int GetDecimalRange(); 31 | 32 | protected: 33 | int m_intRange; 34 | int m_decimalRange; 35 | bool m_isRangeDirty; 36 | float m_value; 37 | bool m_isValueDirty; 38 | std::vector m_num; 39 | EETexture m_numTexs[11]; 40 | }; 41 | } 42 | 43 | 44 | #endif -------------------------------------------------------------------------------- /Emerald/EEErode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_ERODE_H_ 3 | #define _EE_ERODE_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | // EEErodeBufferDesc 13 | //---------------------------------------------------------------------------------------------------- 14 | struct EEErodeBufferDesc 15 | { 16 | INT2 kernel; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EEErodeC 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEErodeC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeErodeC(); 27 | 28 | protected: 29 | static bool s_isErodeCInitialized; 30 | static ID3D11Buffer *s_erodeBuffer; 31 | static ID3D11ComputeShader *s_erodeCS; 32 | 33 | public: 34 | EEErodeC(EETexture& _target, EETexture& _gray, const INT2& _kernel); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | 39 | protected: 40 | EETexture m_backup; 41 | EETexture m_backupGray; 42 | EETexture m_target; 43 | INT2 m_kernel; 44 | }; 45 | } 46 | 47 | 48 | #endif -------------------------------------------------------------------------------- /Emerald/EEDilate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_DILATE_H_ 3 | #define _EE_DILATE_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | // EEDilateBufferDesc 13 | //---------------------------------------------------------------------------------------------------- 14 | struct EEDilateBufferDesc 15 | { 16 | INT2 kernel; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EEDilateC 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEDilateC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeDilateC(); 27 | 28 | protected: 29 | static bool s_isDilateCInitialized; 30 | static ID3D11Buffer *s_dilateBuffer; 31 | static ID3D11ComputeShader *s_dilateCS; 32 | 33 | public: 34 | EEDilateC(EETexture& _target, EETexture& _gray, const INT2& _kernel); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | 39 | protected: 40 | EETexture m_backup; 41 | EETexture m_backupGray; 42 | EETexture m_target; 43 | INT2 m_kernel; 44 | }; 45 | } 46 | 47 | 48 | #endif -------------------------------------------------------------------------------- /Emerald/EESphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SPHERE_H_ 3 | #define _EE_SPHERE_H_ 4 | 5 | #include "EEObject3D.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | // EESphereVertex 11 | //---------------------------------------------------------------------------------------------------- 12 | struct EESphereVertex 13 | { 14 | FLOAT3 pos; 15 | FLOAT3 normal; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EESphere 20 | //---------------------------------------------------------------------------------------------------- 21 | class EESphere : public EEObject3D 22 | { 23 | public: 24 | EESphere(float _radius, int _slice, int _stack); 25 | EESphere(float _radius, int _slice, int _stack, const EETexture& _tex); 26 | EESphere(const EESphere& _sphere); 27 | virtual ~EESphere(); 28 | virtual inline EEObject* Clone() { return new EESphere(*this); } 29 | 30 | virtual bool Update(); 31 | virtual bool Render(); 32 | 33 | protected: 34 | //vbuffer and ibuffer 35 | bool CreateSphereBuffer(); 36 | 37 | protected: 38 | //the size of the sphere 39 | float m_radius; 40 | int m_slice; 41 | int m_stack; 42 | }; 43 | } 44 | 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EEGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_GRID_H_ 3 | #define _EE_GRID_H_ 4 | 5 | #include "EEObject3D.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | // EEGridVertex 11 | //---------------------------------------------------------------------------------------------------- 12 | struct EEGridVertex 13 | { 14 | FLOAT3 pos; 15 | FLOAT3 normal; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EEGrid 20 | //---------------------------------------------------------------------------------------------------- 21 | class EEGrid : public EEObject3D 22 | { 23 | public: 24 | EEGrid(float _width, float _height, unsigned int _m, unsigned int _n); 25 | EEGrid(float _width, float _height, unsigned int _m, unsigned int _n, const EETexture& _tex); 26 | EEGrid(const EEGrid& _grid); 27 | virtual ~EEGrid(); 28 | virtual inline EEObject* Clone() { return new EEGrid(*this); } 29 | 30 | virtual bool Update(); 31 | virtual bool Render(); 32 | 33 | protected: 34 | // vbuffer and ibuffer 35 | bool CreateGridBuffer(); 36 | 37 | protected: 38 | // the size of the grid 39 | FLOAT2 m_size; 40 | int m_m; 41 | int m_n; 42 | }; 43 | } 44 | 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EECanny.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_CANNY_H_ 3 | #define _EE_CANNY_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | // EECannyBufferDesc 13 | //---------------------------------------------------------------------------------------------------- 14 | struct EECannyBufferDesc 15 | { 16 | INT2 kernel; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EECannyC 22 | //---------------------------------------------------------------------------------------------------- 23 | class EECannyC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeCannyC(); 27 | 28 | protected: 29 | static bool s_isCannyCInitialized; 30 | static ID3D11Buffer *s_cannyBuffer; 31 | static ID3D11ComputeShader *s_cannyCS; 32 | 33 | public: 34 | EECannyC(EETexture& _target, EETexture& _gray, const INT2& _kernel); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | 39 | protected: 40 | EETexture m_backup; 41 | EETexture m_backupGray; 42 | EETexture m_gradient; 43 | EETexture m_target; 44 | INT2 m_kernel; 45 | }; 46 | } 47 | 48 | 49 | #endif -------------------------------------------------------------------------------- /Emerald/EEList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_LIST_H_ 3 | #define _EE_LIST_H_ 4 | 5 | #include 6 | #include 7 | #include "EEGeometry.h" 8 | 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | namespace Emerald 12 | { 13 | // EEListItem 14 | //---------------------------------------------------------------------------------------------------- 15 | struct EEListItem 16 | { 17 | EEObject* anchor; 18 | EEObject* content; 19 | 20 | inline EEListItem(EEObject* _anchor,EEObject* _content) 21 | : 22 | anchor(_anchor), 23 | content(_content) 24 | {} 25 | }; 26 | 27 | // EEList 28 | //---------------------------------------------------------------------------------------------------- 29 | class EEList : public EEObject 30 | { 31 | public: 32 | EEList(); 33 | EEList(const EEList &_list); 34 | virtual ~EEList(); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | bool AddObject(EEObject* _object); 39 | bool AddObjectAt(EEObject* _object, unsigned int _index); 40 | bool RemoveObject(EEObject* _object); 41 | bool RemoveObjectAt(unsigned int _index); 42 | 43 | protected: 44 | std::vector m_objects; 45 | }; 46 | } 47 | 48 | 49 | #endif -------------------------------------------------------------------------------- /Emerald/EEThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_THREAD_H_ 3 | #define _EE_THREAD_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | // it is not useful now 10 | //---------------------------------------------------------------------------------------------------- 11 | namespace Emerald 12 | { 13 | //EEThreadSystem 14 | //---------------------------------------------------------------------------------------------------- 15 | class EEThreadSystem 16 | { 17 | public: 18 | EEThreadSystem(); 19 | EEThreadSystem(const EEThreadSystem& _system); 20 | inline virtual ~EEThreadSystem() { Shutdown(); } 21 | 22 | bool Initialize(); 23 | void Shutdown(); 24 | 25 | bool AddThread(boost::thread* _thread); 26 | bool RemoveThread(boost::thread* _thread); 27 | bool RemoveThread(); 28 | void JoinAll(); 29 | 30 | private: 31 | std::list m_threads; 32 | }; 33 | 34 | //EEThread_APIs 35 | //---------------------------------------------------------------------------------------------------- 36 | void EEThreadSleep(int _millisecs); 37 | bool EEAddThread(boost::thread* _thread); 38 | bool EERemoveThread(boost::thread* _thread); 39 | bool EERemoveThread(); 40 | void EEJoinAll(); 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | enum DIVAState 9 | { 10 | DIVA_DEFAULT = 0, 11 | DIVA_MENU, 12 | DIVA_FREE_MODE, 13 | DIVA_END 14 | }; 15 | 16 | //---------------------------------------------------------------------------------------------------- 17 | enum DIVADifficulty 18 | { 19 | DIVA_EASY = 0, 20 | DIVA_NORMAL, 21 | DIVA_HARD, 22 | DIVA_FUCK 23 | }; 24 | 25 | //---------------------------------------------------------------------------------------------------- 26 | class DIVAConfig 27 | { 28 | public: 29 | static bool Initialize(); 30 | 31 | static char GetKeyMap(unsigned int _key); 32 | static int GetFramesPerBeat(); 33 | static int GetPeriodsPerBeat(); 34 | static int GetNoteNum(); 35 | static int GetMusicMaxPerFrame(); 36 | static int GetNoteWidth(); 37 | static int GetNoteHeight(); 38 | 39 | private: 40 | static bool s_isInitialized; 41 | 42 | static std::map s_keyMap; 43 | static int s_framesPerBeat; 44 | static int s_periodsPerBeat; 45 | static int s_noteNum; 46 | static int s_musicMaxPerFrame; 47 | static int s_noteWidth; 48 | static int s_noteHeight; 49 | }; 50 | -------------------------------------------------------------------------------- /Emerald/EESlide.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SLIDE_H_ 3 | #define _EE_SLIDE_H_ 4 | 5 | #include 6 | #include "EEQuad2D.h" 7 | 8 | // memo: textures count <= 128 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | //EESlide 13 | //---------------------------------------------------------------------------------------------------- 14 | class EESlide : public EEQuad2D 15 | { 16 | public: 17 | EESlide(const Rect_Float& _rect, float _interval = 0.0f, bool _isLoop = true); 18 | EESlide(const Rect_Float& _rect, EETexture& _texs, float _interval = 0.0f, bool _isLoop = true); 19 | EESlide(const Rect_Float& _rect, EETexture* _texs, int _amount, float _interval = 0.0f, bool _isLoop = true); 20 | EESlide(const Rect_Float& _rect, std::vector& _texs, float _interval = 0.0f, bool _isLoop = true); 21 | EESlide(const EESlide& _slide); 22 | virtual inline EEObject* Clone() { return new EESlide(*this); } 23 | 24 | virtual bool Update(); 25 | 26 | bool SetCurrentSlide(int _num); 27 | void SetInterval(float _interval); 28 | void SetIsLoop(bool _isLoop); 29 | 30 | protected: 31 | float m_updateTime; 32 | float m_changeInterval; 33 | bool m_isLoop; 34 | }; 35 | } 36 | 37 | 38 | #endif -------------------------------------------------------------------------------- /Emerald/EEPolyhedron.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_POLYHEDRON_H_ 3 | #define _EE_POLYHEDRON_H_ 4 | 5 | #include "EEObject3D.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | // EEPolyhedronVertex 11 | //---------------------------------------------------------------------------------------------------- 12 | struct EEPolyhedronVertex 13 | { 14 | FLOAT3 pos; 15 | FLOAT3 normal; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EEPolyhedron 20 | //---------------------------------------------------------------------------------------------------- 21 | class EEPolyhedron : public EEObject3D 22 | { 23 | public: 24 | EEPolyhedron(const LPCWSTR _fileName); 25 | EEPolyhedron(const LPCWSTR _fileName, const EETexture& _tex); 26 | EEPolyhedron(const EEPolyhedron& _polyhedron); 27 | virtual ~EEPolyhedron(); 28 | virtual inline EEObject* Clone() { return new EEPolyhedron(*this); } 29 | 30 | virtual bool Update(); 31 | virtual bool Render(); 32 | 33 | protected: 34 | //vbuffer and ibuffer 35 | bool CreatePolyhedronBuffer(const LPCWSTR _fileName); 36 | 37 | protected: 38 | //the size of the polyhedron 39 | float m_radius; 40 | int m_slice; 41 | int m_stack; 42 | }; 43 | } 44 | 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EEButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_BUTTON_H_ 3 | #define _EE_BUTTON_H_ 4 | 5 | #include "EEQuad2D.h" 6 | //#include 7 | 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | // EEButton 13 | //---------------------------------------------------------------------------------------------------- 14 | class EEButton : public EEQuad2D 15 | { 16 | public: 17 | EEButton(const Rect_Float& _rect, const EETexture& _tex, std::function _funcPtr = [] {}); 18 | EEButton(const Rect_Float& _rect, const EETexture& _upTex, const EETexture& _overTex, const EETexture& _downTex, std::function _funcPtr = []{}); 19 | EEButton(const EEButton& _button); 20 | virtual ~EEButton(); 21 | 22 | virtual bool Update(); 23 | virtual bool Render(); 24 | 25 | virtual Rect_Float GetFinalRect() const; 26 | EETexture* GetUpTex(); 27 | EETexture* GetOverTex(); 28 | EETexture* GetDownTex(); 29 | 30 | // OnFunction 31 | virtual void OnMouseOver(const Point& _pos); 32 | virtual void OnMouseClicked(const Point& _pos); 33 | virtual void OnMouseTriggered(const Point& _pos); 34 | 35 | protected: 36 | EETexture m_overTex, m_downTex; 37 | // callback function 38 | std::function m_callbackFunc; 39 | }; 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /Emerald/EEBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_BOX_H_ 3 | #define _EE_BOX_H_ 4 | 5 | #include "EEObject3D.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | // EEBoxVertex 11 | //---------------------------------------------------------------------------------------------------- 12 | struct EEBoxVertex 13 | { 14 | FLOAT3 pos; 15 | FLOAT3 normal; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EEBox 20 | //---------------------------------------------------------------------------------------------------- 21 | class EEBox : public EEObject3D 22 | { 23 | public: 24 | EEBox(const FLOAT3& _pos, const FLOAT3& _size); 25 | EEBox(const FLOAT3& _pos, const FLOAT3& _size, const EETexture& _tex); 26 | EEBox(const FLOAT3& _pos, FLOAT _width, FLOAT _height, FLOAT _depth); 27 | EEBox(const FLOAT3& _pos, FLOAT _width, FLOAT _height, FLOAT _depth, const EETexture& _tex); 28 | EEBox(const EEBox& _box); 29 | virtual ~EEBox(); 30 | virtual inline EEObject* Clone() { return new EEBox(*this); } 31 | 32 | virtual bool Update(); 33 | virtual bool Render(); 34 | 35 | protected: 36 | // vbuffer and ibuffer 37 | bool CreateBoxVertexBuffer(); 38 | bool CreateBoxIndexBuffer(); 39 | 40 | protected: 41 | // the size of the box 42 | FLOAT3 m_size; 43 | }; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEErodeShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_ERODESHADER_HLSL_ 2 | #define _EE_ERODESHADER_HLSL_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | // Erode 9 | //---------------------------------------------------------------------------------------------------- 10 | cbuffer ErodeBuffer : register(b3) 11 | { 12 | int2 cb_kernel : packoffset(c0.x); 13 | float cb_tmp32 : packoffset(c0.z); 14 | float cb_tmp33 : packoffset(c0.w); 15 | }; 16 | 17 | Texture2D g_input : register(cs, t0); 18 | Texture2D g_input_gray : register(cs, t1); 19 | RWTexture2D g_output : register(cs, u0); 20 | 21 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 22 | void ErodeCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 23 | { 24 | uint2 index = _threadID.xy; 25 | 26 | int i = max((int)_threadID.x - cb_kernel.x, 0); 27 | int ie = min(_threadID.x + cb_kernel.x, g_input.Length.x - 1); 28 | for (; i <= ie; ++i) 29 | { 30 | int j = max((int)_threadID.y - cb_kernel.y, 0); 31 | int je = min(_threadID.y + cb_kernel.y, g_input.Length.y - 1); 32 | for (; j <= je; ++j) 33 | { 34 | if (g_input_gray[uint2(i, j)] < g_input_gray[index]) 35 | index = uint2(i, j); 36 | } 37 | } 38 | 39 | g_output[_threadID.xy] = g_input[index]; 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /Emerald/EELineBrowser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_LINEBROWSER_H_ 3 | #define _EE_LINEBROWSER_H_ 4 | 5 | #include "EEGeometry.h" 6 | #include "EEFont.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EELineBrowser 12 | //---------------------------------------------------------------------------------------------------- 13 | class EELineBrowser : public EEQuad2D 14 | { 15 | public: 16 | EELineBrowser(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor); 17 | EELineBrowser(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor, const std::string& _text); 18 | EELineBrowser(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor, const std::wstring& _text); 19 | EELineBrowser(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor, const std::wstring& _text); 20 | EELineBrowser(const EELineBrowser& _lineEditor); 21 | virtual ~EELineBrowser(); 22 | 23 | virtual bool Update(); 24 | virtual bool Render(); 25 | bool AddText(wchar_t _text); 26 | bool AddText(const wchar_t* _text); 27 | 28 | void SetText(const std::string& _text); 29 | void SetText(const std::wstring& _text); 30 | 31 | const std::wstring& GetText(); 32 | 33 | protected: 34 | EEFont m_font; 35 | }; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Emerald/EEShader/EEDilateShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_DILATESHADER_HLSL_ 2 | #define _EE_DILATESHADER_HLSL_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | // Dilate 9 | //---------------------------------------------------------------------------------------------------- 10 | cbuffer DilateBuffer : register(b3) 11 | { 12 | int2 cb_kernel : packoffset(c0.x); 13 | float cb_tmp32 : packoffset(c0.z); 14 | float cb_tmp33 : packoffset(c0.w); 15 | }; 16 | 17 | Texture2D g_input : register(cs, t0); 18 | Texture2D g_input_gray : register(cs, t1); 19 | RWTexture2D g_output : register(cs, u0); 20 | 21 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 22 | void DilateCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 23 | { 24 | uint2 index = _threadID.xy; 25 | 26 | int i = max((int)_threadID.x - cb_kernel.x, 0); 27 | int ie = min(_threadID.x + cb_kernel.x, g_input.Length.x - 1); 28 | for (; i <= ie; ++i) 29 | { 30 | int j = max((int)_threadID.y - cb_kernel.y, 0); 31 | int je = min(_threadID.y + cb_kernel.y, g_input.Length.y - 1); 32 | for (; j <= je; ++j) 33 | { 34 | if (g_input_gray[uint2(i, j)] > g_input_gray[index]) 35 | index = uint2(i, j); 36 | } 37 | } 38 | 39 | g_output[_threadID.xy] = g_input[index]; 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /Emerald/EECylinder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_CYLINDER_H_ 3 | #define _EE_CYLINDER_H_ 4 | 5 | #include "EEObject3D.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | // EECylinderVertex 11 | //---------------------------------------------------------------------------------------------------- 12 | struct EECylinderVertex 13 | { 14 | FLOAT3 pos; 15 | FLOAT3 normal; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EECylinder 20 | //---------------------------------------------------------------------------------------------------- 21 | class EECylinder : public EEObject3D 22 | { 23 | public: 24 | EECylinder(float _topRadius, float _bottomRadius, float _height, int _slice, int _stack); 25 | EECylinder(float _topRadius, float _bottomRadius, float _height, int _slice, int _stack, const EETexture& _tex); 26 | EECylinder(const EECylinder& _cylinder); 27 | virtual ~EECylinder(); 28 | virtual inline EEObject* Clone() { return new EECylinder(*this); } 29 | 30 | virtual bool Update(); 31 | virtual bool Render(); 32 | 33 | protected: 34 | // vbuffer and ibuffer 35 | bool CreateCylinderBuffer(); 36 | 37 | protected: 38 | // the size of the cylinder 39 | float m_topRadius; 40 | float m_bottomRadius; 41 | float m_height; 42 | int m_slice; 43 | int m_stack; 44 | }; 45 | } 46 | 47 | 48 | #endif -------------------------------------------------------------------------------- /Emerald/EELine2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_LINE2D_H_ 3 | #define _EE_LINE2D_H_ 4 | 5 | #include "EEObject2D.h" 6 | #include "EETexture.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //EELine2DVertex 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EELine2DVertex 14 | { 15 | FLOAT3 pos; 16 | FLOAT2 tex; 17 | }; 18 | 19 | //EELine2D 20 | //---------------------------------------------------------------------------------------------------- 21 | class EELine2D : public EEObject2D 22 | { 23 | protected: 24 | static bool InitializeLine2D(); 25 | 26 | protected: 27 | static bool s_isLine2DInitialized; 28 | static ID3D11InputLayout *s_lineIL; 29 | static ID3D11VertexShader *s_lineVS; 30 | static ID3D11PixelShader *s_linePS; 31 | static ID3D11Buffer *s_line2DBuffer; 32 | 33 | public: 34 | EELine2D(FLOAT2& _start, FLOAT2& _end, const EEColor& _color); 35 | virtual ~EELine2D(); 36 | 37 | virtual bool Update(); 38 | virtual bool Render(); 39 | 40 | void SetWidth(float _width); 41 | 42 | protected: 43 | bool CreateLineVertexBuffer(); 44 | 45 | protected: 46 | FLOAT2 m_pos0, m_pos1; 47 | float m_width; 48 | bool m_isLineDirty; 49 | ID3D11Buffer *m_lineVB; 50 | }; 51 | 52 | } 53 | 54 | 55 | #endif -------------------------------------------------------------------------------- /Emerald/EEMagicButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_MAGICBUTTON_H_ 3 | #define _EE_MAGICBUTTON_H_ 4 | 5 | #include "EEQuad2D.h" 6 | 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEButton 12 | //---------------------------------------------------------------------------------------------------- 13 | class EEMagicButton : public EEQuad2D 14 | { 15 | public: 16 | EEMagicButton(const Rect_Float& _rect, float _scale, float _scaleTime, float _fadeTime, const EETexture& _tex, std::function _funcPtr = [] {}); 17 | EEMagicButton(const EEMagicButton& _button); 18 | virtual ~EEMagicButton(); 19 | 20 | virtual bool Update(); 21 | virtual bool Render(); 22 | 23 | virtual Rect_Float GetFinalRect() const; 24 | 25 | // OnFunction 26 | virtual void OnMouseFree(const Point& _pos); 27 | virtual void OnMouseOver(const Point& _pos); 28 | virtual void OnMouseClicked(const Point& _pos); 29 | virtual void OnMouseTriggered(const Point& _pos); 30 | virtual void OnTriggered(); 31 | 32 | protected: 33 | // Scale 34 | float m_aimScale; 35 | float m_currScaleTime; 36 | float m_aimScaleTime; 37 | // Alpha 38 | float m_aimAlpha; 39 | float m_currFadeTime; 40 | float m_aimFadeTime; 41 | // Callback function 42 | std::function m_callbackFunc; 43 | }; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EESocket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SOCKET_H_ 3 | #define _EE_SOCKET_H_ 4 | 5 | #define _WINSOCK_DEPRECATED_NO_WARNINGS 6 | #pragma comment(lib, "ws2_32.lib") 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | //---------------------------------------------------------------------------------------------------- 13 | namespace Emerald 14 | { 15 | // EESocket 16 | //---------------------------------------------------------------------------------------------------- 17 | class EESocket 18 | { 19 | protected: 20 | static bool InitializeSocket(); 21 | 22 | protected: 23 | static bool s_isSocketInitialized; 24 | 25 | public: 26 | EESocket(char* _addr, char* _port); 27 | EESocket(char* _addr, u_short _port); 28 | EESocket(SOCKET _socket, const sockaddr_storage& _addr); 29 | EESocket(SOCKET _socket, const sockaddr_in& _addr); 30 | EESocket(const EESocket& _socket); 31 | virtual ~EESocket(); 32 | 33 | SOCKET Socket(); 34 | std::string IP(); 35 | u_short Port(); 36 | 37 | protected: 38 | SOCKET m_socket; 39 | sockaddr_storage m_addr; 40 | int m_addrLen; 41 | }; 42 | 43 | // EESocket_APIs 44 | //---------------------------------------------------------------------------------------------------- 45 | std::string EEGetIP(sockaddr_storage& _addr); 46 | u_short EEGetPort(sockaddr_storage& _addr); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /Emerald/EEContrastAndBright.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_CONTRASTANDBRIGHT_H_ 3 | #define _EE_CONTRASTANDBRIGHT_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEContrastAndBrightBufferDesc 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EEContrastAndBrightBufferDesc 14 | { 15 | float contrast; 16 | float bright; 17 | float tmp2; 18 | float tmp3; 19 | }; 20 | 21 | // EEContrastAndBrightC 22 | //---------------------------------------------------------------------------------------------------- 23 | class EEContrastAndBrightC : public EEEffect 24 | { 25 | protected: 26 | static bool InitializeContrastAndBrightC(); 27 | 28 | protected: 29 | static bool s_isContrastAndBrightCInitialized; 30 | static ID3D11Buffer *s_contrastAndBrightBuffer; 31 | static ID3D11ComputeShader *s_contrastAndBrightCS; 32 | 33 | public: 34 | EEContrastAndBrightC(EETexture& _target); 35 | 36 | virtual bool Update(); 37 | virtual bool Render(); 38 | 39 | void SetContrast(float _contrast); 40 | void SetBright(float _bright); 41 | 42 | protected: 43 | EETexture m_backup; 44 | EETexture m_target; 45 | float m_contrast; 46 | float m_bright; 47 | }; 48 | } 49 | 50 | 51 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EECannyShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_ERODESHADER_HLSL_ 2 | #define _EE_ERODESHADER_HLSL_ 3 | 4 | #define GROUPDIM_X 32 5 | #define GROUPDIM_Y 32 6 | #define GROUPDIM_Z 1 7 | 8 | // Canny 9 | //---------------------------------------------------------------------------------------------------- 10 | cbuffer CannyBuffer : register(b3) 11 | { 12 | int2 cb_kernel : packoffset(c0.x); 13 | float cb_tmp32 : packoffset(c0.z); 14 | float cb_tmp33 : packoffset(c0.w); 15 | }; 16 | 17 | Texture2D g_input : register(cs, t0); 18 | Texture2D g_input_gray : register(cs, t1); 19 | RWTexture2D g_output : register(cs, u0); 20 | 21 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 22 | void CannyCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 23 | { 24 | float4 values = { 25 | g_input_gray[uint2(_threadID.x, _threadID.y)], 26 | g_input_gray[uint2(_threadID.x + 1, _threadID.y)], 27 | g_input_gray[uint2(_threadID.x, _threadID.y + 1)], 28 | g_input_gray[uint2(_threadID.x + 1, _threadID.y + 1)], 29 | }; 30 | float p = (values[1] + values[3] - values[0] - values[2]) / 2; 31 | float q = (values[0] + values[1] - values[2] - values[3]) / 2; 32 | float m = sqrt(pow(p, 2) + pow(q, 2)); 33 | 34 | if (m > 0.5f) 35 | g_output[_threadID.xy] = 1.f; 36 | else 37 | g_output[_threadID.xy] = 0.f; 38 | } 39 | 40 | #endif -------------------------------------------------------------------------------- /Emerald/EERecorder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_RECORDER_H_ 3 | #define _EE_RECORDER_H_ 4 | 5 | #pragma comment(lib,"Winmm") 6 | #define WIN32_LEAN_AND_MEAN 7 | #include 8 | #include 9 | #include "EEMusic.h" 10 | 11 | #define EE_RECORDER_SAMPLE_POOR 8000 12 | #define EE_RECORDER_SAMPLE_LOW 11025 13 | #define EE_RECORDER_SAMPLE_NORMAL 22050 14 | #define EE_RECORDER_SAMPLE_HIGH 44100 15 | #define EE_RECORDER_BIT 16 16 | #define EE_RECORDER_CHANNELS 2 17 | 18 | #define EE_RECORDER_FRAME_NUM 10 19 | #define EE_RECORDER_FRAME_SIZE 960 20 | 21 | //---------------------------------------------------------------------------------------------------- 22 | namespace Emerald 23 | { 24 | //EERecorder 25 | //---------------------------------------------------------------------------------------------------- 26 | class EERecorder : public EEMusic 27 | { 28 | protected: 29 | static void CALLBACK RecorderInProc(HWAVEIN _waveIn, UINT _msg, DWORD_PTR _instance, DWORD_PTR _param1, DWORD_PTR _param2); 30 | static EERecorder* FindRecorder(HWAVEIN _waveIn); 31 | 32 | protected: 33 | static std::vector s_recorders; 34 | 35 | public: 36 | EERecorder(); 37 | EERecorder(DWORD_PTR _callBack); 38 | virtual ~EERecorder(); 39 | 40 | void Start(); 41 | 42 | protected: 43 | HWAVEIN m_waveIn; 44 | WAVEINCAPS m_waveInCaps; 45 | WAVEHDR m_waveInHdr[EE_RECORDER_FRAME_NUM]; 46 | }; 47 | } 48 | 49 | 50 | #endif -------------------------------------------------------------------------------- /Emerald/DirectXTex/scoped.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------- 2 | // scoped.h 3 | // 4 | // Utility header with helper classes for exception-safe handling of resources 5 | // 6 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 7 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 8 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 9 | // PARTICULAR PURPOSE. 10 | // 11 | // Copyright (c) Microsoft Corporation. All rights reserved. 12 | //------------------------------------------------------------------------------------- 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | //--------------------------------------------------------------------------------- 21 | struct aligned_deleter { void operator()(void* p) { _aligned_free(p); } }; 22 | 23 | typedef std::unique_ptr ScopedAlignedArrayFloat; 24 | 25 | typedef std::unique_ptr ScopedAlignedArrayXMVECTOR; 26 | 27 | //--------------------------------------------------------------------------------- 28 | struct handle_closer { void operator()(HANDLE h) { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } }; 29 | 30 | typedef public std::unique_ptr ScopedHandle; 31 | 32 | inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; } 33 | -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAManager.cpp: -------------------------------------------------------------------------------- 1 | #include "DIVAManager.h" 2 | #include "DIVAMenu.h" 3 | #include "DIVAFreeMode.h" 4 | 5 | 6 | //---------------------------------------------------------------------------------------------------- 7 | DIVAManager::DIVAManager() 8 | : 9 | m_state(DIVA_FREE_MODE) 10 | { 11 | Initialize(); 12 | } 13 | 14 | //---------------------------------------------------------------------------------------------------- 15 | DIVAManager::~DIVAManager() 16 | { 17 | 18 | } 19 | 20 | //---------------------------------------------------------------------------------------------------- 21 | bool DIVAManager::Process() 22 | { 23 | EEDesc desc; 24 | desc.applicationName = L"Emerald"; 25 | desc.isFullScreen = false; 26 | desc.width = 800; 27 | desc.height = 450; 28 | desc.isSSAA = false; 29 | desc.isVsync = true; 30 | EEInitialize(desc); 31 | 32 | while (m_state != DIVA_END) 33 | { 34 | switch (m_state) 35 | { 36 | case DIVA_MENU: 37 | { 38 | DIVAMenu menu; 39 | m_state = menu.Process(); 40 | break; 41 | } 42 | case DIVA_FREE_MODE: 43 | { 44 | DIVAFreeMode freeMode; 45 | m_state = freeMode.Process(); 46 | break; 47 | } 48 | default: 49 | m_state = DIVA_END; 50 | break; 51 | } 52 | } 53 | 54 | EEShutdown(); 55 | return 0; 56 | } 57 | 58 | //---------------------------------------------------------------------------------------------------- 59 | bool DIVAManager::Initialize() 60 | { 61 | 62 | return true; 63 | } -------------------------------------------------------------------------------- /Emerald/EEPoints2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_POINTS2D_H_ 3 | #define _EE_POINTS2D_H_ 4 | 5 | #include 6 | #include "EEObject2D.h" 7 | #include "EETexture.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | //EEPoints2DVertex 13 | //---------------------------------------------------------------------------------------------------- 14 | struct EEPoints2DVertex 15 | { 16 | FLOAT3 pos; 17 | }; 18 | 19 | //EEPoints2D 20 | //---------------------------------------------------------------------------------------------------- 21 | class EEPoints2D : public EEObject2D 22 | { 23 | protected: 24 | static bool InitializePoints2D(); 25 | 26 | protected: 27 | static bool s_isPoints2DInitialized; 28 | static ID3D11InputLayout *s_pointsIL; 29 | static ID3D11VertexShader *s_pointsVS; 30 | static ID3D11PixelShader *s_pointsPS; 31 | static ID3D11Buffer *s_points2DBuffer; 32 | 33 | public: 34 | EEPoints2D(); 35 | EEPoints2D(std::vector& _points); 36 | 37 | virtual ~EEPoints2D(); 38 | 39 | virtual bool Update(); 40 | virtual bool Render(); 41 | 42 | void AddPoints(std::vector& _points); 43 | void AddPoints(std::vector& _points); 44 | 45 | protected: 46 | bool CreatePointsVertexBuffer(); 47 | 48 | protected: 49 | bool m_isPointsDirty; 50 | std::vector m_points; 51 | ID3D11Buffer *m_pointsVB; 52 | }; 53 | 54 | } 55 | 56 | 57 | #endif -------------------------------------------------------------------------------- /Emerald/EECollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_COLLISION_H_ 3 | #define _EE_COLLISION_H_ 4 | 5 | #include "EEMath.h" 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | struct EEFrustum 11 | { 12 | FLOAT3 Origin; // Origin of the frustum (and projection). 13 | FLOAT4 Orientation; // Unit quaternion representing rotation. 14 | 15 | FLOAT RightSlope; // Positive X slope (X/Z). 16 | FLOAT LeftSlope; // Negative X slope. 17 | FLOAT TopSlope; // Positive Y slope (Y/Z). 18 | FLOAT BottomSlope; // Negative Y slope. 19 | FLOAT Near, Far; // Z of the near plane and far plane. 20 | }; 21 | 22 | struct EEAxisAlignedBox 23 | { 24 | FLOAT3 center; // Center of the box. 25 | FLOAT3 extents; // Distance from the center to each side. 26 | }; 27 | 28 | //---------------------------------------------------------------------------------------------------- 29 | void EEComputeFrustumFromProjection(EEFrustum& _frustum, MATRIX& _matrix); 30 | 31 | //---------------------------------------------------------------------------------------------------- 32 | bool EECollision(int _x, int _y, int _z, int _w, const Point& _point); 33 | bool EECollision(const Rect_Int& _rect, const Point& _point); 34 | bool EECollision(const Rect_Float& _rect, const Point& _point); 35 | 36 | //---------------------------------------------------------------------------------------------------- 37 | 38 | } 39 | 40 | 41 | #endif -------------------------------------------------------------------------------- /Emerald/EEScrollView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SCROLLVIEW_H_ 3 | #define _EE_SCROLLVIEW_H_ 4 | 5 | #include "EEQuad2D.h" 6 | 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEScrollView 12 | //---------------------------------------------------------------------------------------------------- 13 | /* 14 | content origin 15 | +--------------------+ content 16 | | | 17 | | | 18 | | | 19 | ++--------------------+-+ view 20 | || | | 21 | || | | 22 | || | | (scroll bar) 23 | || | | 24 | || | | 25 | ++--------------------+-+ 26 | | (scroll bar) | 27 | | | 28 | +--------------------+ 29 | */ 30 | class EEScrollView : public EEQuad2D 31 | { 32 | public: 33 | EEScrollView(); 34 | EEScrollView(const Rect_Float& _area); 35 | EEScrollView(const EEScrollView& _scrollView); 36 | virtual ~EEScrollView(); 37 | 38 | virtual bool Update(); 39 | virtual bool Render(); 40 | 41 | public: 42 | bool VerticalPull(float _scrollPos); 43 | bool Repull(); 44 | 45 | bool SetContent(EEObject* _content); 46 | 47 | protected: 48 | EEObject m_contentOrigin; 49 | EEObject* m_content; 50 | float m_offsetHeight; 51 | float m_verticalScrollHeight; 52 | float m_verticalScrollCapacity; 53 | float m_verticalScrollPos; 54 | float m_verticalPos; 55 | float m_verticalPosDelta; 56 | }; 57 | } 58 | 59 | 60 | #endif -------------------------------------------------------------------------------- /Emerald/EEProgressBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_PROGRESSBAR_H_ 3 | #define _EE_PROGRESSBAR_H_ 4 | 5 | #include 6 | #include "EEGeometry.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEProgressBar 12 | //---------------------------------------------------------------------------------------------------- 13 | class EEProgressbar : public EEQuad2D 14 | { 15 | public: 16 | EEProgressbar(const Rect_Float& _progressRect, const EETexture& _progressTex, const EETexture& _frameTex, std::function _funcPtr = [](float){}); 17 | EEProgressbar(const Rect_Float& _progressRect, const Rect_Float& _frameRect, const EETexture& _progressTex, const EETexture& _frameTex, std::function _funcPtr = [](float){}); 18 | EEProgressbar(const EEProgressbar& _progressbar); 19 | virtual ~EEProgressbar(); 20 | 21 | virtual bool Update(); 22 | virtual bool Render(); 23 | 24 | // localZOrder 25 | virtual void SetLocalZOrder(float _localZOrder); 26 | bool SetProgress(float _progress); 27 | bool SetCallbackFunc(std::function); 28 | 29 | float GetProgress(); 30 | EETexture* GetProgressTex(); 31 | EETexture* GetFrameTex(); 32 | 33 | virtual void OnMouseTriggered(const Point& _pos); 34 | 35 | private: 36 | // the quad of the frame 37 | EEQuad2D m_progressFrame; 38 | // the degree of the progress 39 | float m_progress; 40 | bool m_isProgressDirty; 41 | // callback function 42 | std::function m_callbackFunc; 43 | }; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /Emerald/EECurve2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_CURVE2D_H_ 3 | #define _EE_CURVE2D_H_ 4 | 5 | #include "EEObject2D.h" 6 | #include "EETexture.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EECurve2DVertex 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EECurve2DVertex 14 | { 15 | FLOAT3 pos; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EECurve2D 20 | //---------------------------------------------------------------------------------------------------- 21 | class EECurve2D : public EEObject2D 22 | { 23 | protected: 24 | static bool InitializeCurve2D(); 25 | 26 | protected: 27 | static bool s_isCurve2DInitialized; 28 | static ID3D11InputLayout *s_curveIL; 29 | static ID3D11VertexShader *s_curveVS; 30 | static ID3D11PixelShader *s_curvePS; 31 | static ID3D11Buffer *s_curveBuffer; 32 | 33 | public: 34 | EECurve2D(); 35 | EECurve2D(const EETexture& _tex); 36 | EECurve2D(const std::vector& _curve, const EETexture& _tex); 37 | EECurve2D(const std::vector& _curve, const EEColor& _color); 38 | virtual ~EECurve2D(); 39 | 40 | virtual bool Update(); 41 | virtual bool Render(); 42 | 43 | void SetCurve(const std::vector& _curve); 44 | void SetWidth(float _width); 45 | 46 | protected: 47 | bool CreateCurveVertexBuffer(); 48 | 49 | protected: 50 | std::vector m_curve; 51 | float m_width; 52 | bool m_isCurveDirty; 53 | ID3D11Buffer *m_curveVB; 54 | }; 55 | 56 | } 57 | 58 | 59 | #endif -------------------------------------------------------------------------------- /Emerald/EEEffect.cpp: -------------------------------------------------------------------------------- 1 | #include "EEEffect.h" 2 | 3 | //---------------------------------------------------------------------------------------------------- 4 | namespace Emerald 5 | { 6 | //EEEffect 7 | //---------------------------------------------------------------------------------------------------- 8 | EEEffect::EEEffect() 9 | : 10 | m_isAlive(true) 11 | { 12 | 13 | } 14 | 15 | //---------------------------------------------------------------------------------------------------- 16 | EEEffect::EEEffect(EEEffect& _effect) 17 | { 18 | 19 | } 20 | 21 | //---------------------------------------------------------------------------------------------------- 22 | EEEffect::~EEEffect() 23 | { 24 | 25 | } 26 | 27 | //---------------------------------------------------------------------------------------------------- 28 | bool EEEffect::Update() 29 | { 30 | if (m_isAlive) 31 | { 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | 38 | //---------------------------------------------------------------------------------------------------- 39 | bool EEEffect::Render() 40 | { 41 | if (m_isAlive) 42 | { 43 | return true; 44 | } 45 | 46 | return false; 47 | } 48 | 49 | //---------------------------------------------------------------------------------------------------- 50 | bool EEEffect::Process() 51 | { 52 | if (Update()) 53 | return Render(); 54 | 55 | return false; 56 | } 57 | 58 | //EEEffect_APIs 59 | //---------------------------------------------------------------------------------------------------- 60 | bool EEProcess(EEEffect* _effect) 61 | { 62 | return _effect->Process(); 63 | } 64 | } -------------------------------------------------------------------------------- /Emerald/EESort.cpp: -------------------------------------------------------------------------------- 1 | #include "EESort.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | // EESort_APIs 8 | //---------------------------------------------------------------------------------------------------- 9 | void EEBubbleSort(std::vector& _objects, bool _isInverse) 10 | { 11 | if (_isInverse) 12 | for (unsigned int i = 0; i < _objects.size() - 1; ++i) 13 | for (unsigned int j = 0; j < _objects.size() - i - 1; ++j) 14 | { 15 | if (*_objects[j] < *_objects[j + 1]) 16 | { 17 | EEObject* tmp = _objects[j]; 18 | _objects[j] = _objects[j + 1]; 19 | _objects[j + 1] = tmp; 20 | } 21 | } 22 | else 23 | for (unsigned int i = 0; i < _objects.size() - 1; ++i) 24 | for (unsigned int j = 0; j < _objects.size() - i - 1; ++j) 25 | { 26 | if (_objects[j] > _objects[j + 1]) 27 | { 28 | EEObject* tmp = _objects[j]; 29 | _objects[j] = _objects[j + 1]; 30 | _objects[j + 1] = tmp; 31 | } 32 | } 33 | } 34 | 35 | //---------------------------------------------------------------------------------------------------- 36 | void EEInsertSort(std::vector& _objects, EEObject* _object, bool _isInverse) 37 | { 38 | auto it = _objects.begin(); 39 | if (_isInverse) 40 | for (; it != _objects.end(); ++it) 41 | { 42 | if (**it > *_object) 43 | continue; 44 | else 45 | break; 46 | } 47 | else 48 | for (; it != _objects.end(); ++it) 49 | { 50 | if (**it < *_object) 51 | continue; 52 | else 53 | break; 54 | } 55 | 56 | _objects.insert(it, _object); 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /Emerald/EEUDP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_UDP_H_ 3 | #define _EE_UDP_H_ 4 | 5 | #include "EESocket.h" 6 | #include 7 | 8 | #define EE_UDP_SIZE_MAX 1024 9 | #define EE_UDP_TIME 0 10 | 11 | //---------------------------------------------------------------------------------------------------- 12 | namespace Emerald 13 | { 14 | //EEUDP 15 | //---------------------------------------------------------------------------------------------------- 16 | class EEUDP : public EESocket 17 | { 18 | public: 19 | EEUDP(char* _addr, u_short _port); 20 | EEUDP(const EEUDP& _server); 21 | virtual ~EEUDP(); 22 | 23 | protected: 24 | }; 25 | 26 | //EEUDPServer 27 | //---------------------------------------------------------------------------------------------------- 28 | class EEUDPServer : public EEUDP 29 | { 30 | public: 31 | EEUDPServer(char* _addr, u_short _port); 32 | EEUDPServer(const EEUDPServer& _server); 33 | virtual ~EEUDPServer(); 34 | 35 | bool Send(sockaddr_storage* _addr, const std::string _data); 36 | bool Send(sockaddr_in* _addr, const std::string _data); 37 | bool Recv(sockaddr_storage* _addr, std::string& _data); 38 | 39 | protected: 40 | 41 | }; 42 | 43 | //EEUDPClient 44 | //---------------------------------------------------------------------------------------------------- 45 | class EEUDPClient : public EEUDP 46 | { 47 | public: 48 | EEUDPClient(char* _addr, u_short _port); 49 | EEUDPClient(const EEUDPClient& _client); 50 | virtual ~EEUDPClient(); 51 | 52 | bool Send(const std::string& _data); 53 | bool Recv(std::string& _data); 54 | 55 | protected: 56 | 57 | }; 58 | 59 | 60 | 61 | 62 | } 63 | 64 | 65 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEQuad2DShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_QUAD2DSHADER_HLSL_ 2 | #define _EE_QUAD2DSHADER_HLSL_ 3 | 4 | #include "EEObjectBuffer.hlsl" 5 | #include "EECameraBuffer.hlsl" 6 | 7 | Texture2DArray g_tex0 : register(ps, t0); 8 | 9 | SamplerState texSampler 10 | { 11 | Filter = ANISOTROPIC; 12 | }; 13 | 14 | struct QuadVIn 15 | { 16 | float3 pos: POSITION; 17 | float2 tex: TEXCOORD; 18 | }; 19 | 20 | struct QuadVOut 21 | { 22 | float4 pos: SV_POSITION; 23 | float2 tex: TEXCOORD; 24 | }; 25 | 26 | QuadVOut QuadVS(QuadVIn _vIn) 27 | { 28 | QuadVOut vOut; 29 | vOut.pos = mul(float4(_vIn.pos, 1.0f), cb_worldViewProjMatrix); 30 | vOut.tex = _vIn.tex; 31 | return vOut; 32 | } 33 | 34 | [earlydepthstencil] 35 | void QuadPS(QuadVOut _pIn, out float4 _finalColor :SV_TARGET) 36 | { 37 | if (cb_isUseColor && cb_isUseTex) 38 | _finalColor = g_tex0.Sample(texSampler, float3(_pIn.tex, cb_texIndex)) * cb_color; 39 | else if (cb_isUseColor) 40 | _finalColor = cb_color; 41 | else if (cb_isUseTex) 42 | _finalColor = g_tex0.Sample(texSampler, float3(_pIn.tex, cb_texIndex)); 43 | else 44 | _finalColor = cb_color; 45 | 46 | /* 47 | if (_pIn.pos.y < 320) 48 | { 49 | if (_finalColor.x + _finalColor.y + _finalColor.z > 1.7f) 50 | _finalColor = float4(1.0f, 1.0f, 1.0f, 1.0f); 51 | else 52 | _finalColor = float4(1.0f * _pIn.pos.x / 300, 1.0f * _pIn.pos.y / 500, 0.0f, 1.0f); 53 | } 54 | else if (_finalColor.x + _finalColor.y + _finalColor.z > 0.8f) 55 | _finalColor = float4(1.0f, 1.0f, 1.0f, 1.0f); 56 | else 57 | _finalColor = float4(1.0f * _pIn.pos.x / 300, 1.0f * _pIn.pos.y / 500, 0.0f, 1.0f); 58 | */ 59 | 60 | _finalColor.w = _finalColor.w * cb_alpha; 61 | } 62 | 63 | #endif -------------------------------------------------------------------------------- /Emerald/EETCP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_TCP_H_ 3 | #define _EE_TCP_H_ 4 | 5 | #include "EESocket.h" 6 | #include 7 | 8 | #define EE_TCP_SIZE_MAX 1024 9 | #define EE_TCP_TIME 0 10 | 11 | //---------------------------------------------------------------------------------------------------- 12 | namespace Emerald 13 | { 14 | //EETCP 15 | //---------------------------------------------------------------------------------------------------- 16 | class EETCP : public EESocket 17 | { 18 | public: 19 | EETCP(char* _addr , u_short _port); 20 | EETCP(const EETCP& _server); 21 | virtual ~EETCP(); 22 | 23 | protected: 24 | }; 25 | 26 | //EETCPServer 27 | //---------------------------------------------------------------------------------------------------- 28 | class EETCPServer : public EETCP 29 | { 30 | public: 31 | EETCPServer(char* _addr, u_short _port); 32 | EETCPServer(const EETCPServer& _server); 33 | virtual ~EETCPServer(); 34 | 35 | virtual bool Process(); 36 | SOCKET Accept(); 37 | bool Send(const std::string& _data); 38 | bool Send(SOCKET _socket, const std::string _data); 39 | SOCKET Recv(std::string& _data); 40 | SOCKET Recv(std::string& _data, unsigned int _size); 41 | bool Recv(SOCKET _socket, std::string& _data); 42 | 43 | protected: 44 | std::map m_clients; 45 | }; 46 | 47 | //EETCPClient 48 | //---------------------------------------------------------------------------------------------------- 49 | class EETCPClient : public EETCP 50 | { 51 | public: 52 | EETCPClient(char* _addr, u_short _port); 53 | EETCPClient(const EETCPClient& _client); 54 | virtual ~EETCPClient(); 55 | 56 | bool Send(const std::string& _data); 57 | bool Recv(std::string& _data); 58 | bool Recv(std::string& _data, unsigned int _size); 59 | 60 | protected: 61 | 62 | }; 63 | } 64 | 65 | 66 | #endif -------------------------------------------------------------------------------- /Emerald/EEAction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_ACTION_H_ 3 | #define _EE_ACTION_H_ 4 | 5 | #include "EEThread.h" 6 | #include "EEMath.h" 7 | #include "EEGUI.h" 8 | 9 | //memo:save the return value of actions to object 10 | //---------------------------------------------------------------------------------------------------- 11 | namespace Emerald 12 | { 13 | //EEAction_APIs 14 | //---------------------------------------------------------------------------------------------------- 15 | boost::thread* EEMoveBy(EEObject* _object, float _time, const FLOAT2& _dir, float _delay = 0.0f, bool _isInfinite = false); 16 | void EEMoveByProcess(EEObject* _object, float _time, const FLOAT2& _dir, float _delay, bool _isInfinite, float _startTime); 17 | 18 | boost::thread* EEScale(EEObject* _object, float _time, float _degree, float _delay = 0.0f); 19 | void EEScaleProcess(EEObject* _object, float _time, float _degree, float _delay, float _startTime); 20 | 21 | boost::thread* EERotateYX(EEObject* _object, float _time, float _radiansYX, float _delay = 0.0f, bool _isInfinite = false); 22 | void EERotateYXProcess(EEObject* _object, float _time, float _radiansYX, float _delay, bool _isInfinite, float _startTime); 23 | 24 | boost::thread* EERotate(EEObject* _object, float _time, float _radians, const FLOAT3& _center, float _delay = 0.0f, bool _isInfinite = false); 25 | void EERotateProcess(EEObject* _object, float _time, float _radians, const FLOAT3& _center, float _delay, bool _isInfinite, float _startTime); 26 | 27 | boost::thread* EERotateBy(EEObject* _object, float _time, float _radians, const FLOAT2& _center, float _delay = 0.0f, bool _isInfinite = false); 28 | void EERotateByProcess(EEObject* _object, float _time, float _radians, const FLOAT2& _center, float _delay, bool _isInfinite, float _startTime); 29 | 30 | boost::thread* EEFade(EEObject* _object, float _time, float _degree, float _delay = 0.0f); 31 | void EEFadeProcess(EEObject* _object, float _time, float _degree, float _delay, float _startTime); 32 | } 33 | 34 | 35 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEBoxShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_BOXSHADER_HLSL_ 2 | #define _EE_BOXSHADER_HLSL_ 3 | 4 | #include "EEObjectBuffer.hlsl" 5 | #include "EECameraBuffer.hlsl" 6 | #include "EELightShader.hlsl" 7 | 8 | Texture2D g_tex0 : register(ps, t0); 9 | 10 | SamplerState texSampler 11 | { 12 | Filter = ANISOTROPIC; 13 | }; 14 | 15 | struct BoxVIn 16 | { 17 | float3 pos: POSITION; 18 | float3 normal: NORMAL; 19 | float2 tex: TEXCOORD; 20 | }; 21 | 22 | struct BoxVOut 23 | { 24 | float4 pos: SV_POSITION; 25 | float3 normal: NORMAL; 26 | float2 tex: TEXCOORD; 27 | float3 posW: POSITION; 28 | }; 29 | 30 | BoxVOut BoxVS(BoxVIn _vIn) 31 | { 32 | BoxVOut vOut; 33 | vOut.pos = mul(float4(_vIn.pos, 1.f), cb_worldViewProjMatrix); 34 | vOut.normal = _vIn.normal; 35 | vOut.tex = _vIn.tex; 36 | vOut.posW = mul(float4(_vIn.pos, 1.f), cb_worldMatrix).xyz; 37 | return vOut; 38 | } 39 | 40 | [earlydepthstencil] 41 | void BoxPS(BoxVOut _pIn, out float4 _finalColor :SV_TARGET) 42 | { 43 | if (cb_isUseColor && cb_isUseTex) 44 | _finalColor = g_tex0.Sample(texSampler, _pIn.tex) * cb_color; 45 | else if (cb_isUseColor) 46 | _finalColor = cb_color; 47 | //_finalColor = _pIn.pos / 100; 48 | else if (cb_isUseTex) 49 | _finalColor = g_tex0.Sample(texSampler, _pIn.tex); 50 | else 51 | _finalColor = cb_color; 52 | 53 | _finalColor.w = _finalColor.w * cb_alpha; 54 | 55 | Material material; 56 | material.ambient = _finalColor; 57 | material.diffuse = _finalColor; 58 | material.specular = float4(_finalColor.xyz, 16.0f); 59 | DirLight directLight; 60 | directLight.ambient = float4(0.2f, 0.2f, 0.2f, 1.0f); 61 | directLight.diffuse = float4(0.5f, 0.5f, 0.5f, 1.0f); 62 | directLight.specular = float4(0.5f, 0.5f, 0.5f, 1.0f); 63 | directLight.dir = float3(0.67735f, -0.57735f, 0.57735f); 64 | float3 toEye = normalize(cb_eyePos - _pIn.posW); 65 | float4 A = float4(0.f, 0.f, 0.f, 0.f); 66 | float4 D = float4(0.f, 0.f, 0.f, 0.f); 67 | float4 S = float4(0.f, 0.f, 0.f, 0.f); 68 | ComputeDirLight(material, directLight, normalize(_pIn.normal), toEye, A, D, S); 69 | 70 | _finalColor = A + D + S; 71 | } 72 | 73 | #endif -------------------------------------------------------------------------------- /Emerald/Emerald.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_EMERALD_H_ 3 | #define _EE_EMERALD_H_ 4 | 5 | #include "EECore.h" 6 | #include "EEAlgorithm.h" 7 | #include "EEColor.h" 8 | #include "EESystem.h" 9 | #include "EEInput.h" 10 | #include "EETimer.h" 11 | #include "EED3D.h" 12 | #include "EEGeometry.h" 13 | #include "EEGUI.h" 14 | #include "EEAction.h" 15 | #include "EEMusic.h" 16 | #include "EEVideo.h" 17 | #include "EERecorder.h" 18 | #include "EEWaveCoder.h" 19 | #include "EEParticle.h" 20 | #include "EEFont.h" 21 | #include "EETCP.h" 22 | #include "EEUDP.h" 23 | #include "EEDNS.h" 24 | #include "EEAnimation.h" 25 | #include "EECharacterGenerator.h" 26 | 27 | #include "EEAverage.h" 28 | #include "EERipple.h" 29 | #include "EEBlur.h" 30 | #include "EEGray.h" 31 | #include "EEContrastAndBright.h" 32 | #include "EEErode.h" 33 | #include "EEDilate.h" 34 | #include "EECanny.h" 35 | 36 | #include "EEMemoryLeak.h" 37 | 38 | using namespace Emerald; 39 | 40 | /* 41 | //EECore_APIs 42 | //---------------------------------------------------------------------------------------------------- 43 | bool EEInitialize(); 44 | bool EEInitialize(const EEDesc& _EEDesc); 45 | void EEShutdown(); 46 | 47 | //EEInput_APIs 48 | //---------------------------------------------------------------------------------------------------- 49 | bool EEIsKeyDown(UINT _para); 50 | Point EEGetMousePosition(); 51 | int EEGetOnDeltaX(); 52 | int EEGetOnDeltaY(); 53 | void EEClearOnDeltaX(); 54 | void EEClearOnDeltaY(); 55 | void EEClearOnDeltaXY(); 56 | 57 | //EETimer_APIs 58 | //---------------------------------------------------------------------------------------------------- 59 | void EETimerStart(); 60 | void EETimerStop(); 61 | void EETimerReset(); 62 | void EETimerTick(); 63 | double EEGetTotalTime(); 64 | double EEGetDeltaTime(); 65 | void EEShowFPSInTitle(); 66 | void EEShowFPSInTitle(LPCWSTR _title); 67 | 68 | //EED3D_APIs 69 | //---------------------------------------------------------------------------------------------------- 70 | void EEBeginScene(float, float, float, float); 71 | void EEBeginScene(const FLOAT4&); 72 | void EEEndScene(); 73 | 74 | */ 75 | 76 | #endif -------------------------------------------------------------------------------- /Emerald/EEShaderState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SHADERSTATE_H_ 3 | #define _EE_SHADERSTATE_H_ 4 | 5 | #include 6 | 7 | //---------------------------------------------------------------------------------------------------- 8 | namespace Emerald 9 | { 10 | //EEShaderState 11 | //---------------------------------------------------------------------------------------------------- 12 | class EEShaderState 13 | { 14 | public: 15 | EEShaderState(); 16 | EEShaderState(const EEShaderState& _shaderState); 17 | inline virtual ~EEShaderState() { Shutdown(); } 18 | 19 | bool Initialize(); 20 | void Shutdown(); 21 | 22 | bool SetDepthStencilState(const D3D11_DEPTH_STENCIL_DESC& _desc); 23 | bool SetRasterizerState(const D3D11_RASTERIZER_DESC& _desc); 24 | bool SetSamplerState(const D3D11_SAMPLER_DESC& _desc); 25 | bool SetBlendState(const D3D11_BLEND_DESC& _desc); 26 | 27 | const D3D11_DEPTH_STENCIL_DESC& GetDepthStencilDesc() const; 28 | const D3D11_RASTERIZER_DESC& GetRasterizerDesc() const; 29 | const D3D11_SAMPLER_DESC& GetSamplerDesc() const; 30 | const D3D11_BLEND_DESC& GetBlendDesc() const; 31 | 32 | private: 33 | D3D11_DEPTH_STENCIL_DESC m_depthStencilDesc; 34 | ID3D11DepthStencilState *m_depthStencilState; 35 | D3D11_RASTERIZER_DESC m_rasterizerDesc; 36 | ID3D11RasterizerState *m_rasterizerState; 37 | D3D11_SAMPLER_DESC m_samplerDesc; 38 | ID3D11SamplerState *m_samplerState; 39 | float m_blendFactor[4]; 40 | D3D11_BLEND_DESC m_blendDesc; 41 | ID3D11BlendState *m_blendState; 42 | }; 43 | 44 | //EEShaderState_APIs 45 | //---------------------------------------------------------------------------------------------------- 46 | bool EESetDepthStencilState(const D3D11_DEPTH_STENCIL_DESC& _desc); 47 | bool EESetRasterizerState(const D3D11_RASTERIZER_DESC& _desc); 48 | bool EESetSamplerState(const D3D11_SAMPLER_DESC& _desc); 49 | bool EESetBlendState(const D3D11_BLEND_DESC& _desc); 50 | 51 | const D3D11_DEPTH_STENCIL_DESC& EEGetDepthStencilDesc(); 52 | const D3D11_RASTERIZER_DESC& EEGetRasterizerDesc(); 53 | const D3D11_SAMPLER_DESC& EEGetSamplerDesc(); 54 | const D3D11_BLEND_DESC& EEGetBlendDesc(); 55 | } 56 | 57 | 58 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EERippleShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_RIPPLESHADER_HLSL_ 2 | #define _EE_RIPPLESHADER_HLSL_ 3 | 4 | #include "EERippleHelper.hlsl" 5 | 6 | //Ripple 7 | //---------------------------------------------------------------------------------------------------- 8 | cbuffer RippleBuffer : register(b3) 9 | { 10 | float cb_refractiveIndex : packoffset(c0.x); 11 | float cb_tmp31 : packoffset(c0.y); 12 | float cb_tmp32 : packoffset(c0.z); 13 | float cb_tmp33 : packoffset(c0.w); 14 | }; 15 | 16 | Texture2D g_weight : register(cs, t0); 17 | Texture2D g_input : register(cs, t1); 18 | RWTexture2D g_output : register(cs, u0); 19 | 20 | [numthreads(GROUPDIM_X, GROUPDIM_Y, GROUPDIM_Z)] 21 | void RippleCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 22 | { 23 | int weight = g_weight[uint2(_threadID.x, _threadID.y)]; 24 | 25 | if (weight) 26 | { 27 | // use self-weight 28 | float halfWidth = g_weight.Length.x / 2.f; 29 | float halfHeight = g_weight.Length.y / 2.f; 30 | 31 | float factor = 1.0f - weight / cb_refractiveIndex; 32 | int a = ((_threadID.x - halfWidth) * factor) + halfWidth; 33 | int b = ((_threadID.y - halfHeight) * factor) + halfHeight; 34 | 35 | g_output[uint2(_threadID.x, _threadID.y)] = g_input[uint2(a, b)]; 36 | 37 | // use weight diff 38 | //int a = g_weight[uint2(_threadID.x + 1, _threadID.y)] - g_weight[uint2(_threadID.x - 1, _threadID.y)] >> 2; 39 | //int b = g_weight[uint2(_threadID.x, _threadID.y + 1)] - g_weight[uint2(_threadID.x, _threadID.y - 1)] >> 2; 40 | //g_output[uint2(_threadID.x, _threadID.y)] = g_input[uint2(_threadID.x + a, _threadID.y + b)]; 41 | 42 | 43 | 44 | /* 45 | if (a >= width) 46 | a = width - 1; 47 | else if (a < 0) 48 | a = 0; 49 | 50 | if (b >= height) 51 | b = height - 1; 52 | else if (b < 0) 53 | b = 0; 54 | */ 55 | //Set the value that is out of bound to the average color value 56 | 57 | // Deal with refraction 58 | //g_output[uint2(_threadID.x, _threadID.y)] = g_input[uint2(a, b)]; 59 | //g_output[uint2(_threadID.x, _threadID.y)] = float4(0.5f, 0.5f, 0.5f, 0.5f); 60 | } 61 | } 62 | 63 | #endif -------------------------------------------------------------------------------- /Emerald/EEScene.cpp: -------------------------------------------------------------------------------- 1 | #include "EEScene.h" 2 | #include "EECore.h" 3 | #include "EESort.h" 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | //EEScene 9 | //---------------------------------------------------------------------------------------------------- 10 | EEScene::EEScene() 11 | : 12 | EEObject() 13 | { 14 | 15 | } 16 | 17 | //---------------------------------------------------------------------------------------------------- 18 | EEScene::EEScene(const EEScene &_scene) 19 | : 20 | EEObject(_scene), 21 | m_objects(m_objects) 22 | { 23 | 24 | } 25 | 26 | //---------------------------------------------------------------------------------------------------- 27 | EEScene::~EEScene() 28 | { 29 | 30 | } 31 | 32 | //---------------------------------------------------------------------------------------------------- 33 | bool EEScene::Update() 34 | { 35 | if (!EEObject::Update()) 36 | return false; 37 | 38 | for (UINT i = 0; i < m_objects.size(); ++i) 39 | { 40 | m_objects[i]->Update(); 41 | } 42 | 43 | return true; 44 | } 45 | 46 | //---------------------------------------------------------------------------------------------------- 47 | bool EEScene::Render() 48 | { 49 | if (!EEObject::Render()) 50 | return false; 51 | 52 | for (UINT i = 0; i < m_objects.size(); ++i) 53 | { 54 | m_objects[i]->Render(); 55 | } 56 | 57 | return true; 58 | } 59 | 60 | //---------------------------------------------------------------------------------------------------- 61 | void EEScene::AddObject(EEObject* _object) 62 | { 63 | _object->SetParent(this); 64 | //if (m_objects.size() == m_objects.capacity()) 65 | // m_objects.reserve(m_objects.size() + 1); 66 | //m_objects.push_back(_object); 67 | EEInsertSort(m_objects, _object, true); 68 | } 69 | 70 | //---------------------------------------------------------------------------------------------------- 71 | void EEScene::RemoveObject(EEObject* _object) 72 | { 73 | for (auto it = m_objects.begin(); it != m_objects.end(); ++it) 74 | { 75 | if (*it = _object) 76 | { 77 | m_objects.erase(it); 78 | break; 79 | } 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /Emerald/EETextEditor.cpp: -------------------------------------------------------------------------------- 1 | #include "EETextEditor.h" 2 | #include "EECore.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | //EETextEditor 9 | //---------------------------------------------------------------------------------------------------- 10 | EETextEditor::EETextEditor(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor) 11 | : 12 | EEQuad2D(_rect, _color), 13 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 14 | { 15 | m_font.SetParent(this); 16 | SetIsFocusable(true); 17 | } 18 | 19 | //---------------------------------------------------------------------------------------------------- 20 | EETextEditor::EETextEditor(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor) 21 | : 22 | EEQuad2D(_rect, _tex), 23 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 24 | { 25 | m_font.SetParent(this); 26 | SetIsFocusable(true); 27 | } 28 | 29 | //---------------------------------------------------------------------------------------------------- 30 | EETextEditor::EETextEditor(const EETextEditor& _lineEditor) 31 | : 32 | EEQuad2D(_lineEditor), 33 | m_font(_lineEditor.m_font) 34 | { 35 | 36 | } 37 | 38 | //---------------------------------------------------------------------------------------------------- 39 | EETextEditor::~EETextEditor() 40 | { 41 | 42 | } 43 | 44 | //---------------------------------------------------------------------------------------------------- 45 | bool EETextEditor::Update() 46 | { 47 | if (!EEQuad2D::Update()) 48 | return false; 49 | 50 | if (s_focusedObject == this) 51 | { 52 | //the key queue need to be clear here 53 | } 54 | if (s_triggeredObject == this) 55 | { 56 | if (EECore::s_EECore->IsKeyInput()) 57 | { 58 | m_font.AddText((wchar_t)EECore::s_EECore->GetKey()); 59 | } 60 | } 61 | m_font.Update(); 62 | 63 | return true; 64 | } 65 | 66 | //---------------------------------------------------------------------------------------------------- 67 | bool EETextEditor::Render() 68 | { 69 | if (!EEQuad2D::Render()) 70 | return false; 71 | 72 | m_font.Render(); 73 | 74 | return true; 75 | } 76 | } -------------------------------------------------------------------------------- /Emerald/EESystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SYSTEM_H_ 3 | #define _EE_SYSTEM_H_ 4 | 5 | #define WIN32_LEAN_AND_MEAN 6 | #include 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | //EESystem 13 | //---------------------------------------------------------------------------------------------------- 14 | class EESystem 15 | { 16 | public: 17 | inline EESystem() 18 | { 19 | } 20 | 21 | inline EESystem(const EESystem&) 22 | { 23 | } 24 | 25 | inline virtual ~EESystem() 26 | { 27 | Shutdown(); 28 | } 29 | 30 | bool Initialize(LPCWSTR _applicationName, bool _isFullScreen, int _width, int _height); 31 | void Shutdown(); 32 | 33 | bool SetHInstance(HINSTANCE _para); 34 | bool SetHWnd(HWND _para); 35 | bool SetApplicationName(LPCWSTR _para); 36 | bool SetIsFullScreen(bool _para); 37 | bool SetWidth(int _para); 38 | bool SetHeight(int _para); 39 | bool SetRect(const RECT& _para); 40 | bool SetInsideCentre(const INT2& _para); 41 | bool SetOutsideCentre(const INT2& _para); 42 | 43 | HINSTANCE GetHInstance() const; 44 | HWND GetHWnd() const; 45 | LPCWSTR GetApplicationName() const; 46 | bool GetIsFullScreen() const; 47 | int GetWidth() const; 48 | int GetHeight() const; 49 | RECT GetRect() const; 50 | INT2 GetInsideCentre() const; 51 | INT2 GetOutsideCentre() const; 52 | 53 | private: 54 | void InitWindows(); 55 | void ShutdownWindows(); 56 | 57 | static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 58 | 59 | private: 60 | HINSTANCE m_hInstance; 61 | HWND m_hWnd; 62 | LPCWSTR m_applicationName; 63 | bool m_isFullScreen; 64 | int m_width; 65 | int m_height; 66 | RECT m_rect; 67 | INT2 m_insideCentre; 68 | INT2 m_outsideCentre; 69 | }; 70 | 71 | //EESystem_APIs 72 | //---------------------------------------------------------------------------------------------------- 73 | HINSTANCE EEGetHInstance(); 74 | HWND EEGetHWnd(); 75 | LPCWSTR EEGetApplicationName(); 76 | bool EEGetIsFullScreen(); 77 | int EEGetWidth(); 78 | int EEGetHeight(); 79 | RECT EEGetRect(); 80 | INT2 EEGetInsideCentre(); 81 | INT2 EEGetOutsideCentre(); 82 | } 83 | 84 | #endif -------------------------------------------------------------------------------- /Emerald/EEVideo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_VIDEO_H_ 3 | #define _EE_VIDEO_H_ 4 | 5 | #pragma warning(disable: 4996) 6 | extern "C" 7 | { 8 | #pragma comment (lib, "avcodec.lib") 9 | #pragma comment (lib, "avdevice.lib") 10 | #pragma comment (lib, "avfilter.lib") 11 | #pragma comment (lib, "avformat.lib") 12 | #pragma comment (lib, "avutil.lib") 13 | #pragma comment (lib, "swresample.lib") 14 | #pragma comment (lib, "swscale.lib") 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | } 25 | #include 26 | #include 27 | #include "EEQuad2D.h" 28 | #include "EEMusic.h" 29 | 30 | 31 | namespace Emerald 32 | { 33 | // EEVideoData 34 | //---------------------------------------------------------------------------------------------------- 35 | struct EEVideoData 36 | { 37 | 38 | 39 | }; 40 | 41 | // EEVideo 42 | //---------------------------------------------------------------------------------------------------- 43 | class EEVideo 44 | { 45 | public: 46 | static bool InitializeVideo(); 47 | 48 | protected: 49 | static bool s_isVideoInitialized; 50 | 51 | public: 52 | EEVideo(); 53 | EEVideo(const Rect_Float& _rect); 54 | ~EEVideo(); 55 | 56 | virtual bool Update(); 57 | virtual bool Render(); 58 | virtual bool Process(); 59 | bool Open(const char* _fileName); 60 | bool Play(); 61 | 62 | int GetPacketSize(); 63 | 64 | protected: 65 | bool LoadVideo(const char* _fileName); 66 | bool DecodePacket(int _num); 67 | 68 | protected: 69 | // info 70 | AVFormatContext *m_formatContext; 71 | int m_streamIndex; 72 | AVCodecContext *m_codecContext; 73 | SwsContext *m_swsContext; 74 | AVFrame *m_frameRGBA; 75 | int m_width; 76 | int m_height; 77 | double m_frameRate; 78 | double m_totalTime; 79 | double m_timeBase; 80 | 81 | bool m_isRunning; 82 | double m_startTime; 83 | int m_currentPacket; 84 | 85 | // data 86 | EEQuad2D m_screen; 87 | std::vector m_packets; 88 | std::queue> m_frames; 89 | EEMusic m_music; 90 | }; 91 | } 92 | 93 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "DIVAConfig.h" 6 | using namespace std; 7 | 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | enum class NoteType { NOTE_NORMAL = 0, NOTE_STRIP = 1 }; 11 | enum class NoteKey { NOTE_CIRCLE = 0, NOTE_RECT = 1, NOTE_CROSS = 2, NOTE_TRIANGLE = 3, NOTE_RIGHT = 4, NOTE_LEFT = 5, NOTE_DOWN = 6, NOTE_UP = 7 }; 12 | 13 | //---------------------------------------------------------------------------------------------------- 14 | class DIVAMap 15 | { 16 | //---------------------------------------------------------------------------------------------------- 17 | class Note 18 | { 19 | public: 20 | inline Note() : framePos(0), sound(0), x(0), y(0), tailX(0), tailY(0), keyType(), key() {} 21 | 22 | public: 23 | int framePos; 24 | int sound; 25 | NoteType keyType; 26 | NoteKey key; 27 | int x, y; 28 | float tailX, tailY; 29 | float duration; 30 | }; 31 | 32 | //---------------------------------------------------------------------------------------------------- 33 | class Frame 34 | { 35 | public: 36 | Frame() : isAlive(true), timePos(0), beatsPerMinute(0), resource(-1) {} 37 | 38 | inline double GetSingleTime() { return 60.0 / (beatsPerMinute * (DIVAConfig::GetFramesPerBeat() / DIVAConfig::GetPeriodsPerBeat())); } 39 | 40 | public: 41 | bool isAlive; 42 | double timePos; 43 | double beatsPerMinute; 44 | vector music; 45 | int resource; 46 | vector notes; 47 | }; 48 | 49 | //---------------------------------------------------------------------------------------------------- 50 | public: 51 | DIVAMap(); 52 | DIVAMap(const char* _filePath, const char* _basePath); 53 | virtual ~DIVAMap(); 54 | 55 | bool LoadMap(const char* _filePath, const char* _basePath); 56 | 57 | private: 58 | // map info 59 | string m_toolVersion; 60 | string m_mapName; 61 | string m_noterName; 62 | string m_authorName; 63 | 64 | int m_level; 65 | int m_difficulty; 66 | float m_beatsPerMinute; 67 | int m_frameNum; 68 | 69 | vector m_frames; 70 | map m_music; 71 | map m_resources; 72 | 73 | int m_chanceTimeStart; 74 | int m_chanceTimeEnd; 75 | 76 | // runtime data 77 | int m_framePos; 78 | int m_frameForwardPos; 79 | }; -------------------------------------------------------------------------------- /Emerald/EEColor.cpp: -------------------------------------------------------------------------------- 1 | #include "EEColor.h" 2 | 3 | namespace Emerald 4 | { 5 | //EEColor 6 | //---------------------------------------------------------------------------------------------------- 7 | const EEColor EEColor::BLACK(0.0f, 0.0f, 0.0f, 1.0f); 8 | const EEColor EEColor::WHITE(1.0f, 1.0f, 1.0f, 1.0f); 9 | const EEColor EEColor::RED(1.0f, 0.0f, 0.0f, 1.0f); 10 | const EEColor EEColor::GREEN(0.0f, 1.0f, 0.0f, 1.0f); 11 | const EEColor EEColor::BLUE(0.0f, 0.0f, 1.0f, 1.0f); 12 | const EEColor EEColor::YELLOW(1.0f, 1.0f, 0.0f, 1.0f); 13 | const EEColor EEColor::CYAN(0.0f, 1.0f, 1.0f, 1.0f); 14 | const EEColor EEColor::MAGENTA(1.0f, 0.0f, 1.0f, 1.0f); 15 | const EEColor EEColor::SILVER(0.75f, 0.75f, 0.75f, 1.0f); 16 | const EEColor EEColor::COLORS[9] = { EEColor::BLACK, EEColor::WHITE, EEColor::RED, EEColor::GREEN, EEColor::BLUE, EEColor::YELLOW, EEColor::CYAN, EEColor::MAGENTA, EEColor::SILVER }; 17 | const EEColor EEColor::LUCENCY(0.0f, 0.0f, 0.0f, 0.0f); 18 | 19 | //---------------------------------------------------------------------------------------------------- 20 | EEColor::EEColor() 21 | : 22 | FLOAT4() 23 | { 24 | 25 | } 26 | 27 | //---------------------------------------------------------------------------------------------------- 28 | EEColor::EEColor(FLOAT _red, FLOAT _green, FLOAT _yellow, FLOAT _alpha) 29 | : 30 | FLOAT4(_red, _green, _yellow, _alpha) 31 | { 32 | 33 | } 34 | 35 | //---------------------------------------------------------------------------------------------------- 36 | EEColor::EEColor(const FLOAT4& _color) 37 | : 38 | FLOAT4(_color) 39 | { 40 | 41 | } 42 | 43 | //---------------------------------------------------------------------------------------------------- 44 | EEColor::EEColor(const EEColor& _color) 45 | : 46 | FLOAT4(_color) 47 | { 48 | 49 | } 50 | 51 | //---------------------------------------------------------------------------------------------------- 52 | EEColor::~EEColor() 53 | { 54 | 55 | } 56 | 57 | //---------------------------------------------------------------------------------------------------- 58 | bool EEColor::SetColor(const FLOAT4& _color) 59 | { 60 | *this = _color; 61 | 62 | return true; 63 | } 64 | 65 | //---------------------------------------------------------------------------------------------------- 66 | const FLOAT4& EEColor::GetColor() 67 | { 68 | return *this; 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "DIVAConfig.h" 2 | #include "../../Emerald.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | bool DIVAConfig::s_isInitialized = false; 7 | 8 | std::map DIVAConfig::s_keyMap; 9 | int DIVAConfig::s_framesPerBeat = 192; 10 | int DIVAConfig::s_periodsPerBeat = 4; 11 | int DIVAConfig::s_noteNum = 8; 12 | int DIVAConfig::s_musicMaxPerFrame = 10; 13 | int DIVAConfig::s_noteWidth = 0; 14 | int DIVAConfig::s_noteHeight = 0; 15 | 16 | //---------------------------------------------------------------------------------------------------- 17 | bool DIVAConfig::Initialize() 18 | { 19 | if (!s_isInitialized) 20 | { 21 | s_noteWidth = EEGetWidth() / 40; 22 | s_noteHeight = EEGetHeight() / 22; 23 | 24 | s_keyMap[0] = 'D'; 25 | s_keyMap[1] = 'A'; 26 | s_keyMap[2] = 'S'; 27 | s_keyMap[3] = 'W'; 28 | 29 | s_keyMap[4] = (char)39; 30 | s_keyMap[5] = (char)37; 31 | s_keyMap[6] = (char)40; 32 | s_keyMap[7] = (char)38; 33 | 34 | s_keyMap[8] = 'D'; 35 | s_keyMap[9] = 'A'; 36 | s_keyMap[10] = 'S'; 37 | s_keyMap[11] = 'W'; 38 | 39 | s_keyMap[12] = (char)39; 40 | s_keyMap[13] = (char)37; 41 | s_keyMap[14] = (char)40; 42 | s_keyMap[15] = (char)38; 43 | 44 | s_isInitialized = true; 45 | } 46 | 47 | return true; 48 | } 49 | 50 | //---------------------------------------------------------------------------------------------------- 51 | char DIVAConfig::GetKeyMap(unsigned int _key) 52 | { 53 | Initialize(); 54 | 55 | auto it = s_keyMap.find(_key); 56 | if (it != s_keyMap.end()) 57 | return it->second; 58 | else 59 | return (char)0; 60 | } 61 | 62 | int DIVAConfig::GetFramesPerBeat() 63 | { 64 | Initialize(); 65 | 66 | return s_framesPerBeat; 67 | } 68 | 69 | int DIVAConfig::GetPeriodsPerBeat() 70 | { 71 | Initialize(); 72 | 73 | return s_periodsPerBeat; 74 | } 75 | 76 | int DIVAConfig::GetNoteNum() 77 | { 78 | Initialize(); 79 | 80 | return s_noteNum; 81 | } 82 | 83 | int DIVAConfig::GetMusicMaxPerFrame() 84 | { 85 | Initialize(); 86 | 87 | return s_musicMaxPerFrame; 88 | } 89 | 90 | int DIVAConfig::GetNoteWidth() 91 | { 92 | Initialize(); 93 | 94 | return s_noteWidth; 95 | } 96 | 97 | int DIVAConfig::GetNoteHeight() 98 | { 99 | Initialize(); 100 | 101 | return s_noteHeight; 102 | } -------------------------------------------------------------------------------- /Emerald/EEBitmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_BITMAP_H_ 3 | #define _EE_BITMAP_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | //EEBitmap 13 | //---------------------------------------------------------------------------------------------------- 14 | class EEBitmap 15 | { 16 | public: 17 | EEBitmap(); 18 | EEBitmap(wchar_t* _file); 19 | EEBitmap(unsigned int _width, unsigned int _height); 20 | EEBitmap(unsigned int _width, unsigned int _height, const unsigned char* _buffer); 21 | EEBitmap(unsigned int _width, unsigned int _height, const unsigned char* _buffer, unsigned int _rowPitch); 22 | EEBitmap(const EEBitmap& _bitmap); 23 | EEBitmap(const EEBitmap&& _bitmap); 24 | virtual ~EEBitmap(); 25 | 26 | void Resize(unsigned int _width, unsigned int _height); 27 | 28 | unsigned char* GetData(); 29 | int GetDataSize(); 30 | int GetWidth() const; 31 | int GetHeight() const; 32 | bool IsEmpty() const; 33 | EEBitmap GetSubmap(int _x, int _y, int _width = -1, int _height = -1) const; 34 | 35 | bool SetData(const wchar_t* _file); 36 | bool SetData(unsigned int _width, unsigned int _height, const unsigned char* _buffer); 37 | bool SetData(unsigned int _width, unsigned int _height, const unsigned char* _buffer, unsigned int _rowPitch); 38 | bool SetData(unsigned int _x, unsigned int _y, unsigned int _width, unsigned int _height, EEBitmap& _src); 39 | 40 | protected: 41 | std::vector m_data; 42 | int m_width; 43 | int m_height; 44 | }; 45 | 46 | // EEBitmap_APIs 47 | // Rvalue reference 48 | //---------------------------------------------------------------------------------------------------- 49 | EEBitmap EEBitmapCombineHorizontal(EEBitmap& _top, EEBitmap& _bottom); 50 | EEBitmap EEBitmapCombineHorizontal(EEBitmap* _bitmaps, int _count); 51 | EEBitmap EEBitmapCombineHorizontal(std::vector& _bitmaps); 52 | EEBitmap EEBitmapCombineVertical(EEBitmap& _top, EEBitmap& _bottom); 53 | EEBitmap EEBitmapCombineVertical(std::vector& _bitmaps); 54 | void EEBitmapDivideHorizontal(EEBitmap& _bitmap, unsigned int _amount, std::vector& _bitmaps); 55 | void EEBitmapDivideVertical(EEBitmap& _bitmap, unsigned int _amount, std::vector& _bitmaps); 56 | void EEMerge(std::vector& _bitmaps, EEBitmap& _result); 57 | } 58 | 59 | #endif -------------------------------------------------------------------------------- /Emerald/EERipple.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_RIPPLE_H_ 3 | #define _EE_RIPPLE_H_ 4 | 5 | #include "EETexture.h" 6 | #include "EEEffect.h" 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | /* 13 | //EERipple 14 | //---------------------------------------------------------------------------------------------------- 15 | class EERipple : public EEEffect 16 | { 17 | public: 18 | 19 | 20 | protected: 21 | 22 | }; 23 | */ 24 | 25 | // EEDisturbBufferDesc 26 | //---------------------------------------------------------------------------------------------------- 27 | struct EEDisturbBufferDesc 28 | { 29 | INT2 pos; 30 | int range; 31 | int weight; 32 | }; 33 | 34 | // EESpreadBufferDesc 35 | //---------------------------------------------------------------------------------------------------- 36 | struct EESpreadBufferDesc 37 | { 38 | int spreadFactor; 39 | int fadeFactor; 40 | float tmp1; 41 | float tmp2; 42 | }; 43 | 44 | // EERippleBufferDesc 45 | //---------------------------------------------------------------------------------------------------- 46 | struct EERippleBufferDesc 47 | { 48 | float refractiveIndex; 49 | float tmp1; 50 | float tmp2; 51 | float tmp3; 52 | }; 53 | 54 | // EERippleC 55 | //---------------------------------------------------------------------------------------------------- 56 | class EERippleC : public EEEffect 57 | { 58 | protected: 59 | static bool InitializeRippleC(); 60 | 61 | protected: 62 | static bool s_isRippleCInitialized; 63 | static ID3D11Buffer *s_disturbBuffer; 64 | static ID3D11Buffer *s_spreadBuffer; 65 | static ID3D11Buffer *s_rippleBuffer; 66 | static ID3D11ComputeShader *s_disturbCS; 67 | static ID3D11ComputeShader *s_spreadCS; 68 | static ID3D11ComputeShader *s_rippleCS; 69 | 70 | public: 71 | EERippleC(); 72 | EERippleC(EETexture& _target); 73 | 74 | virtual bool Update(); 75 | virtual bool Render(); 76 | bool Disturb(int _x, int _y, int _range, int _weight); 77 | 78 | bool SetSpreadFactor(int _factor); 79 | bool SetFadeFactor(int _factor); 80 | bool SetRefractiveIndex(float _index); 81 | 82 | protected: 83 | EETexture m_target; 84 | EETexture m_backup; 85 | EETexture m_weightMap[2]; 86 | unsigned int m_currWeightMap; 87 | int m_spreadFactor; 88 | int m_fadeFactor; 89 | float m_refractiveIndex; 90 | float m_updateTime; 91 | float m_spreadInterval; //0.f is the best choice 92 | }; 93 | 94 | } 95 | 96 | 97 | #endif -------------------------------------------------------------------------------- /Emerald/EELineEditor.cpp: -------------------------------------------------------------------------------- 1 | #include "EELineEditor.h" 2 | #include "EECore.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | //EELineEditor 9 | //---------------------------------------------------------------------------------------------------- 10 | EELineEditor::EELineEditor(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor) 11 | : 12 | EEQuad2D(_rect, _color), 13 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 14 | { 15 | m_font.SetParent(this); 16 | SetIsFocusable(true); 17 | } 18 | 19 | //---------------------------------------------------------------------------------------------------- 20 | EELineEditor::EELineEditor(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor) 21 | : 22 | EEQuad2D(_rect, _tex), 23 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 24 | { 25 | m_font.SetParent(this); 26 | SetIsFocusable(true); 27 | } 28 | 29 | //---------------------------------------------------------------------------------------------------- 30 | EELineEditor::EELineEditor(const EELineEditor& _lineEditor) 31 | : 32 | EEQuad2D(_lineEditor), 33 | m_font(_lineEditor.m_font) 34 | { 35 | 36 | } 37 | 38 | //---------------------------------------------------------------------------------------------------- 39 | EELineEditor::~EELineEditor() 40 | { 41 | 42 | } 43 | 44 | //---------------------------------------------------------------------------------------------------- 45 | bool EELineEditor::Update() 46 | { 47 | if (!EEQuad2D::Update()) 48 | return false; 49 | 50 | if (s_focusedObject == this) 51 | { 52 | // the key queue need to be cleared here 53 | } 54 | if (s_triggeredObject == this) 55 | { 56 | while (EECore::s_EECore->IsKeyInput()) 57 | { 58 | //the letter on the LineEditor can not be '\r' 59 | wchar_t letter = (wchar_t)EECore::s_EECore->GetKey(); 60 | if (letter != L'\r' && letter != L'\n') 61 | { 62 | m_font.AddText(letter); 63 | } 64 | } 65 | } 66 | 67 | m_font.Update(); 68 | 69 | return true; 70 | } 71 | 72 | //---------------------------------------------------------------------------------------------------- 73 | bool EELineEditor::Render() 74 | { 75 | if (!EEQuad2D::Render()) 76 | return false; 77 | 78 | return m_font.Render(); 79 | } 80 | 81 | //---------------------------------------------------------------------------------------------------- 82 | const std::wstring& EELineEditor::GetText() 83 | { 84 | return m_font.GetText(); 85 | } 86 | } -------------------------------------------------------------------------------- /Emerald/EEGeneticAlgorithm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_GENETICALGORITHM_H_ 3 | #define _EE_GENETICALGORITHM_H_ 4 | 5 | // #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "EESmartPtr.h" 12 | #include "EERouletteWheel.h" 13 | 14 | 15 | //---------------------------------------------------------------------------------------------------- 16 | namespace Emerald 17 | { 18 | // EEChromosome 19 | //---------------------------------------------------------------------------------------------------- 20 | struct EEChromosome 21 | { 22 | std::vector genes; // bits 23 | float fitness; // 0.f - 1.f 24 | 25 | //---------------------------------------------------------------------------------------------------- 26 | inline EEChromosome(const std::vector& _genes) 27 | : 28 | genes(_genes), 29 | fitness(0.f) 30 | { 31 | } 32 | 33 | //---------------------------------------------------------------------------------------------------- 34 | inline EEChromosome(const EEChromosome& _chromosome) 35 | : 36 | genes(_chromosome.genes), 37 | fitness(_chromosome.fitness) 38 | { 39 | } 40 | 41 | //---------------------------------------------------------------------------------------------------- 42 | inline bool operator!= (const EEChromosome& _chromosome) 43 | { 44 | return genes != _chromosome.genes; 45 | } 46 | }; 47 | typedef EESmartPtr EEChromosomePtr; 48 | 49 | // EEGeneController 50 | //---------------------------------------------------------------------------------------------------- 51 | class EEGeneController 52 | { 53 | public: 54 | EEGeneController(const std::function)>& _fitnessFunc, int _maxPopulationSize = 2000,float _crossoverRate = 0.7,float _mutationRate = 0.1); 55 | virtual ~EEGeneController(); 56 | 57 | virtual bool Epoch(); 58 | virtual bool AddSample(const std::vector& _genes); 59 | virtual void AddTranslation(std::string _gene, boost::any _meaning); 60 | 61 | protected: 62 | bool CalculateFitness(EEChromosomePtr& _chromosome); 63 | void Crossover(); 64 | bool Mutate(EEChromosomePtr& _chromosome); 65 | 66 | protected: 67 | int m_maxPopulationSize; 68 | float m_crossoverRate; 69 | float m_mutationRate; 70 | std::map m_geneTranslation; 71 | std::function)> m_fitnessFunc; 72 | // Todo: crossover func, mutation func 73 | 74 | // runtime 75 | EERouletteWheel m_chromosomes; 76 | }; 77 | } 78 | 79 | #endif -------------------------------------------------------------------------------- /Emerald/EED3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_D3D_H_ 3 | #define _EE_D3D_H_ 4 | 5 | #include 6 | #include "EETexture.h" 7 | #include "EEMath.h" 8 | 9 | //---------------------------------------------------------------------------------------------------- 10 | namespace Emerald 11 | { 12 | //EED3D 13 | //---------------------------------------------------------------------------------------------------- 14 | class EED3D 15 | { 16 | public: 17 | EED3D(); 18 | EED3D(const EED3D&); 19 | inline virtual ~EED3D() { Shutdown(); } 20 | 21 | bool Initialize(bool _isSSAA, bool _isVsync); 22 | void Shutdown(); 23 | 24 | void BeginScene(float, float, float, float); 25 | void BeginScene(const FLOAT4&); 26 | void EndScene(); 27 | void ClearDepthStencilView(); 28 | 29 | bool SetDevice(ID3D11Device* _para); 30 | bool SetDeviceeContext(ID3D11DeviceContext* _para); 31 | bool SetScreenNear(float _para); 32 | bool SetScreenDeep(float _para); 33 | bool SetIsSSAA(bool _para); 34 | bool SetIsVsync(bool _para); 35 | bool SetRenderTarget(EETexture* _target = nullptr); 36 | 37 | ID3D11Device* GetDevice(); 38 | ID3D11DeviceContext* GetDeviceContext(); 39 | float GetScreenNear() const; 40 | float GetScreenDeep() const; 41 | bool GetIsSSAA() const; 42 | bool GetIsVsync() const; 43 | void GetVideoCardInfo(char*, int&); 44 | ID3D11RenderTargetView* GetRenderTargetView(); 45 | ID3D11DepthStencilView* GetDepthStencilView(); 46 | 47 | protected: 48 | ID3D11Device *m_device; 49 | ID3D11DeviceContext *m_deviceContext; 50 | float m_screenNear; 51 | float m_screenDeep; 52 | bool m_isSSAA; 53 | bool m_isVsync; 54 | int m_videoCardMemory; 55 | char m_videoCardDescription[128]; 56 | UINT m_x4MultiQuality; 57 | IDXGISwapChain *m_swapChain; 58 | ID3D11Texture2D *m_depthStencilBuffer; 59 | ID3D11RenderTargetView *m_renderTargetView; 60 | ID3D11DepthStencilView *m_depthStencilView; 61 | }; 62 | 63 | //EED3D_APIs 64 | //---------------------------------------------------------------------------------------------------- 65 | void EEBeginScene(float, float, float, float); 66 | void EEBeginScene(const FLOAT4&); 67 | void EEEndScene(); 68 | void EEClearDepthStencilView(); 69 | 70 | bool EESetRenderTarget(EETexture* _target = nullptr); 71 | 72 | ID3D11Device* EEGetDevice(); 73 | ID3D11DeviceContext* EEGetDeviceContext(); 74 | float EEGetScreenNear(); 75 | float EEGetScreenDeep(); 76 | bool EEGetIsSSAA(); 77 | bool EEGetIsVsync(); 78 | void EEGetVideoCardInfo(char*, int&); 79 | ID3D11RenderTargetView* EEGetRenderTargetView(); 80 | ID3D11DepthStencilView* EEGetDepthStencilView(); 81 | } 82 | 83 | #endif -------------------------------------------------------------------------------- /Emerald/EECollision.cpp: -------------------------------------------------------------------------------- 1 | #include "EECollision.h" 2 | 3 | //---------------------------------------------------------------------------------------------------- 4 | namespace Emerald 5 | { 6 | //---------------------------------------------------------------------------------------------------- 7 | void EEComputeFrustumFromProjection(EEFrustum& _frustum, MATRIX& _matrix) 8 | { 9 | 10 | } 11 | 12 | //---------------------------------------------------------------------------------------------------- 13 | bool EECollision(int _x, int _y, int _z, int _w, const POINT& _point) 14 | { 15 | return _point.x >= _x && _point.x <= _z && _point.y >= _y && _point.y <= _w; 16 | } 17 | 18 | //---------------------------------------------------------------------------------------------------- 19 | bool EECollision(const Rect_Int& _rect, const Point& _point) 20 | { 21 | return _point.x >= _rect.x && _point.x <= _rect.z && _point.y >= _rect.y && _point.y <= _rect.w; 22 | } 23 | 24 | //---------------------------------------------------------------------------------------------------- 25 | bool EECollision(const Rect_Float& _rect, const Point& _point) 26 | { 27 | return _point.x >= _rect.x && _point.x <= _rect.z && _point.y >= _rect.y && _point.y <= _rect.w; 28 | } 29 | 30 | //---------------------------------------------------------------------------------------------------- 31 | bool IntersectTriangle(const FLOAT3& orig, const FLOAT3& dir, 32 | FLOAT3& v0, FLOAT3& v1, FLOAT3& v2, 33 | FLOAT* t, FLOAT* u, FLOAT* v) 34 | { 35 | // Find vectors for two edges sharing vert0 36 | FLOAT3 edge1 = v1 - v0; 37 | FLOAT3 edge2 = v2 - v0; 38 | 39 | // Begin calculating determinant - also used to calculate U parameter 40 | FLOAT3 pvec = dir.CrossProduct(edge2); 41 | 42 | // If determinant is near zero, ray lies in plane of triangle 43 | FLOAT det = edge1.DotProduct(pvec); 44 | 45 | FLOAT3 tvec; 46 | if (det > 0) 47 | { 48 | tvec = orig - v0; 49 | } 50 | else 51 | { 52 | tvec = v0 - orig; 53 | det = -det; 54 | } 55 | 56 | if (det < 0.0001f) 57 | return false; 58 | 59 | // Calculate U parameter and test bounds 60 | *u = tvec.DotProduct(pvec); 61 | if (*u < 0.0f || *u > det) 62 | return false; 63 | 64 | // Prepare to test V parameter 65 | FLOAT3 qvec = tvec.CrossProduct(edge1);; 66 | 67 | // Calculate V parameter and test bounds 68 | *v = dir.DotProduct(qvec); 69 | if (*v < 0.0f || *u + *v > det) 70 | return false; 71 | 72 | // Calculate t, scale parameters, ray intersects triangle 73 | *t = edge2.DotProduct(qvec);; 74 | FLOAT fInvDet = 1.0f / det; 75 | *t *= fInvDet; 76 | *u *= fInvDet; 77 | *v *= fInvDet; 78 | 79 | return true; 80 | } 81 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Emerald/EEWaveCoder.cpp: -------------------------------------------------------------------------------- 1 | #include "EEWaveCoder.h" 2 | 3 | //contradict with ... 4 | #pragma comment(lib, "Lib/G729aR.lib") 5 | #include 6 | #include "Include/G729a.h" 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | //---------------------------------------------------------------------------------------------------- 12 | bool EEWaveCoder::s_isWaveCoderInitialized = false; 13 | 14 | //---------------------------------------------------------------------------------------------------- 15 | bool EEWaveCoder::InitializeWaveCoder() 16 | { 17 | if (!s_isWaveCoderInitialized) 18 | { 19 | va_g729a_init_encoder(); 20 | va_g729a_init_decoder(); 21 | 22 | s_isWaveCoderInitialized = true; 23 | } 24 | 25 | return true; 26 | } 27 | 28 | //---------------------------------------------------------------------------------------------------- 29 | EEWaveCoder::EEWaveCoder() 30 | { 31 | InitializeWaveCoder(); 32 | } 33 | 34 | //---------------------------------------------------------------------------------------------------- 35 | EEWaveCoder::~EEWaveCoder() 36 | { 37 | } 38 | 39 | //---------------------------------------------------------------------------------------------------- 40 | bool EEWaveCoder::WaveEncode(char *_dataIn, int _inLen, char *_dataOut, int *_outLen) 41 | { 42 | InitializeWaveCoder(); 43 | 44 | if (!_dataIn || _inLen != 960 || !_dataOut) 45 | return false; 46 | 47 | va_g729a_encoder((short*)_dataIn, (BYTE*)_dataOut); 48 | va_g729a_encoder((short*)(_dataIn + 160), (BYTE*)_dataOut + 10); 49 | va_g729a_encoder((short*)(_dataIn + 320), (BYTE*)_dataOut + 20); 50 | va_g729a_encoder((short*)(_dataIn + 480), (BYTE*)_dataOut + 30); 51 | va_g729a_encoder((short*)(_dataIn + 640), (BYTE*)_dataOut + 40); 52 | va_g729a_encoder((short*)(_dataIn + 800), (BYTE*)_dataOut + 50); 53 | 54 | if (_outLen) 55 | *_outLen = 60; 56 | 57 | return true; 58 | } 59 | 60 | //---------------------------------------------------------------------------------------------------- 61 | bool EEWaveCoder::WaveDecode(char *_dataIn, int _inLen, char *_dataOut, int *_outLen) 62 | { 63 | InitializeWaveCoder(); 64 | 65 | if (!_dataIn || _inLen != 60 || !_dataOut) 66 | return false; 67 | 68 | va_g729a_decoder((BYTE*)_dataIn, (short*)(_dataOut), 0); 69 | va_g729a_decoder((BYTE*)_dataIn + 10, (short*)(_dataOut + 160), 0); 70 | va_g729a_decoder((BYTE*)_dataIn + 20, (short*)(_dataOut + 320), 0); 71 | va_g729a_decoder((BYTE*)_dataIn + 30, (short*)(_dataOut + 480), 0); 72 | va_g729a_decoder((BYTE*)_dataIn + 40, (short*)(_dataOut + 640), 0); 73 | va_g729a_decoder((BYTE*)_dataIn + 50, (short*)(_dataOut + 800), 0); 74 | 75 | if (_outLen) 76 | *_outLen = 960; 77 | 78 | return true; 79 | } 80 | } -------------------------------------------------------------------------------- /Emerald/EEComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include "EEComboBox.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | //---------------------------------------------------------------------------------------------------- 8 | EEComboBox::EEComboBox(const Rect_Float& _rect, const EEColor& _color, const EEColor& _fontColor) 9 | : 10 | EELineBrowser(_rect, _color, _fontColor), 11 | m_isSelecting(false), 12 | m_options(), 13 | m_selected(-1), 14 | m_isSelectedDirty(true) 15 | { 16 | SetIsFocusable(true); 17 | } 18 | 19 | //---------------------------------------------------------------------------------------------------- 20 | EEComboBox::~EEComboBox() 21 | { 22 | 23 | } 24 | 25 | //---------------------------------------------------------------------------------------------------- 26 | bool EEComboBox::Update() 27 | { 28 | if (m_isSelectedDirty) 29 | { 30 | if (0 <= m_selected && m_selected < (int)m_options.size()) 31 | { 32 | SetText(m_options[m_selected]->GetText()); 33 | m_isSelectedDirty = false; 34 | } 35 | } 36 | //if (s_focusedObject != this) 37 | // m_isSelecting = false; 38 | if (!EELineBrowser::Update()) 39 | return false; 40 | 41 | if (m_isSelecting) 42 | { 43 | for (EELineBrowser* item : m_options) 44 | item->Update(); 45 | } 46 | 47 | return true; 48 | } 49 | 50 | //---------------------------------------------------------------------------------------------------- 51 | bool EEComboBox::Render() 52 | { 53 | if (!EELineBrowser::Render()) 54 | return false; 55 | 56 | if (m_isSelecting) 57 | { 58 | for (EELineBrowser* item : m_options) 59 | item->Render(); 60 | } 61 | 62 | return true; 63 | } 64 | 65 | //---------------------------------------------------------------------------------------------------- 66 | bool EEComboBox::AddItem(const std::wstring& _str, std::function _funcPtr) 67 | { 68 | float height = GetHeight() * (m_options.size() + 1); 69 | m_options.push_back(new EELineBrowser(Rect_Float(0.0f, height, GetWidth(), height + GetHeight()) - FLOAT2(GetWidth() / 2, GetHeight() / 2), 70 | m_color, m_font.GetColor(), _str)); 71 | int index = m_options.size() - 1; 72 | m_options[index]->SetParent(this); 73 | m_options[index]->SetIsFocusable(true); 74 | m_options[index]->SetTriggeredFunc( 75 | [&, index, _funcPtr]() 76 | { 77 | _funcPtr(); 78 | m_selected = index; 79 | m_isSelectedDirty = true; 80 | m_isSelecting = false; 81 | }); 82 | 83 | return true; 84 | } 85 | 86 | //---------------------------------------------------------------------------------------------------- 87 | void EEComboBox::OnMouseClicked(const Point& _pos) 88 | { 89 | EELineBrowser::OnMouseClicked(_pos); 90 | s_focusedObject = this; 91 | 92 | m_isSelecting = !m_isSelecting; 93 | } 94 | } -------------------------------------------------------------------------------- /Emerald/EECharacterGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include "EECharacterGenerator.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | // EECharacterGenerator 8 | //---------------------------------------------------------------------------------------------------- 9 | EECharacterGenerator::EECharacterGenerator() 10 | { 11 | Initialize(); 12 | } 13 | 14 | //---------------------------------------------------------------------------------------------------- 15 | EECharacterGenerator::~EECharacterGenerator() 16 | { 17 | 18 | } 19 | 20 | //---------------------------------------------------------------------------------------------------- 21 | bool EECharacterGenerator::Generate(EEBitmap& _bitmap, std::vector& _result) 22 | { 23 | _result.clear(); 24 | 25 | unsigned char *data = _bitmap.GetData(); 26 | for (int i = 0; i < _bitmap.GetHeight() * _bitmap.GetWidth() << 2; i += _bitmap.GetWidth() << 2) 27 | { 28 | std::string rowData; 29 | for (int j = 0; j < _bitmap.GetWidth() << 2; j += 4) 30 | { 31 | float gray = data[i + j] * 0.299f + data[i + j + 1] * 0.587f + data[i + j + 2] * 0.114f; 32 | char character = ' '; 33 | characterTree.FindData(gray, gray, character); 34 | rowData.push_back(character); 35 | } 36 | 37 | _result.push_back(rowData); 38 | } 39 | 40 | return true; 41 | } 42 | 43 | //---------------------------------------------------------------------------------------------------- 44 | bool EECharacterGenerator::Generate(EEBitmap& _bitmap, std::string& _result) 45 | { 46 | _result.clear(); 47 | 48 | unsigned char *data = _bitmap.GetData(); 49 | for (int i = 0; i < _bitmap.GetHeight() * _bitmap.GetWidth() << 2; i += _bitmap.GetWidth() << 2) 50 | { 51 | std::string rowData; 52 | for (int j = 0; j < _bitmap.GetWidth() << 2; j += 4) 53 | { 54 | float gray = data[i + j] * 0.299f + data[i + j + 1] * 0.587f + data[i + j + 2] * 0.114f; 55 | char character = ' '; 56 | characterTree.FindData(gray, gray, character); 57 | rowData.push_back(character); 58 | } 59 | 60 | rowData += '\n'; 61 | _result.append(rowData); 62 | } 63 | 64 | return true; 65 | } 66 | 67 | //---------------------------------------------------------------------------------------------------- 68 | bool EECharacterGenerator::Initialize() 69 | { 70 | characterTree.Insert(0.f, 20.f, '#'); 71 | characterTree.Insert(20.f, 50.f, '#'); 72 | characterTree.Insert(50.f, 70.f, '&'); 73 | characterTree.Insert(70.f, 80.f, '$'); 74 | characterTree.Insert(80.f, 110.f, '*'); 75 | characterTree.Insert(110.f, 150.f, '+'); 76 | characterTree.Insert(150.f, 180.f, '~'); 77 | characterTree.Insert(180.f, 200.f, '^'); 78 | characterTree.Insert(200.f, 220.f, '-'); 79 | characterTree.Insert(220.f, 240.f, '`'); 80 | characterTree.Insert(240.f, 256.f, ' '); 81 | 82 | return true; 83 | } 84 | } -------------------------------------------------------------------------------- /Emerald/EETextBrowser.cpp: -------------------------------------------------------------------------------- 1 | #include "EETextBrowser.h" 2 | #include "EECore.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | // EETextBrowser 9 | //---------------------------------------------------------------------------------------------------- 10 | EETextBrowser::EETextBrowser(const Rect_Float &_rect, const EEColor& _color, const EEColor& _fontColor) 11 | : 12 | EEQuad2D(_rect, _color), 13 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 14 | { 15 | m_font.SetParent(this); 16 | } 17 | 18 | //---------------------------------------------------------------------------------------------------- 19 | EETextBrowser::EETextBrowser(const Rect_Float &_rect, const EETexture& _tex, const EEColor& _fontColor) 20 | : 21 | EEQuad2D(_rect, _tex), 22 | m_font(m_quadWidth, m_quadHeight, _fontColor, L"") 23 | { 24 | m_font.SetParent(this); 25 | } 26 | 27 | //---------------------------------------------------------------------------------------------------- 28 | EETextBrowser::EETextBrowser(const EETextBrowser& _textBrowser) 29 | : 30 | EEQuad2D(_textBrowser), 31 | m_font(_textBrowser.m_font) 32 | { 33 | 34 | } 35 | 36 | //---------------------------------------------------------------------------------------------------- 37 | EETextBrowser::~EETextBrowser() 38 | { 39 | 40 | } 41 | 42 | //---------------------------------------------------------------------------------------------------- 43 | bool EETextBrowser::Update() 44 | { 45 | if (!EEQuad2D::Update()) 46 | return false; 47 | 48 | if (s_focusedObject == this) 49 | { 50 | // the key queue need to be cleared here 51 | } 52 | if (s_triggeredObject == this) 53 | { 54 | 55 | } 56 | m_font.Update(); 57 | 58 | return true; 59 | } 60 | 61 | //---------------------------------------------------------------------------------------------------- 62 | bool EETextBrowser::Render() 63 | { 64 | if (!EEQuad2D::Render()) 65 | return false; 66 | 67 | return m_font.Render(); 68 | } 69 | 70 | //---------------------------------------------------------------------------------------------------- 71 | bool EETextBrowser::AddText(wchar_t _text) 72 | { 73 | return m_font.AddText(_text); 74 | } 75 | 76 | //---------------------------------------------------------------------------------------------------- 77 | bool EETextBrowser::AddText(const wchar_t* _text) 78 | { 79 | return m_font.AddText(_text); 80 | } 81 | 82 | //---------------------------------------------------------------------------------------------------- 83 | void EETextBrowser::SetText(const std::wstring& _text) 84 | { 85 | m_font.SetText(_text.data()); 86 | } 87 | 88 | //---------------------------------------------------------------------------------------------------- 89 | const std::wstring& EETextBrowser::GetText() 90 | { 91 | return m_font.GetText(); 92 | } 93 | } -------------------------------------------------------------------------------- /Emerald/DirectXTex/BCDirectCompute.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------- 2 | // BCDirectCompute.h 3 | // 4 | // Direct3D 11 Compute Shader BC Compressor 5 | // 6 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 7 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 8 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 9 | // PARTICULAR PURPOSE. 10 | // 11 | // Copyright (c) Microsoft Corporation. All rights reserved. 12 | //------------------------------------------------------------------------------------- 13 | 14 | #pragma once 15 | 16 | namespace DirectX 17 | { 18 | 19 | class GPUCompressBC 20 | { 21 | public: 22 | GPUCompressBC(); 23 | 24 | HRESULT Initialize( _In_ ID3D11Device* pDevice ); 25 | 26 | HRESULT Prepare( _In_ size_t width, _In_ size_t height, _In_ DXGI_FORMAT format, _In_ float alphaWeight = 1.f ); 27 | 28 | HRESULT Compress( _In_ const Image& srcImage, _In_ const Image& destImage ); 29 | 30 | DXGI_FORMAT GetSourceFormat() const { return m_srcformat; } 31 | 32 | private: 33 | DXGI_FORMAT m_bcformat; 34 | DXGI_FORMAT m_srcformat; 35 | float m_alphaWeight; 36 | size_t m_width; 37 | size_t m_height; 38 | 39 | Microsoft::WRL::ComPtr m_device; 40 | Microsoft::WRL::ComPtr m_context; 41 | 42 | Microsoft::WRL::ComPtr m_err1; 43 | Microsoft::WRL::ComPtr m_err1UAV; 44 | Microsoft::WRL::ComPtr m_err1SRV; 45 | 46 | Microsoft::WRL::ComPtr m_err2; 47 | Microsoft::WRL::ComPtr m_err2UAV; 48 | Microsoft::WRL::ComPtr m_err2SRV; 49 | 50 | Microsoft::WRL::ComPtr m_output; 51 | Microsoft::WRL::ComPtr m_outputCPU; 52 | Microsoft::WRL::ComPtr m_outputUAV; 53 | Microsoft::WRL::ComPtr m_constBuffer; 54 | 55 | // Compute shader library 56 | Microsoft::WRL::ComPtr m_BC6H_tryModeG10CS; 57 | Microsoft::WRL::ComPtr m_BC6H_tryModeLE10CS; 58 | Microsoft::WRL::ComPtr m_BC6H_encodeBlockCS; 59 | 60 | Microsoft::WRL::ComPtr m_BC7_tryMode456CS; 61 | Microsoft::WRL::ComPtr m_BC7_tryMode137CS; 62 | Microsoft::WRL::ComPtr m_BC7_tryMode02CS; 63 | Microsoft::WRL::ComPtr m_BC7_encodeBlockCS; 64 | }; 65 | 66 | }; // namespace -------------------------------------------------------------------------------- /Emerald/Demo/GeneTest.cpp: -------------------------------------------------------------------------------- 1 | // Demo 2 | #if 0 3 | #include "../Emerald.h" 4 | 5 | 6 | //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) 7 | int main(int _argc, char** _argv) 8 | { 9 | EEGeneController geneController( 10 | [](std::vector _meanings) -> float 11 | { 12 | if (!_meanings.size()) 13 | return 0.f; 14 | 15 | bool isInitialized = false; 16 | bool isFuncLoaded = false; 17 | bool isNumLoaded = false; 18 | int left = 0; 19 | int right = 0; 20 | std::function operateFunc; 21 | for (unsigned int i = 0; i < _meanings.size(); ++i) 22 | { 23 | if (_meanings[i].type() == typeid(int)) 24 | { 25 | if (isNumLoaded) 26 | { 27 | right *= 10; 28 | right += boost::any_cast(_meanings[i]); 29 | } 30 | else 31 | { 32 | right = boost::any_cast(_meanings[i]); 33 | isNumLoaded = true; 34 | } 35 | } 36 | else if (_meanings[i].type() == typeid(std::function)) 37 | { 38 | if (!isInitialized) 39 | { 40 | left = right; 41 | isInitialized = true; 42 | } 43 | else if (isNumLoaded && isFuncLoaded) 44 | { 45 | std::cout << left << " op " << right; 46 | left = operateFunc(left, right); 47 | std::cout << " = " << left << std::endl; 48 | } 49 | 50 | operateFunc = boost::any_cast>(_meanings[i]); 51 | isNumLoaded = false; 52 | isFuncLoaded = true; 53 | } 54 | } 55 | if (isNumLoaded && isFuncLoaded) 56 | { 57 | std::cout << left << " op " << right; 58 | left = operateFunc(left, right); 59 | std::cout << " = " << left << std::endl; 60 | } 61 | 62 | float result = 1.f / (0.05f * abs(left - 100) + 1); // Option: logistic regression function 63 | std::cout << "Fitness:" << result << std::endl; 64 | return result; 65 | }); 66 | 67 | geneController.AddTranslation("0000", 0); 68 | geneController.AddTranslation("0001", 1); 69 | geneController.AddTranslation("0010", 2); 70 | geneController.AddTranslation("0011", 3); 71 | geneController.AddTranslation("0100", 4); 72 | geneController.AddTranslation("0101", 5); 73 | geneController.AddTranslation("0110", 6); 74 | geneController.AddTranslation("0111", 7); 75 | geneController.AddTranslation("1000", 8); 76 | geneController.AddTranslation("1001", 9); 77 | geneController.AddTranslation("00", std::function([](int _a, int _b) -> int { return _a + _b; })); 78 | geneController.AddTranslation("01", std::function([](int _a, int _b) -> int { return _a - _b; })); 79 | geneController.AddTranslation("10", std::function([](int _a, int _b) -> int { return _a * _b; })); 80 | geneController.AddSample({ "0000", "00", "0000", "00", "0000", "00", "0000" }); 81 | geneController.AddSample({ "0000", "01", "0000", "01", "0000", "01", "0000" }); 82 | geneController.AddSample({ "0000", "10", "0000", "10", "0000", "10", "0000" }); 83 | while (geneController.Epoch()); 84 | 85 | return 0; 86 | } 87 | 88 | #endif -------------------------------------------------------------------------------- /Emerald/EETexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_TEXTURE_H_ 3 | #define _EE_TEXTURE_H_ 4 | 5 | #include 6 | #include 7 | #include "EESmartPtr.h" 8 | #include "EEBitmap.h" 9 | 10 | #include // debug 11 | 12 | 13 | //---------------------------------------------------------------------------------------------------- 14 | namespace Emerald 15 | { 16 | // EETextureType 17 | //---------------------------------------------------------------------------------------------------- 18 | typedef enum EETextureType 19 | { 20 | EE_BMP = 1, 21 | EE_JPG = 2, 22 | EE_PNG = 3, 23 | EE_DDS = 4, 24 | EE_TIFF = 5, 25 | EE_GIF = 6, 26 | EE_WMP = 7, 27 | } EETextureType; 28 | 29 | // EETextureData 30 | //---------------------------------------------------------------------------------------------------- 31 | class EETextureData 32 | { 33 | public: 34 | EETextureData(); 35 | EETextureData(ID3D11Resource* _resource); 36 | EETextureData(ID3D11ShaderResourceView* _texture); 37 | virtual ~EETextureData(); 38 | 39 | public: 40 | ID3D11Resource *resource; 41 | ID3D11ShaderResourceView *texture; 42 | ID3D11UnorderedAccessView *textureUAV; 43 | ID3D11RenderTargetView *textureRTV; 44 | int width; 45 | int height; 46 | int number; 47 | }; 48 | 49 | // EETexture 50 | //---------------------------------------------------------------------------------------------------- 51 | class EETexture : public EESmartPtr 52 | { 53 | public: 54 | EETexture(); 55 | EETexture(wchar_t* _file); 56 | EETexture(unsigned int _width, unsigned int _height); 57 | EETexture(const unsigned char* _buffer, unsigned int _width, unsigned int _height); 58 | EETexture(EEBitmap& _bitmap); 59 | EETexture(ID3D11Resource* _resource); 60 | EETexture(ID3D11ShaderResourceView* _texture); 61 | EETexture(const EETexture& _texture); 62 | virtual ~EETexture(); 63 | 64 | virtual EETexture Clone(); 65 | 66 | bool SetTexture(LPCWSTR _file); 67 | bool SetTexture(unsigned int _width, unsigned int _height); 68 | bool SetTexture(const unsigned char* _buffer, unsigned int _width, unsigned int _height); 69 | bool SetTexture(unsigned int _width, unsigned int _height, DXGI_FORMAT _format); 70 | bool SetTexture(EEBitmap& _bitmap); 71 | bool SetTexture(ID3D11Resource* _resource); 72 | bool SetTexture(ID3D11ShaderResourceView* _texture); 73 | 74 | int GetWidth(); 75 | int GetHeight(); 76 | int GetNumber(); 77 | bool GetBitmap(EEBitmap& _bitmap, unsigned int _mipLevel = 0); 78 | ID3D11Resource* GetResource(); 79 | ID3D11ShaderResourceView* GetTexture(); 80 | ID3D11UnorderedAccessView* GetTextureUAV(); 81 | ID3D11RenderTargetView* GetTextureRTV(); 82 | 83 | }; 84 | 85 | // EETexture_APIs 86 | //---------------------------------------------------------------------------------------------------- 87 | bool EESaveTextureToFile(EETexture& _texture, LPCWSTR _fileName, EETextureType _type); 88 | EETexture EETextureCombine(EETexture* _texture, unsigned int _num); 89 | } 90 | 91 | #endif -------------------------------------------------------------------------------- /Emerald/EEQuad2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_QUAD2D_H_ 3 | #define _EE_QUAD2D_H_ 4 | 5 | #include "EEObject2D.h" 6 | 7 | 8 | //---------------------------------------------------------------------------------------------------- 9 | namespace Emerald 10 | { 11 | // EEQuad2DVertex 12 | //---------------------------------------------------------------------------------------------------- 13 | struct EEQuad2DVertex 14 | { 15 | FLOAT3 pos; 16 | FLOAT2 tex; 17 | }; 18 | 19 | // EEQuad2D 20 | //---------------------------------------------------------------------------------------------------- 21 | /* 22 | +--+--+--+--+--+--+--+--+ 23 | | + position | 24 | +--+--+--+--0--+--+--+--+ 25 | | + | 26 | +--+--+--+--+--+--+--+--+ 27 | */ 28 | class EEQuad2D : public EEObject2D 29 | { 30 | protected: 31 | static bool InitializeQuad2D(); 32 | 33 | protected: 34 | static bool s_isQuad2DInitialized; 35 | static ID3D11InputLayout *s_quadIL; 36 | static ID3D11VertexShader *s_quadVS; 37 | static ID3D11PixelShader *s_quadPS; 38 | static ID3D11Buffer *s_quad2DBuffer; 39 | 40 | public: 41 | EEQuad2D(); 42 | EEQuad2D(const FLOAT3& _position); 43 | EEQuad2D(const FLOAT3& _position, FLOAT _width, FLOAT _height); 44 | EEQuad2D(const FLOAT3& _position, FLOAT _width, FLOAT _height, const EEColor& _color); 45 | EEQuad2D(const FLOAT3& _position, FLOAT _width, FLOAT _height, const EETexture& _tex); 46 | EEQuad2D(const Rect_Float& _rect); 47 | EEQuad2D(const Rect_Float& _rect, const EEColor& _color); 48 | EEQuad2D(const Rect_Float& _rect, const EETexture& _tex); 49 | EEQuad2D(const Rect_Float& _rect, ID3D11ShaderResourceView* _tex); 50 | EEQuad2D(const EEQuad2D& _quad); 51 | virtual ~EEQuad2D(); 52 | virtual inline EEObject* Clone() { return new EEQuad2D(*this); } 53 | 54 | virtual bool Update(); 55 | virtual bool Render(); 56 | 57 | // position 58 | virtual void SetPositionX(float _posX); 59 | virtual void SetPositionY(float _posY); 60 | virtual void SetPositionXY(const FLOAT2& _position); 61 | virtual void SetPosition(const FLOAT3& _position); 62 | virtual void SetRect(const Rect_Float& _rect); 63 | virtual void SetWidth(float _width); 64 | virtual void SetHeight(float _height); 65 | 66 | // position 67 | virtual const Rect_Float& GetRect() const; 68 | virtual float GetWidth() const; 69 | virtual float GetHeight() const; 70 | virtual FLOAT3 GetCenter() const; 71 | virtual float GetOffsetWidth() const; 72 | virtual float GetOffsetHeight() const; 73 | 74 | // position 75 | virtual Rect_Float GetFinalRect() const; 76 | virtual FLOAT3 GetFinalCenter() const; 77 | 78 | protected: 79 | // state 80 | virtual bool UpdateObjectState(); 81 | // vbuffer 82 | bool CreateQuadVertexBuffer(int _verticesNum = 4); 83 | 84 | protected: 85 | // the size of the quad 86 | Rect_Float m_quadRect; // redundancy 87 | float m_quadWidth, m_quadHeight; 88 | // the vertex buffer of the quad 89 | ID3D11Buffer *m_quadVB; 90 | }; 91 | } 92 | 93 | 94 | #endif -------------------------------------------------------------------------------- /Emerald/EEAnimation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_ANIMATION_H_ 3 | #define _EE_ANIMATION_H_ 4 | 5 | #include 6 | #include 7 | #include "EEGeometry.h" 8 | #include "EEHelper.h" 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | namespace Emerald 12 | { 13 | // EEAnimationFrame 14 | //---------------------------------------------------------------------------------------------------- 15 | struct EEAnimationFrame 16 | { 17 | bool isRunning; 18 | int id; 19 | EEObject *object; 20 | float startTime; 21 | float duration; 22 | std::vector> actions; 23 | 24 | inline EEAnimationFrame() : isRunning(false), id(-1), object(nullptr), startTime(0.f), duration(0.f), actions() {} 25 | inline EEAnimationFrame(const EEAnimationFrame& _frame) { *this = _frame; } 26 | inline ~EEAnimationFrame() 27 | { 28 | SAFE_DELETE(object); 29 | } 30 | inline void SetObject(EEObject& _obj) { SAFE_DELETE(object); object = _obj.Clone(); } 31 | 32 | EEAnimationFrame& operator= (const EEAnimationFrame& _frame) 33 | { 34 | isRunning = _frame.isRunning; 35 | id = _frame.id; 36 | object = _frame.object->Clone(); 37 | startTime = _frame.startTime; 38 | duration = _frame.duration; 39 | actions = _frame.actions; 40 | 41 | return *this; 42 | } 43 | }; 44 | 45 | // EEAnimation 46 | //---------------------------------------------------------------------------------------------------- 47 | class EEAnimation : public EEObject 48 | { 49 | public: 50 | EEAnimation(); 51 | EEAnimation(const EEAnimation& _animation); 52 | virtual ~EEAnimation(); 53 | virtual inline EEObject* Clone() { return new EEAnimation(*this); } 54 | 55 | virtual bool Update(); 56 | virtual bool Render(); 57 | bool Start(); 58 | bool AddFrame(const EEAnimationFrame& _frame); 59 | bool RemoveFrame(int _id = -1); 60 | 61 | void SetIsLoop(bool _isLoop); 62 | 63 | std::vector GetFrames(); 64 | 65 | protected: 66 | std::vector m_frames; 67 | std::vector m_backup; 68 | float startTime; 69 | bool m_isLoop; 70 | }; 71 | 72 | // EEAnimationEmitter 73 | // The more efficient way is to store only one animation and copy it to every frames 74 | //---------------------------------------------------------------------------------------------------- 75 | class EEAnimationEmitter : public EEObject 76 | { 77 | public: 78 | EEAnimationEmitter(); 79 | EEAnimationEmitter(const EEAnimationEmitter& _emitter); 80 | virtual ~EEAnimationEmitter(); 81 | 82 | virtual bool Update(); 83 | virtual bool Render(); 84 | 85 | bool Emit(const FLOAT3& _pos); 86 | bool SetAnimation(const EEAnimation* _animation); 87 | void SetIsAnimationDirty(bool _isAnimationDirty); 88 | 89 | EEAnimation* GetAnimation(); 90 | 91 | protected: 92 | std::vector m_animations; 93 | EEAnimation* m_backup; 94 | bool m_isAnimationDirty; 95 | }; 96 | } 97 | 98 | 99 | #endif -------------------------------------------------------------------------------- /Emerald/EEShader/EEBlurShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_BLURSHADER_HLSL_ 2 | #define _EE_BLURSHADER_HLSL_ 3 | 4 | #include "EEShaderHelper.hlsl" 5 | 6 | #define N 256 7 | #define GROUPDIM_Z 1 8 | 9 | // Blur 10 | //---------------------------------------------------------------------------------------------------- 11 | cbuffer BlurSettings 12 | { 13 | static const int g_blurRadius = 5; 14 | static const float g_weights[11] = 15 | { 16 | 0.05f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.05f, 0.05f, 17 | }; 18 | }; 19 | 20 | cbuffer BlurBuffer : register(b3) 21 | { 22 | float cb_value : packoffset(c0.x); 23 | float cb_tmp31 : packoffset(c0.y); 24 | float cb_tmp32 : packoffset(c0.z); 25 | float cb_tmp33 : packoffset(c0.w); 26 | }; 27 | 28 | Texture2D g_input : register(cs, t0); 29 | RWTexture2D g_output : register(cs, u0); 30 | groupshared float4 g_cache[N + 2 * g_blurRadius]; 31 | 32 | [numthreads(N, 1, GROUPDIM_Z)] 33 | void BlurHorzCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 34 | { 35 | // left borders 36 | if (_groupTID.x < g_blurRadius) 37 | { 38 | // image borders 39 | int x = max(_threadID.x - g_blurRadius, 0); 40 | g_cache[_groupTID.x] = g_input[uint2(x, _threadID.y)]; 41 | } 42 | // right borders 43 | if (_groupTID.x >= N - g_blurRadius) 44 | { 45 | // image borders. 46 | int x = min(_threadID.x + g_blurRadius, g_input.Length.x - 1); 47 | g_cache[_groupTID.x + 2 * g_blurRadius] = g_input[uint2(x, _threadID.y)]; 48 | } 49 | g_cache[_groupTID.x + g_blurRadius] = g_input[min(_threadID.xy, g_input.Length.xy - 1)]; 50 | 51 | GroupMemoryBarrierWithGroupSync(); 52 | 53 | // blur 54 | float4 blurColor = float4(0.f, 0.f, 0.f, 0.f); 55 | [unroll] 56 | for (int i = -g_blurRadius; i <= g_blurRadius; ++i) 57 | { 58 | blurColor += g_weights[i + g_blurRadius] * g_cache[_groupTID.x + g_blurRadius + i]; 59 | } 60 | g_output[_threadID.xy] = blurColor; 61 | } 62 | 63 | [numthreads(1, N, GROUPDIM_Z)] 64 | void BlurVertCS(uint3 _groupID : SV_GroupID, uint3 _groupTID : SV_GroupThreadID, uint _groupIndex : SV_GroupIndex, uint3 _threadID : SV_DispatchThreadID) 65 | { 66 | // top borders 67 | if (_groupTID.y < g_blurRadius) 68 | { 69 | // image borders 70 | int y = max(_threadID.y - g_blurRadius, 0); 71 | g_cache[_groupTID.y] = g_input[uint2(_threadID.x, y)]; 72 | } 73 | // buttom borders 74 | if (_groupTID.y >= N - g_blurRadius) 75 | { 76 | // image borders. 77 | int y = min(_threadID.y + g_blurRadius, g_input.Length.y - 1); 78 | g_cache[_groupTID.y + 2 * g_blurRadius] = g_input[uint2(_threadID.x, y)]; 79 | } 80 | g_cache[_groupTID.y + g_blurRadius] = g_input[min(_threadID.xy, g_input.Length.xy - 1)]; 81 | 82 | GroupMemoryBarrierWithGroupSync(); 83 | 84 | // blur 85 | float4 blurColor = float4(0.f, 0.f, 0.f, 0.f); 86 | [unroll] 87 | for (int i = -g_blurRadius; i <= g_blurRadius; ++i) 88 | { 89 | blurColor += g_weights[i + g_blurRadius] * g_cache[_groupTID.y + g_blurRadius + i]; 90 | } 91 | g_output[_threadID.xy] = blurColor; 92 | } 93 | 94 | #endif -------------------------------------------------------------------------------- /Emerald/Demo/DIVAProject/DIVAMusicList.cpp: -------------------------------------------------------------------------------- 1 | #include "DIVAMusicList.h" 2 | #include 3 | #include 4 | 5 | 6 | //---------------------------------------------------------------------------------------------------- 7 | DIVAMusicList::DIVAMusicList() 8 | { 9 | LoadMusicList(); 10 | } 11 | 12 | //---------------------------------------------------------------------------------------------------- 13 | vector* DIVAMusicList::GetMusicList() 14 | { 15 | return &m_musicList; 16 | } 17 | 18 | //---------------------------------------------------------------------------------------------------- 19 | const DIVAMap* DIVAMusicList::GetMap(unsigned int _listId, DIVADifficulty _difficulty) 20 | { 21 | if (_listId < 0 || m_musicList.size() <= _listId) 22 | return nullptr; 23 | 24 | auto& paths = m_musicList[_listId].musicMapsPath; 25 | auto& pathsIt = paths.find(_difficulty); 26 | if (pathsIt == paths.end()) 27 | return nullptr; 28 | 29 | auto& maps = m_musicList[_listId].musicMaps; 30 | auto mapIt = maps.find(_difficulty); 31 | if (mapIt == maps.end()) 32 | { 33 | maps[_difficulty] = DIVAMap(pathsIt->second.c_str(), m_musicList[_listId].musicPath.c_str()); 34 | } 35 | 36 | return &maps[_difficulty]; 37 | } 38 | 39 | //---------------------------------------------------------------------------------------------------- 40 | bool DIVAMusicList::LoadMusicList() 41 | { 42 | char pathBase[MAX_PATH] = { 0 }; 43 | GetCurrentDirectoryA(MAX_PATH, pathBase); 44 | 45 | // find music directory 46 | HANDLE musicHandle; 47 | WIN32_FIND_DATAA musicData; 48 | string path(pathBase); 49 | path += "/Song/"; 50 | musicHandle = FindFirstFileA((path + "*.*").c_str(), &musicData); 51 | if (musicHandle != INVALID_HANDLE_VALUE) 52 | { 53 | do 54 | { 55 | if (musicData.cFileName[0] == '.') 56 | continue; 57 | 58 | if (musicData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 59 | { 60 | DIVAMusicInfo info; 61 | info.musicName = musicData.cFileName; 62 | info.musicPath = path + musicData.cFileName + '/'; 63 | // find diva 64 | HANDLE mapHandle; 65 | WIN32_FIND_DATAA mapData; 66 | mapHandle = FindFirstFileA((info.musicPath + "*.diva").c_str(), &mapData); 67 | if (mapHandle != INVALID_HANDLE_VALUE) 68 | { 69 | do 70 | { 71 | string degree = mapData.cFileName; 72 | auto begin = degree.find_last_of('_') + 1; 73 | auto end = degree.find_last_of('.') - 1; 74 | degree = degree.substr(begin, end - begin + 1); 75 | if (degree == "Easy") 76 | info.musicMapsPath[DIVA_EASY] = info.musicPath + mapData.cFileName; 77 | else if (degree == "Normal") 78 | info.musicMapsPath[DIVA_NORMAL] = info.musicPath + mapData.cFileName; 79 | else if (degree == "Hard") 80 | info.musicMapsPath[DIVA_HARD] = info.musicPath + mapData.cFileName; 81 | else 82 | info.musicMapsPath[DIVA_FUCK] = info.musicPath + mapData.cFileName; 83 | } while (FindNextFileA(mapHandle, &mapData)); 84 | } 85 | 86 | // save 87 | m_musicList.push_back(info); 88 | } 89 | } while (FindNextFileA(musicHandle, &musicData)); 90 | 91 | return true; 92 | } 93 | return false; 94 | } 95 | -------------------------------------------------------------------------------- /Emerald/EENeuralNetworks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_NEURALNETWORKS_H_ 3 | #define _EE_NEURALNETWORKS_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "EESmartPtr.h" 9 | 10 | 11 | // Option: time-based 12 | // Warnning: loop 13 | //---------------------------------------------------------------------------------------------------- 14 | namespace Emerald 15 | { 16 | struct EESynapse; 17 | typedef EESmartPtr EESynapsePtr; 18 | class EENeuron; 19 | typedef EESmartPtr EENeuronPtr; 20 | 21 | // EESynapse (Input & Output) 22 | //---------------------------------------------------------------------------------------------------- 23 | struct EESynapse 24 | { 25 | public: 26 | EESynapse(EENeuronPtr _source, float _weight, EENeuronPtr _target); 27 | 28 | void Activate(float _input); 29 | 30 | public: 31 | EENeuronPtr source; 32 | float weight; 33 | EENeuronPtr target; 34 | }; 35 | 36 | // EENeuron (Core) 37 | //---------------------------------------------------------------------------------------------------- 38 | class EENeuron 39 | { 40 | public: 41 | EENeuron(); 42 | virtual ~EENeuron(); 43 | 44 | void Stimulate(float _input); 45 | float Activate(); 46 | 47 | float GetActivity(); 48 | bool IsStimulusDirty(); 49 | void ClearStimulus(); 50 | std::map& GetDendrites(); 51 | void AddDendrite(EESynapsePtr& _dendrite); 52 | void AddAxon(EESynapsePtr& _axon); 53 | std::map& GetAxons(); 54 | bool RemoveDendrite(EENeuronPtr& _dendrite); 55 | bool RemoveAxon(EENeuronPtr& _axon); 56 | 57 | // Learning 58 | void AdjustWeights(float _error); 59 | 60 | protected: 61 | void AddStimulus(float _stimulus); 62 | float Sigmoid(float _input); 63 | float SigmoidD(float _input); 64 | 65 | protected: 66 | float m_activity; 67 | bool m_isStimulusDirty; 68 | float m_stimulus; 69 | unsigned int m_stimulatedTimes; 70 | std::map m_dendrites; // Input 71 | std::map m_axons; // Output 72 | 73 | // Learning 74 | float m_learningRate; 75 | }; 76 | 77 | // NeuralNetworks 78 | //---------------------------------------------------------------------------------------------------- 79 | class EENeuralNetworks 80 | { 81 | public: 82 | EENeuralNetworks(); 83 | virtual ~EENeuralNetworks(); 84 | 85 | bool Generate(unsigned int _inputCount, unsigned int _outputCount, std::vector _neuronCounts); // Feedforword 86 | std::vector Stimulate(const std::vector& _inputs); 87 | 88 | // Learning 89 | bool BPTrain(const std::vector& _inputs, const std::vector& _outputs); // Back Propagation 90 | 91 | protected: 92 | void ClearStimulus(); 93 | void ClearStimulus(EENeuronPtr _neuron); 94 | bool Link(EENeuronPtr _source, float _weight, EENeuronPtr _target); 95 | bool Unlink(EENeuronPtr _source, EENeuronPtr _target); 96 | 97 | protected: 98 | std::vector m_inputs; 99 | std::vector m_outputs; 100 | }; 101 | } 102 | 103 | #endif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | 98 | # NuGet Packages Directory 99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 100 | packages/ 101 | 102 | # Windows Azure Build Output 103 | csx 104 | *.build.csdef 105 | 106 | # Windows Store app package directory 107 | AppPackages/ 108 | 109 | # Others 110 | sql/ 111 | *.Cache 112 | ClientBin/ 113 | [Ss]tyle[Cc]op.* 114 | ~$* 115 | *~ 116 | *.dbmdl 117 | *.[Pp]ublish.xml 118 | *.pfx 119 | *.publishsettings 120 | 121 | # RIA/Silverlight projects 122 | Generated_Code/ 123 | 124 | # Backup & report files from converting an old project file to a newer 125 | # Visual Studio version. Backup files are not needed, because we have git ;-) 126 | _UpgradeReport_Files/ 127 | Backup*/ 128 | UpgradeLog*.XML 129 | UpgradeLog*.htm 130 | 131 | # SQL Server files 132 | App_Data/*.mdf 133 | App_Data/*.ldf 134 | 135 | 136 | #LightSwitch generated files 137 | GeneratedArtifacts/ 138 | _Pvt_Extensions/ 139 | ModelManifest.xml 140 | 141 | # ========================= 142 | # Windows detritus 143 | # ========================= 144 | 145 | # Windows image file caches 146 | Thumbs.db 147 | ehthumbs.db 148 | 149 | # Folder config file 150 | Desktop.ini 151 | 152 | # Recycle Bin used on file shares 153 | $RECYCLE.BIN/ 154 | 155 | # Mac desktop service store files 156 | .DS_Store 157 | 158 | # Demo Files 159 | Texture/ 160 | Song/ 161 | Music/ 162 | # 163 | DLL/ 164 | *.o 165 | *.exe 166 | -------------------------------------------------------------------------------- /Emerald/EEFont/EEFontdata.txt: -------------------------------------------------------------------------------- 1 | 32 0.0 0.0 0 2 | 33 ! 0.0 0.000976563 1 3 | 34 " 0.00195313 0.00488281 3 4 | 35 # 0.00585938 0.0136719 8 5 | 36 $ 0.0146484 0.0195313 5 6 | 37 % 0.0205078 0.0302734 10 7 | 38 & 0.03125 0.0390625 8 8 | 39 ' 0.0400391 0.0410156 1 9 | 40 ( 0.0419922 0.0449219 3 10 | 41 ) 0.0458984 0.0488281 3 11 | 42 * 0.0498047 0.0546875 5 12 | 43 + 0.0556641 0.0625 7 13 | 44 , 0.0634766 0.0644531 1 14 | 45 - 0.0654297 0.0683594 3 15 | 46 . 0.0693359 0.0703125 1 16 | 47 / 0.0712891 0.0751953 4 17 | 48 0 0.0761719 0.0820313 6 18 | 49 1 0.0830078 0.0859375 3 19 | 50 2 0.0869141 0.0927734 6 20 | 51 3 0.09375 0.0996094 6 21 | 52 4 0.100586 0.106445 6 22 | 53 5 0.107422 0.113281 6 23 | 54 6 0.114258 0.120117 6 24 | 55 7 0.121094 0.126953 6 25 | 56 8 0.12793 0.133789 6 26 | 57 9 0.134766 0.140625 6 27 | 58 : 0.141602 0.142578 1 28 | 59 ; 0.143555 0.144531 1 29 | 60 < 0.145508 0.151367 6 30 | 61 = 0.152344 0.15918 7 31 | 62 > 0.160156 0.166016 6 32 | 63 ? 0.166992 0.171875 5 33 | 64 @ 0.172852 0.18457 12 34 | 65 A 0.185547 0.194336 9 35 | 66 B 0.195313 0.202148 7 36 | 67 C 0.203125 0.209961 7 37 | 68 D 0.210938 0.217773 7 38 | 69 E 0.21875 0.225586 7 39 | 70 F 0.226563 0.232422 6 40 | 71 G 0.233398 0.241211 8 41 | 72 H 0.242188 0.249023 7 42 | 73 I 0.25 0.250977 1 43 | 74 J 0.251953 0.256836 5 44 | 75 K 0.257813 0.265625 8 45 | 76 L 0.266602 0.272461 6 46 | 77 M 0.273438 0.282227 9 47 | 78 N 0.283203 0.290039 7 48 | 79 O 0.291016 0.298828 8 49 | 80 P 0.299805 0.306641 7 50 | 81 Q 0.307617 0.31543 8 51 | 82 R 0.316406 0.323242 7 52 | 83 S 0.324219 0.331055 7 53 | 84 T 0.332031 0.338867 7 54 | 85 U 0.339844 0.34668 7 55 | 86 V 0.347656 0.356445 9 56 | 87 W 0.357422 0.370117 13 57 | 88 X 0.371094 0.37793 7 58 | 89 Y 0.378906 0.385742 7 59 | 90 Z 0.386719 0.393555 7 60 | 91 [ 0.394531 0.396484 2 61 | 92 \ 0.397461 0.401367 4 62 | 93 ] 0.402344 0.404297 2 63 | 94 ^ 0.405273 0.410156 5 64 | 95 _ 0.411133 0.417969 7 65 | 96 ` 0.418945 0.420898 2 66 | 97 a 0.421875 0.426758 5 67 | 98 b 0.427734 0.432617 5 68 | 99 c 0.433594 0.438477 5 69 | 100 d 0.439453 0.444336 5 70 | 101 e 0.445313 0.450195 5 71 | 102 f 0.451172 0.455078 4 72 | 103 g 0.456055 0.460938 5 73 | 104 h 0.461914 0.466797 5 74 | 105 i 0.467773 0.46875 1 75 | 106 j 0.469727 0.472656 3 76 | 107 k 0.473633 0.478516 5 77 | 108 l 0.479492 0.480469 1 78 | 109 m 0.481445 0.490234 9 79 | 110 n 0.491211 0.496094 5 80 | 111 o 0.49707 0.501953 5 81 | 112 p 0.50293 0.507813 5 82 | 113 q 0.508789 0.513672 5 83 | 114 r 0.514648 0.517578 3 84 | 115 s 0.518555 0.523438 5 85 | 116 t 0.524414 0.527344 3 86 | 117 u 0.52832 0.533203 5 87 | 118 v 0.53418 0.539063 5 88 | 119 w 0.540039 0.548828 9 89 | 120 x 0.549805 0.554688 5 90 | 121 y 0.555664 0.560547 5 91 | 122 z 0.561523 0.566406 5 92 | 123 { 0.567383 0.570313 3 93 | 124 | 0.571289 0.572266 1 94 | 125 } 0.573242 0.576172 3 95 | 126 ~ 0.577148 0.583984 7 96 | -------------------------------------------------------------------------------- /Emerald/EEListView.cpp: -------------------------------------------------------------------------------- 1 | #include "EEListView.h" 2 | 3 | //---------------------------------------------------------------------------------------------------- 4 | namespace Emerald 5 | { 6 | // EEListView 7 | //---------------------------------------------------------------------------------------------------- 8 | EEListView::EEListView() 9 | : 10 | EEScrollView() 11 | { 12 | SetContent(&m_list); 13 | } 14 | 15 | //---------------------------------------------------------------------------------------------------- 16 | EEListView::EEListView(const Rect_Float& _area) 17 | : 18 | EEScrollView(_area) 19 | { 20 | SetContent(&m_list); 21 | } 22 | 23 | //---------------------------------------------------------------------------------------------------- 24 | EEListView::EEListView(const EEListView& _listView) 25 | : 26 | EEScrollView(_listView) 27 | { 28 | } 29 | 30 | //---------------------------------------------------------------------------------------------------- 31 | EEListView::~EEListView() 32 | { 33 | 34 | } 35 | 36 | //---------------------------------------------------------------------------------------------------- 37 | bool EEListView::Update() 38 | { 39 | if (!EEScrollView::Update()) 40 | return false; 41 | 42 | return true; 43 | } 44 | 45 | //---------------------------------------------------------------------------------------------------- 46 | bool EEListView::Render() 47 | { 48 | if (!EEScrollView::Render()) 49 | return false; 50 | 51 | return true; 52 | } 53 | 54 | //---------------------------------------------------------------------------------------------------- 55 | bool EEListView::Process() 56 | { 57 | return EEObject::Process(); 58 | } 59 | 60 | //---------------------------------------------------------------------------------------------------- 61 | bool EEListView::AddObject(EEObject* _object) 62 | { 63 | if (m_list.AddObject(_object)) 64 | { 65 | Repull(); 66 | return true; 67 | } 68 | 69 | return false; 70 | } 71 | 72 | //---------------------------------------------------------------------------------------------------- 73 | bool EEListView::AddObjectAt(EEObject* _object, int _index) 74 | { 75 | if (m_list.AddObjectAt(_object, _index)) 76 | { 77 | Repull(); 78 | return true; 79 | } 80 | 81 | return false; 82 | } 83 | 84 | //---------------------------------------------------------------------------------------------------- 85 | bool EEListView::RemoveObject(EEObject* _object) 86 | { 87 | if (m_list.RemoveObject(_object)) 88 | { 89 | Repull(); 90 | return true; 91 | } 92 | 93 | return false; 94 | } 95 | 96 | //---------------------------------------------------------------------------------------------------- 97 | bool EEListView::RemoveObjectAt(int _index) 98 | { 99 | if (m_list.RemoveObjectAt(_index)) 100 | { 101 | Repull(); 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | //---------------------------------------------------------------------------------------------------- 109 | bool EEListView::SetContent(EEObject* _content) 110 | { 111 | return EEScrollView::SetContent(_content); 112 | } 113 | } -------------------------------------------------------------------------------- /Emerald/EEList.cpp: -------------------------------------------------------------------------------- 1 | #include "EEList.h" 2 | 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | // EEList 8 | //---------------------------------------------------------------------------------------------------- 9 | EEList::EEList() 10 | : 11 | EEObject() 12 | { 13 | 14 | } 15 | 16 | //---------------------------------------------------------------------------------------------------- 17 | EEList::EEList(const EEList &_list) 18 | : 19 | EEObject(_list), 20 | m_objects(m_objects) 21 | { 22 | 23 | } 24 | 25 | //---------------------------------------------------------------------------------------------------- 26 | EEList::~EEList() 27 | { 28 | 29 | } 30 | 31 | //---------------------------------------------------------------------------------------------------- 32 | bool EEList::Update() 33 | { 34 | if (!EEObject::Update()) 35 | return false; 36 | 37 | for (UINT i = 0; i < m_objects.size(); ++i) 38 | { 39 | m_objects[i].anchor->Update(); 40 | m_objects[i].content->Update(); 41 | } 42 | 43 | return true; 44 | } 45 | 46 | //---------------------------------------------------------------------------------------------------- 47 | bool EEList::Render() 48 | { 49 | if (!EEObject::Render()) 50 | return false; 51 | 52 | for (UINT i = 0; i < m_objects.size(); ++i) 53 | { 54 | m_objects[i].anchor->Render(); 55 | m_objects[i].content->Render(); 56 | } 57 | 58 | return true; 59 | } 60 | 61 | //---------------------------------------------------------------------------------------------------- 62 | bool EEList::AddObject(EEObject* _object) 63 | { 64 | if (_object) 65 | { 66 | if (m_objects.size()) 67 | { 68 | EEObject *lastAnchor = m_objects.back().anchor; 69 | FLOAT3 position = lastAnchor->GetPosition(); 70 | position.y += lastAnchor->GetOffsetHeight(); 71 | 72 | EEObject *anchor = new EEObject(position); 73 | anchor->SetParent(this); 74 | _object->SetParent(anchor); 75 | m_objects.push_back(EEListItem(anchor, _object)); 76 | } 77 | else 78 | { 79 | EEObject *anchor = new EEObject(); 80 | anchor->SetParent(this); 81 | _object->SetParent(anchor); 82 | m_objects.push_back(EEListItem(anchor, _object)); 83 | } 84 | return true; 85 | } 86 | 87 | return false; 88 | } 89 | 90 | //---------------------------------------------------------------------------------------------------- 91 | bool EEList::AddObjectAt(EEObject* _object, unsigned int _index) 92 | { 93 | if (_object) 94 | { 95 | 96 | return true; 97 | } 98 | 99 | return false; 100 | } 101 | 102 | //---------------------------------------------------------------------------------------------------- 103 | bool EEList::RemoveObject(EEObject* _object) 104 | { 105 | if (_object) 106 | { 107 | 108 | return true; 109 | } 110 | 111 | return false; 112 | } 113 | 114 | //---------------------------------------------------------------------------------------------------- 115 | bool EEList::RemoveObjectAt(unsigned int _index) 116 | { 117 | if (0 <= _index && _index < m_objects.size()) 118 | { 119 | 120 | return true; 121 | } 122 | 123 | return false; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Emerald/EEShader/EEShaderHelper.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _EE_SHADERHELPER_HLSL_ 2 | #define _EE_SHADERHELPER_HLSL_ 3 | 4 | float Saturate(float _input) 5 | { 6 | return min(max(_input, 0), 1); 7 | } 8 | 9 | uint FloatToUint(float _input, float _Scale) 10 | { 11 | return (uint)floor(_input * _Scale + 0.5f); 12 | } 13 | 14 | // float4 -> uint 15 | //---------------------------------------------------------------------------------------------------- 16 | uint Float4ToUint(in float4 _input) 17 | { 18 | uint result = 0; 19 | result += _input.w * 0xff; 20 | result <<= 8; 21 | result += _input.z * 0xff; 22 | result <<= 8; 23 | result += _input.y * 0xff; 24 | result <<= 8; 25 | result += _input.x * 0xff; 26 | return result; 27 | } 28 | 29 | // uint -> float4 30 | //---------------------------------------------------------------------------------------------------- 31 | float4 UintToFloat4(in uint _input) 32 | { 33 | //_input format is A8B8G8R8 in RWTexture2D load mode, but why? 34 | float4 result; 35 | result.x = (float)(_input & 0xff) / 0xff; 36 | _input >>= 8; 37 | result.y = (float)(_input & 0xff) / 0xff; 38 | _input >>= 8; 39 | result.z = (float)(_input & 0xff) / 0xff; 40 | _input >>= 8; 41 | result.w = (float)(_input & 0xff) / 0xff; 42 | return result; 43 | } 44 | 45 | // uint -> float4 46 | //---------------------------------------------------------------------------------------------------- 47 | void UintToFloat4(in uint _input, out float4 _result) 48 | { 49 | _result.x = (float)(_input & 0xff) / 0xff; 50 | _input >>= 8; 51 | _result.y = (float)(_input & 0xff) / 0xff; 52 | _input >>= 8; 53 | _result.z = (float)(_input & 0xff) / 0xff; 54 | _input >>= 8; 55 | _result.w = (float)(_input & 0xff) / 0xff; 56 | } 57 | 58 | // float4 -> unorm 59 | //---------------------------------------------------------------------------------------------------- 60 | uint Float4ToUnorm(in float4 _input) 61 | { 62 | uint result; 63 | result = 64 | ((FloatToUint(Saturate(_input.r), 255)) | 65 | (FloatToUint(Saturate(_input.g), 255) << 8) | 66 | (FloatToUint(Saturate(_input.b), 255) << 16) | 67 | (FloatToUint(Saturate(_input.a), 255) << 24)); 68 | return result; 69 | } 70 | 71 | // unorm -> float4 72 | //---------------------------------------------------------------------------------------------------- 73 | float4 UnormToFloat4(in uint _input) 74 | { 75 | float4 result; 76 | result.x = (FLOAT)(_input & 0x000000ff) / 255; 77 | result.y = (FLOAT)(((_input >> 8) & 0x000000ff)) / 255; 78 | result.z = (FLOAT)(((_input >> 16) & 0x000000ff)) / 255; 79 | result.w = (FLOAT)(_input >> 24) / 255; 80 | return result; 81 | } 82 | 83 | //---------------------------------------------------------------------------------------------------- 84 | uint2 Float2ToUint2(in float2 _input, in uint _width, in uint _height) 85 | { 86 | return uint2(_input.x * _width, _input.y * _height); 87 | } 88 | 89 | //---------------------------------------------------------------------------------------------------- 90 | void Float2ToUint2(in float2 _input, in uint _width, in uint _height, out uint2 _result) 91 | { 92 | _result.x = _input.x * _width; 93 | _result.y = _input.y * _height; 94 | } 95 | 96 | 97 | //---------------------------------------------------------------------------------------------------- 98 | //cbuffer 99 | //b0 ObjectBuffer 100 | //b1 CameraBuffer 101 | //b2 102 | //b3 (share) 103 | // Quad2DBuffer 104 | // BoxBuffer 105 | 106 | 107 | #endif -------------------------------------------------------------------------------- /Emerald/EESlide.cpp: -------------------------------------------------------------------------------- 1 | #include "EESlide.h" 2 | #include "EECore.h" 3 | 4 | //---------------------------------------------------------------------------------------------------- 5 | namespace Emerald 6 | { 7 | //EESlide 8 | //---------------------------------------------------------------------------------------------------- 9 | EESlide::EESlide(const Rect_Float& _rect, float _interval, bool _isLoop) 10 | : 11 | EEQuad2D(_rect), 12 | m_updateTime(-1.0f), 13 | m_changeInterval(_interval), 14 | m_isLoop(_isLoop) 15 | { 16 | SetIsUseColor(false); 17 | SetIsUseTex(true); 18 | } 19 | 20 | //---------------------------------------------------------------------------------------------------- 21 | EESlide::EESlide(const Rect_Float& _rect, EETexture& _texs, float _interval, bool _isLoop) 22 | : 23 | EEQuad2D(_rect, _texs), 24 | m_updateTime(-1.0f), 25 | m_changeInterval(_interval), 26 | m_isLoop(_isLoop) 27 | { 28 | 29 | } 30 | 31 | //---------------------------------------------------------------------------------------------------- 32 | EESlide::EESlide(const Rect_Float& _rect, EETexture* _texs, int _amount, float _interval, bool _isLoop) 33 | : 34 | EEQuad2D(_rect, EETextureCombine(_texs, _amount)), 35 | m_updateTime(-1.0f), 36 | m_changeInterval(_interval), 37 | m_isLoop(_isLoop) 38 | { 39 | 40 | } 41 | 42 | //---------------------------------------------------------------------------------------------------- 43 | EESlide::EESlide(const Rect_Float& _rect, std::vector& _texs, float _interval, bool _isLoop) 44 | : 45 | EEQuad2D(_rect, EETextureCombine(_texs.data(), _texs.size())), 46 | m_updateTime(-1.0f), 47 | m_changeInterval(_interval), 48 | m_isLoop(_isLoop) 49 | { 50 | 51 | } 52 | 53 | //---------------------------------------------------------------------------------------------------- 54 | EESlide::EESlide(const EESlide& _slide) 55 | : 56 | EEQuad2D(_slide), 57 | m_updateTime(_slide.m_updateTime), 58 | m_changeInterval(_slide.m_changeInterval), 59 | m_isLoop(_slide.m_isLoop) 60 | { 61 | 62 | } 63 | 64 | //---------------------------------------------------------------------------------------------------- 65 | bool EESlide::Update() 66 | { 67 | if (!EEObject::Update()) 68 | return false; 69 | 70 | if (m_updateTime < 0.0f) 71 | m_updateTime = (float)EECore::s_EECore->GetTotalTime(); 72 | if (m_changeInterval <= 0.0f) 73 | m_updateTime = (float)EECore::s_EECore->GetTotalTime(); 74 | else 75 | { 76 | int times = (int)((EECore::s_EECore->GetTotalTime() - m_updateTime) / m_changeInterval); 77 | m_updateTime += m_changeInterval * times; 78 | times += GetTexIndex(); 79 | if (m_isLoop) 80 | SetCurrentSlide(times % m_tex.GetNumber()); 81 | else 82 | { 83 | SetCurrentSlide(times < m_tex.GetNumber() ? times : m_tex.GetNumber() - 1); 84 | } 85 | } 86 | 87 | return EEQuad2D::Update(); 88 | } 89 | 90 | //---------------------------------------------------------------------------------------------------- 91 | bool EESlide::SetCurrentSlide(int _num) 92 | { 93 | return SetTexIndex(_num); 94 | } 95 | 96 | //---------------------------------------------------------------------------------------------------- 97 | void EESlide::SetInterval(float _interval) 98 | { 99 | m_changeInterval = _interval; 100 | } 101 | 102 | //---------------------------------------------------------------------------------------------------- 103 | void EESlide::SetIsLoop(bool _isLoop) 104 | { 105 | m_isLoop = _isLoop; 106 | } 107 | } -------------------------------------------------------------------------------- /Emerald/EEThread.cpp: -------------------------------------------------------------------------------- 1 | #include "EEThread.h" 2 | #include "EECore.h" 3 | 4 | 5 | //---------------------------------------------------------------------------------------------------- 6 | namespace Emerald 7 | { 8 | //EEThread 9 | //---------------------------------------------------------------------------------------------------- 10 | EEThreadSystem::EEThreadSystem() 11 | { 12 | 13 | } 14 | 15 | //---------------------------------------------------------------------------------------------------- 16 | EEThreadSystem::EEThreadSystem(const EEThreadSystem& _system) 17 | { 18 | 19 | } 20 | 21 | //---------------------------------------------------------------------------------------------------- 22 | bool EEThreadSystem::Initialize() 23 | { 24 | 25 | return true; 26 | } 27 | 28 | //---------------------------------------------------------------------------------------------------- 29 | void EEThreadSystem::Shutdown() 30 | { 31 | for (boost::thread* thread : m_threads) 32 | { 33 | thread->interrupt(); 34 | thread->join(); 35 | delete thread; 36 | } 37 | m_threads.clear(); 38 | } 39 | 40 | //---------------------------------------------------------------------------------------------------- 41 | bool EEThreadSystem::AddThread(boost::thread* _thread) 42 | { 43 | if (_thread) 44 | { 45 | m_threads.push_back(_thread); 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | //---------------------------------------------------------------------------------------------------- 53 | bool EEThreadSystem::RemoveThread(boost::thread* _thread) 54 | { 55 | auto it = std::find(m_threads.begin(), m_threads.end(), _thread); 56 | if (it != m_threads.end()) 57 | { 58 | (*it)->interrupt(); 59 | delete *it; 60 | m_threads.erase(it); 61 | return true; 62 | } 63 | 64 | return false; 65 | } 66 | 67 | //---------------------------------------------------------------------------------------------------- 68 | bool EEThreadSystem::RemoveThread() 69 | { 70 | for (boost::thread* thread : m_threads) 71 | { 72 | thread->interrupt(); 73 | thread->join(); 74 | delete thread; 75 | } 76 | m_threads.clear(); 77 | 78 | return true; 79 | } 80 | 81 | //---------------------------------------------------------------------------------------------------- 82 | void EEThreadSystem::JoinAll() 83 | { 84 | for (auto it = m_threads.begin(), end = m_threads.end(); it != end; ++it) 85 | { 86 | (*it)->join(); 87 | } 88 | } 89 | 90 | //EEThread_APIs 91 | //---------------------------------------------------------------------------------------------------- 92 | void EEThreadSleep(int _millisecs) 93 | { 94 | boost::this_thread::sleep(boost::posix_time::milliseconds(_millisecs)); 95 | } 96 | 97 | //---------------------------------------------------------------------------------------------------- 98 | bool EEAddThread(boost::thread* _thread) { return EECore::s_EECore->GetEEThreadSystem()->AddThread(_thread); } 99 | 100 | //---------------------------------------------------------------------------------------------------- 101 | bool EERemoveThread(boost::thread* _thread) { return EECore::s_EECore->GetEEThreadSystem()->RemoveThread(_thread); } 102 | 103 | //---------------------------------------------------------------------------------------------------- 104 | bool EERemoveThread() { return EECore::s_EECore->GetEEThreadSystem()->RemoveThread(); } 105 | 106 | //---------------------------------------------------------------------------------------------------- 107 | void EEJoinAll() { EECore::s_EECore->GetEEThreadSystem()->JoinAll(); } 108 | } -------------------------------------------------------------------------------- /Emerald/EESmartPtr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _EE_SMARTPTR_H_ 3 | #define _EE_SMARTPTR_H_ 4 | 5 | 6 | //---------------------------------------------------------------------------------------------------- 7 | namespace Emerald 8 | { 9 | //EESmartPtr 10 | //---------------------------------------------------------------------------------------------------- 11 | template 12 | class EESmartPtr 13 | { 14 | public: 15 | //---------------------------------------------------------------------------------------------------- 16 | EESmartPtr(_T *_value = nullptr) 17 | : 18 | m_counter(new int(1)), 19 | m_value(_value) 20 | { 21 | // std::cout << "init:" << *m_counter << std::endl; 22 | } 23 | 24 | //---------------------------------------------------------------------------------------------------- 25 | EESmartPtr(const EESmartPtr &_smartPtr) 26 | : 27 | m_counter(_smartPtr.m_counter), 28 | m_value(_smartPtr.m_value) 29 | { 30 | // std::cout << "copy:" << *m_counter << std::endl; 31 | ++*m_counter; 32 | } 33 | 34 | //---------------------------------------------------------------------------------------------------- 35 | virtual ~EESmartPtr() 36 | { 37 | DecCounter(); 38 | } 39 | 40 | //---------------------------------------------------------------------------------------------------- 41 | EESmartPtr& operator= (const EESmartPtr &_smartPtr) 42 | { 43 | DecCounter(); 44 | ++*_smartPtr.m_counter; 45 | 46 | m_counter = _smartPtr.m_counter; 47 | m_value = _smartPtr.m_value; 48 | 49 | return *this; 50 | } 51 | 52 | //---------------------------------------------------------------------------------------------------- 53 | bool operator== (const EESmartPtr &_smartPtr) const 54 | { 55 | return m_counter == _smartPtr.m_counter && m_value == _smartPtr.m_value; 56 | } 57 | 58 | //---------------------------------------------------------------------------------------------------- 59 | bool operator!= (const EESmartPtr &_smartPtr) const 60 | { 61 | return !(*this == _smartPtr); 62 | } 63 | 64 | //---------------------------------------------------------------------------------------------------- 65 | bool operator< (const EESmartPtr &_smartPtr) const 66 | { 67 | return m_value < _smartPtr.m_value; 68 | } 69 | 70 | //---------------------------------------------------------------------------------------------------- 71 | _T* operator-> () 72 | { 73 | return m_value; 74 | } 75 | 76 | //---------------------------------------------------------------------------------------------------- 77 | _T& operator* () 78 | { 79 | return *m_value; 80 | } 81 | 82 | //---------------------------------------------------------------------------------------------------- 83 | operator bool () 84 | { 85 | return m_value ? true : false; 86 | } 87 | 88 | // Dangerous 89 | //---------------------------------------------------------------------------------------------------- 90 | /* 91 | operator _T* () 92 | { 93 | return m_value; 94 | } 95 | */ 96 | 97 | 98 | protected: 99 | void SetValue(_T *_value) 100 | { 101 | DecCounter(); 102 | 103 | m_counter = new int(1); 104 | m_value = _value; 105 | } 106 | 107 | void DecCounter() 108 | { 109 | if (--*m_counter == 0) 110 | { 111 | // std::cout << "delete:" << *m_counter << std::endl; 112 | delete m_counter; 113 | m_counter = nullptr; 114 | if (m_value) 115 | { 116 | delete m_value; 117 | //m_value->Release(); 118 | m_value = nullptr; 119 | } 120 | } 121 | } 122 | 123 | protected: 124 | int *m_counter; 125 | _T *m_value; 126 | }; 127 | } 128 | 129 | #endif --------------------------------------------------------------------------------