diff options
Diffstat (limited to 'source/modules/asura-core')
20 files changed, 104 insertions, 194 deletions
diff --git a/source/modules/asura-core/graphics/canvas.h b/source/modules/asura-core/graphics/canvas.h index 4175561..5c11706 100644 --- a/source/modules/asura-core/graphics/canvas.h +++ b/source/modules/asura-core/graphics/canvas.h @@ -53,18 +53,14 @@ namespace AsuraEngine uint mWidth, mHeight; - public: - - //----------------------------------------------------------------------------// + luaxport: - LUAX_DECL_FACTORY(Canvas); + LUAX_DECL_FACTORY(Canvas, RenderTarget); LUAX_DECL_METHOD(_SetSize); LUAX_DECL_METHOD(_Bind); LUAX_DECL_METHOD(_Unbind); - //----------------------------------------------------------------------------// - }; /// diff --git a/source/modules/asura-core/graphics/color.h b/source/modules/asura-core/graphics/color.h index ababcf7..b29c43f 100644 --- a/source/modules/asura-core/graphics/color.h +++ b/source/modules/asura-core/graphics/color.h @@ -42,7 +42,7 @@ namespace AsuraEngine float r, g, b, a; - //----------------------------------------------------------------------------// + luaxport: LUAX_DECL_FACTORY(Color); @@ -61,8 +61,6 @@ namespace AsuraEngine LUAX_DECL_METHOD(___mul); // __mul LUAX_DECL_METHOD(___div); // __div - //----------------------------------------------------------------------------// - }; } diff --git a/source/modules/asura-core/graphics/color32.h b/source/modules/asura-core/graphics/color32.h index 5b10931..9f14155 100644 --- a/source/modules/asura-core/graphics/color32.h +++ b/source/modules/asura-core/graphics/color32.h @@ -20,8 +20,6 @@ namespace AsuraEngine { public: - LUAX_DECL_FACTORY(Color32); - static const uint32 RMASK; static const uint32 GMASK; static const uint32 BMASK; @@ -41,10 +39,12 @@ namespace AsuraEngine byte r, g, b, a; - LUAX_DECL_METHOD(_ToColor); + luaxport: - LUAX_DECL_METHOD(_SetColor); + LUAX_DECL_FACTORY(Color32); + LUAX_DECL_METHOD(_ToColor); + LUAX_DECL_METHOD(_SetColor); LUAX_DECL_METHOD(_GetColor); LUAX_DECL_METHOD(_GetRed); LUAX_DECL_METHOD(_GetGreen); diff --git a/source/modules/asura-core/graphics/gfx_device.cpp b/source/modules/asura-core/graphics/gfx_device.cpp index edfa784..c520127 100644 --- a/source/modules/asura-core/graphics/gfx_device.cpp +++ b/source/modules/asura-core/graphics/gfx_device.cpp @@ -32,6 +32,11 @@ namespace AsuraEngine { } + GfxDevice& GfxDevice::Get() + { + return gfx; + } + static bool inited = false; bool GfxDevice::Init(const AEMath::Recti& view) @@ -122,8 +127,6 @@ namespace AsuraEngine #endif } - //------------------------------------------------------------------------------// - void GfxDevice::SetMatrixMode(MatrixMode mode) { state.matrixMode = mode; @@ -191,7 +194,5 @@ namespace AsuraEngine return state.matrix[state.matrixMode].GetTopIndex(); } - //------------------------------------------------------------------------------// - - } -}
\ No newline at end of file + } // Graphics +} // AsuraEngine
\ No newline at end of file diff --git a/source/modules/asura-core/graphics/gfx_device.h b/source/modules/asura-core/graphics/gfx_device.h index c93717f..3c5b383 100644 --- a/source/modules/asura-core/graphics/gfx_device.h +++ b/source/modules/asura-core/graphics/gfx_device.h @@ -33,12 +33,6 @@ namespace AsuraEngine GL_PARAM_MAX_TEXTURE_UNIT = 1, }; - /// - /// OpenGLģһЩopengl״̬١ڱ༭രڻ£һڶӦһhwnd - /// һhdcԼopengl contextʹwglMakeCurrent(hdc, glc)ָǰ̶߳ - /// Ⱦhdcopenglglcglм¼ľһ̵߳һڵһOpenGL - /// ĵ״ֶ̬֧Ⱦ - /// class GfxDevice : public AEScripting::Portable<GfxDevice> { public: @@ -46,6 +40,8 @@ namespace AsuraEngine GfxDevice(); ~GfxDevice(); + static GfxDevice& Get(); + int GetParam(GLParams param); bool Init(const AEMath::Recti& viewport); @@ -54,8 +50,8 @@ namespace AsuraEngine void SetViewport(const AEMath::Recti viewport); const AEMath::Recti& GetViewport(); - void UseShader(Shader* shader); - void UnuseShader(); + void UseShader(Shader* shader); + void UnuseShader(); Shader* GetShader(); void DrawArrays(GLenum mode, GLint first, GLsizei count); @@ -69,16 +65,16 @@ namespace AsuraEngine void Translate(float x, float y); void Scale(float x, float y); void Ortho(float l, float r, float b, float t, float n, float f); - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); uint GetMatrixDepth(); uint GetMatrixIndex(); + AEMath::Matrix44& GetMatrix(MatrixMode mode); + AEMath::Matrix44 GetMVPMatrix(); - void SetDrawColor(float r, float g, float b, float a); + void SetDrawColor(float r, float g, float b, float a); Color& GetDrawColor(); - void WipeError(); - bool HasError(); + void WipeError(); + bool HasError(); GLenum GetError(); struct @@ -103,7 +99,7 @@ namespace AsuraEngine friend class Profiler; - //----------------------------------------------------------------------------// + luaxport: LUAX_DECL_SINGLETON(GfxDevice); @@ -121,17 +117,12 @@ namespace AsuraEngine LUAX_DECL_METHOD(_Ortho); LUAX_DECL_METHOD(_GetMatrixDepth); LUAX_DECL_METHOD(_GetMatrixIndex); - LUAX_DECL_METHOD(_UseShader); LUAX_DECL_METHOD(_UnuseShader); - //----------------------------------------------------------------------------// - }; - /// - /// OpenGL - /// + // ȫgfx device extern GfxDevice gfx; } diff --git a/source/modules/asura-core/graphics/gpu_buffer.cpp b/source/modules/asura-core/graphics/gpu_buffer.cpp index 4c84b7e..8d6f491 100644 --- a/source/modules/asura-core/graphics/gpu_buffer.cpp +++ b/source/modules/asura-core/graphics/gpu_buffer.cpp @@ -71,13 +71,12 @@ namespace AsuraEngine return false; if (mBuffer == 0) { - // ʼ gfx.WipeError(); glGenBuffers(1, &mBuffer); if (mBuffer == 0) throw Exception("OpenGL glGenBuffers failed."); glBindBuffer(mTarget, mBuffer); - glBufferData(mTarget, mSize, NULL, mUsage); // ʼСΪsizeĻ壬usageŵӦԴ + glBufferData(mTarget, mSize, NULL, mUsage); if (gfx.HasError()) { glBindBuffer(mTarget, 0); @@ -98,7 +97,6 @@ namespace AsuraEngine } glBindBuffer(mTarget, 0); #if ASURA_DEBUG - // һݣ memcpy(mData + offset, data, size); #endif return true; diff --git a/source/modules/asura-core/graphics/gpu_buffer.h b/source/modules/asura-core/graphics/gpu_buffer.h index 9013619..f4f518f 100644 --- a/source/modules/asura-core/graphics/gpu_buffer.h +++ b/source/modules/asura-core/graphics/gpu_buffer.h @@ -44,44 +44,18 @@ namespace AsuraEngine static size_t GetDataTypeSize(GLenum datatype); - /// - /// ʼ\»棬ûgpu bufferԴΪdzʼΪǸ¡ - /// bool Fill(const void* data, size_t size, uint offset = 0) ASURA_THROW(Exception); - /// - /// ӦĿϣͿʹˡ - /// void Bind(); void UnBind(); - /// - /// bufferĴС(Byte) - /// uint GetBufferSize(); - /// - /// bufferԪظ=size/datatypesize - /// uint GetBufferCount(); GLenum GetDataType(); size_t GetDataTypeSize(); private: - //----------------------------------------------------------------------------// - - LUAX_DECL_ABSTRACT_FACTORY(GPUBuffer); - - LUAX_DECL_ENUM(BufferType, 1); - LUAX_DECL_ENUM(BufferUsage, 1); - LUAX_DECL_ENUM(BufferDataType, 2); - - LUAX_DECL_METHOD(_Fill); - LUAX_DECL_METHOD(_GetSize); - LUAX_DECL_METHOD(_GetCount); - - //----------------------------------------------------------------------------// - GLenum ConvertBufferType(BufferType type); GLenum ConvertBufferUsage(BufferUsage type); GLenum ConvertBufferDataType(BufferDataType type); @@ -99,12 +73,21 @@ namespace AsuraEngine uint mSize; #if ASURA_DEBUG - /// - /// رbufferݣԴݱһ£ԺԴ档 - /// byte* mData; #endif + luaxport: + + LUAX_DECL_ABSTRACT_FACTORY(GPUBuffer); + + LUAX_DECL_ENUM(BufferType, 1); + LUAX_DECL_ENUM(BufferUsage, 1); + LUAX_DECL_ENUM(BufferDataType, 2); + + LUAX_DECL_METHOD(_Fill); + LUAX_DECL_METHOD(_GetSize); + LUAX_DECL_METHOD(_GetCount); + }; } diff --git a/source/modules/asura-core/graphics/image.cpp b/source/modules/asura-core/graphics/image.cpp index 42fc2ab..ef01730 100644 --- a/source/modules/asura-core/graphics/image.cpp +++ b/source/modules/asura-core/graphics/image.cpp @@ -101,5 +101,5 @@ namespace AsuraEngine return mHeight; } - } -}
\ No newline at end of file + } // Graphics +} // AsuraEngine
\ No newline at end of file diff --git a/source/modules/asura-core/graphics/image.h b/source/modules/asura-core/graphics/image.h index 8e3e7d3..d7cd37f 100644 --- a/source/modules/asura-core/graphics/image.h +++ b/source/modules/asura-core/graphics/image.h @@ -24,40 +24,26 @@ namespace AsuraEngine namespace Graphics { - /// - /// ImageͼƬڴȡϷĽһImageڴ桢Դֻᱣһ - /// ݣҪimageêλãźתǶȣʹsprite - /// һֻࡣҪǿǵeditorengineʹòͬķװImageֻṩȾʱҪ - /// sampler2Dϸ˵ImageأӦImageṩFrameworkУ - /// Ⱦʵspritespriteṩ˶ݺͷ任 - /// - class Image ASURA_FINAL - : public AEScripting::Portable<Image, Texture> + class Image ASURA_FINAL : public AEScripting::Portable<Image, Texture> { public: Image(); - ~Image(); - /// - /// ͼύGPUϢ¹imageʹglTexImage2D - /// ύimageݡ - /// bool Load(AEImage::ImageData* decodeData); bool Load(AEImage::ImageData* decodeData, const AEMath::Vector2i& pos); uint GetWidth(); uint GetHeight(); - /// - /// һgpu buffer䶥positionݺUV. - /// GPUBuffer* GenGPUBuffer(); private: - //----------------------------------------------------------------------------// + uint32 mWidth, mHeight; + + luaxport: LUAX_DECL_FACTORY(Image, Texture); @@ -69,18 +55,10 @@ namespace AsuraEngine LUAX_DECL_METHOD(_GetPixel); LUAX_DECL_METHOD(_Render); - //----------------------------------------------------------------------------// - - uint32 mWidth, mHeight; - -#if ASURA_EDITOR - -#endif - }; - } -} + } // Graphics +} // AsuraEngine namespace AEGraphics = AsuraEngine::Graphics; diff --git a/source/modules/asura-core/graphics/index_buffer.h b/source/modules/asura-core/graphics/index_buffer.h index ac77162..c5d2e9e 100644 --- a/source/modules/asura-core/graphics/index_buffer.h +++ b/source/modules/asura-core/graphics/index_buffer.h @@ -24,6 +24,8 @@ namespace AsuraEngine private: + luaxport: + LUAX_DECL_FACTORY(IndexBuffer); LUAX_DECL_METHOD(_New); diff --git a/source/modules/asura-core/graphics/matrix_stack.h b/source/modules/asura-core/graphics/matrix_stack.h index 1a318fa..ae983e7 100644 --- a/source/modules/asura-core/graphics/matrix_stack.h +++ b/source/modules/asura-core/graphics/matrix_stack.h @@ -27,9 +27,6 @@ namespace AsuraEngine MatrixStack(); ~MatrixStack(); - /// - /// ջԪصIJֻͨºʵ - /// void LoadIdentity(); bool Push(); bool Pop(); @@ -40,39 +37,19 @@ namespace AsuraEngine void LoadMatrix(const AEMath::Matrix44& mat44); void MultMatrix(const AEMath::Matrix44& mat44); - /// - /// 任 - /// void Rotate(float angle); void Translate(float x, float y); void Scale(float x, float y); - /// - /// ͶӰ任 - /// void Ortho(float l, float r, float b, float t, float n, float f); - //void Perspective(float fov, float aspect, float near, float far); - //void Frustum(float left, float right, float top, float bottom, float near, float far); - //void LookAt(float x, float y, float z, float cx, float cy, float cz, float ux, float uy, float uz); - /// - /// ջΧ0~ASURA_MAX_MATRIX_STACK_DEPTH-1 - /// uint GetTopIndex(); - - /// - /// ջASURA_MAX_MATRIX_STACK_DEPTH - /// uint GetCapacity(); private: AEMath::Matrix44 mStack[ASURA_MAX_MATRIX_STACK_DEPTH]; - - /// - /// ջ0~ASURA_MAX_MATRIX_STACK_DEPTH-1 - /// - uint8 top; + uint8 top; }; diff --git a/source/modules/asura-core/graphics/mesh2d.h b/source/modules/asura-core/graphics/mesh2d.h index f2770e1..5330967 100644 --- a/source/modules/asura-core/graphics/mesh2d.h +++ b/source/modules/asura-core/graphics/mesh2d.h @@ -37,15 +37,14 @@ namespace AsuraEngine private: + VertexBuffer* mVBO; ///< vertex buffer + IndexBuffer* mIBO; ///< index buffer + + luaxport: + LUAX_DECL_FACTORY(Mesh2D); LUAX_DECL_METHOD(_SetVertex); - - /// - /// mesh2d dataйvertex bufferindex buffer - /// - VertexBuffer* mVBO; - IndexBuffer* mIBO; }; diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h index f4553ec..61aa6f1 100644 --- a/source/modules/asura-core/graphics/shader.h +++ b/source/modules/asura-core/graphics/shader.h @@ -71,7 +71,17 @@ namespace AsuraEngine private: - //----------------------------------------------------------------------------// + bool CompileVertexShader(const std::string& vert, std::string& outError); + bool CompileFragementShader(const std::string& frag, std::string& outError); + + std::string GetProgramWarnings(); + std::string GetShaderWarnings(GLuint shader); + + GLuint mProgram; + GLuint mVertShader; + GLuint mFragShader; + + luaxport: LUAX_DECL_FACTORY(Shader); @@ -93,20 +103,9 @@ namespace AsuraEngine LUAX_DECL_METHOD(_SetBuiltInUniforms); - //----------------------------------------------------------------------------// - - bool CompileVertexShader(const std::string& vert, std::string& outError); - bool CompileFragementShader(const std::string& frag, std::string& outError); - - std::string GetProgramWarnings(); - std::string GetShaderWarnings(GLuint shader); - - GLuint mProgram; - GLuint mVertShader; - GLuint mFragShader; - }; + // ڱһGPU typedef Shader GpuProgram; } diff --git a/source/modules/asura-core/graphics/sprite_batch.h b/source/modules/asura-core/graphics/sprite_batch.h index 17ecb40..b517334 100644 --- a/source/modules/asura-core/graphics/sprite_batch.h +++ b/source/modules/asura-core/graphics/sprite_batch.h @@ -24,9 +24,9 @@ namespace AsuraEngine private: - LUAX_DECL_FACTORY(SpriteBatch); - + luaxport: + LUAX_DECL_FACTORY(SpriteBatch); }; diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h index 799227e..7cfddec 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -46,10 +46,10 @@ namespace AsuraEngine /// struct TextureFormat { - GLenum internalformat; // GPUڲʽ + GLenum internalformat; ///< GPUڲʽ - GLenum externalformat; // CPUⲿʽ - GLenum type; // ⲿʽÿchannelֵ + GLenum externalformat; ///< CPUⲿʽ + GLenum type; ///< ⲿʽÿchannelֵ }; /// @@ -81,42 +81,30 @@ namespace AsuraEngine protected: - //----------------------------------------------------------------------------// - - LUAX_DECL_ENUM(ColorFormat, 1); - LUAX_DECL_ENUM(FilterMode, 1); - LUAX_DECL_ENUM(WrapMode, 1); - - LUAX_DECL_METHOD(_SetFilterMode); - LUAX_DECL_METHOD(_SetWrapMode); - LUAX_DECL_METHOD(_GetFilterMode); - LUAX_DECL_METHOD(_GetWrapMode); - LUAX_DECL_METHOD(_IsGenMipmap); - - //----------------------------------------------------------------------------// - /// /// תcolor formatΪtexture format /// TextureFormat ConvertColorFormat(const ColorFormat& colorformat); - //----------------------------------------------------------------------------// - - /// - /// OpenGL - /// GLuint mTex; - FilterMode mMinFilter; FilterMode mMagFilter; - WrapMode mWrapMode; - bool mIsGenMipmap; + LUAX_DECL_ENUM(ColorFormat, 1); + LUAX_DECL_ENUM(FilterMode, 1); + LUAX_DECL_ENUM(WrapMode, 1); + + LUAX_DECL_METHOD(_SetFilterMode); + LUAX_DECL_METHOD(_SetWrapMode); + LUAX_DECL_METHOD(_GetFilterMode); + LUAX_DECL_METHOD(_GetWrapMode); + LUAX_DECL_METHOD(_IsGenMipmap); + }; - using Drawable = Texture; + typedef Texture Drawable; } } diff --git a/source/modules/asura-core/graphics/vertex_buffer.h b/source/modules/asura-core/graphics/vertex_buffer.h index b078c2b..7aad27d 100644 --- a/source/modules/asura-core/graphics/vertex_buffer.h +++ b/source/modules/asura-core/graphics/vertex_buffer.h @@ -25,6 +25,8 @@ namespace AsuraEngine private: + luaxport: + LUAX_DECL_FACTORY(VertexBuffer); LUAX_DECL_METHOD(_New); diff --git a/source/modules/asura-core/image/image_data.h b/source/modules/asura-core/image/image_data.h index c377407..ca459e7 100644 --- a/source/modules/asura-core/image/image_data.h +++ b/source/modules/asura-core/image/image_data.h @@ -49,7 +49,17 @@ namespace AsuraEngine private: - //----------------------------------------------------------------------------// + /// + /// ڵһimage dataʱṩdecoderڼdecodersмѡԡ + /// + static std::list<ImageDecoder*> ImageDecoders; + + /// + /// дݵ + /// + AEThreading::Mutex mMutex; + + luaxport: LUAX_DECL_FACTORY(ImageData); @@ -63,18 +73,6 @@ namespace AsuraEngine LUAX_DECL_METHOD(_DecodeAsync); LUAX_DECL_METHOD(_IsAvailable); - //----------------------------------------------------------------------------// - - /// - /// ڵһimage dataʱṩdecoderڼdecodersмѡԡ - /// - static std::list<ImageDecoder*> ImageDecoders; - - /// - /// дݵ - /// - AEThreading::Mutex mMutex; - }; } diff --git a/source/modules/asura-core/image/image_decode_task.h b/source/modules/asura-core/image/image_decode_task.h index fc695fa..5108c23 100644 --- a/source/modules/asura-core/image/image_decode_task.h +++ b/source/modules/asura-core/image/image_decode_task.h @@ -24,7 +24,7 @@ namespace AsuraEngine /// void Invoke(lua_State* invokeThreaad) override; - private: + luaxport: LUAX_DECL_FACTORY(ImageDecodeTask, AEThreading::Task); diff --git a/source/modules/asura-core/input/clipboard.h b/source/modules/asura-core/input/clipboard.h index b3b9a1a..1b7c2b8 100644 --- a/source/modules/asura-core/input/clipboard.h +++ b/source/modules/asura-core/input/clipboard.h @@ -19,16 +19,14 @@ namespace AsuraEngine void SetString(const Text::String& text); - //----------------------------------------------------------------------------// - - LUAX_DECL_SINGLETON(Clipboard); - - //----------------------------------------------------------------------------// - private: ~Clipboard(); + luaxport: + + LUAX_DECL_SINGLETON(Clipboard); + }; }; diff --git a/source/modules/asura-core/input/cursor.h b/source/modules/asura-core/input/cursor.h index d420d66..e3df7ee 100644 --- a/source/modules/asura-core/input/cursor.h +++ b/source/modules/asura-core/input/cursor.h @@ -49,8 +49,6 @@ namespace AsuraEngine { public: - LUAX_DECL_FACTORY(Cursor); - Cursor(Graphics::ImageData& imageData, int hotx, int hoty); Cursor(SystemCursor cursortype); @@ -66,6 +64,10 @@ namespace AsuraEngine SystemCursor mSystemType; CursorImpl* mImpl; + luaxport: + + LUAX_DECL_FACTORY(Cursor); + }; ASURA_ABSTRACT class CursorImpl |