5.4.1. New lightshow.h file

A new lightshow.h file is required because the lightshow applet is used by the lotion main.cpp code. Example 5.19 lists the new header file:

Example 5.19. New lightshow.h code

#ifndef __LIGHTSHOW_APPLET_H__
#define __LIGHTSHOW_APPLET_H__

#include "../../lotion.h"
#include "../../applet.h"
#include "../../application.h"
#include "../../theme.h"

namespace Lotion    // was namespace MDE in the original lightshow app
{
    namespace Applets
    {
        // lightshow is now an applet class
        class LightShow: public Applet
        {
            MDE::Buffer* flareTexcoord; // this was in the original lightshow app
            GLint flareTexcoordsLoc;    // this was in the original lightshow app

            bool useWireframe;
            bool styggShader;
            int lightCount;

            MDE::SceneAsset* scene;
            MDE::Program* flarePrg;
            MDE::Program* prg_gl2;
            MDE::Program* prg_gl1;

            MDE::NodeAsset* camNode;
            MDE::NodeAsset* targetNode;
            MDE::NodeAsset* light0Node;
            MDE::NodeAsset* light1Node;

            MDE::Texture* flareTex;

            // references to functions that were in the original app
            void prepareFlares(MDE::Context* context, MDE::Program* p);
            void drawFlare(MDE::Context* context, MDE::vec3 position,
                           MDE::vec3 color, float size);
            void traverseTransform(MDE::Tree<MDE::NodeAsset*>* node, 
                                   MDE::mat4 parentTransform, float time);
            void applyMaterial(MDE::MaterialAsset* m, MDE::Context* context);
            void traverseDraw(MDE::Tree<MDE::NodeAsset*>* node, 
                              MDE::Context* context);
            float fract(float v);
            MDE::vec2 angles_for_light(MDE::vec2 cyl_pos, 
                                       float cyl_radius, MDE::vec2 light_position);
            MDE::vec3 calculate_cyl_info(MDE::vec2 cyl_pos, float cyl_radius, 
                                         MDE::vec2 light_position, float light_radius);

            float time;

            // new app must use widgets and radio buttons
            WidgetGroup* wg;
            Widget* exitButton;

            Widgets::Panel* panel; 
            
            RadioButtonGroup* glVersion;
            Widgets::CustomLabel* settingsGlLbl;
            Widgets::RadioButton* gl11Chk;
            Widgets::RadioButton* gl20Chk;

            RadioButtonGroup* renderMode;
            Widgets::CustomLabel* renderLbl;
            Widgets::RadioButton* solidChk;
            Widgets::RadioButton* wireframeChk;

        public:
            // code related to widget creation and associated icons
            virtual String getName() { 
                 return "LightShow Demo"; 
            }
            virtual String getDescription() {
                 return "Light Show Applet."; 
            };
            virtual String getIconThumbDesc() {
                 return "applets/icons/lightshow_small.png"; 
            }
            virtual String getIconFullDesc() {
                 return "applets/icons/lightshow_correct.png"; 
            }

            // initialize the lightshow proxy, context, and assets 
            virtual void onCreate(Widget* w);

            // respond to changed drawing options
            virtual void onValueChanged(Widget* w);

            virtual void draw();
        };
    }
}

#endif

Copyright © 2010 ARM. All rights reserved.ARM DUI 0527A‑02a
Non-Confidential - Draft - BetaID070710