| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #pragma once
- #include <OgreHardwareVertexBuffer.h>
- #include <OgreRenderQueueListener.h>
- #include <OgreRoot.h>
- #include "UiWidget.h"
- /**
- * A sprite.
- */
- class UiSprite : public UiWidget{
- public:
- /**
- * Constructor.
- *
- * @param name[in] The sprite name.
- */
- UiSprite(const Ogre::String& name);
- /**
- * Constructor.
- *
- * @param name[in] The sprinte name.
- * @param path_name[in] Path to the sprite file.
- * @param parent[in] Widget to be set as parent of the sprite.
- * @todo path_name is relative to data? Filename is needed?
- */
- UiSprite(
- const Ogre::String& name, const Ogre::String& path_name,
- UiWidget* parent
- );
- /**
- * Destructor.
- */
- virtual ~UiSprite();
- /**
- * Loads an initializes the sprite.
- */
- void Initialise();
- /**
- * Updates the sprite state.
- */
- virtual void Update();
- /**
- * Renders the sprite.
- */
- virtual void Render();
- /**
- * Updates the sprite state.
- */
- virtual void UpdateTransformation();
- /**
- * Sets the sprite image.
- *
- * @param image[in] @todo file path or just a name?
- */
- void SetImage(const Ogre::String& image);
- /**
- * Sets the vertex shader for the sprite.
- *
- * @param shader[in] The shader to set.
- */
- void SetVertexShader(const Ogre::String& shader);
- /**
- * Sets the fragment shader for the sprite.
- *
- * @param shader[in] The shader to set.
- */
- void SetFragmentShader(const Ogre::String& shader);
- /**
- * Recalculates the sprite geometry.
- */
- void UpdateGeometry();
- private:
- /**
- * Constructor.
- */
- UiSprite();
- /**
- * Creates a vertex buffer for the sprite.
- */
- void CreateVertexBuffer();
- /**
- * Destroys a vertex buffer for the sprite.
- */
- void DestroyVertexBuffer();
- /**
- * The sprite material.
- */
- Ogre::MaterialPtr material_;
- /**
- * The scene manager.
- */
- Ogre::SceneManager* scene_manager_;
- /**
- * The render system.
- */
- Ogre::RenderSystem* render_system_;
- /**
- * The render operation.
- */
- Ogre::RenderOperation render_operation_;
- /**
- * The vertex buffer.
- */
- Ogre::HardwareVertexBufferSharedPtr vertex_buffer_;
- };
|