Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   ==============================================================================
  3.  
  4.   This is an automatically generated GUI class created by the Introjucer!
  5.  
  6.   Be careful when adding custom code to these files, as only the code within
  7.   the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  8.   and re-saved.
  9.  
  10.   Created with Introjucer version: 3.1.1
  11.  
  12.   ------------------------------------------------------------------------------
  13.  
  14.   The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  15.   Copyright 2004-13 by Raw Material Software Ltd.
  16.  
  17.   ==============================================================================
  18. */
  19.  
  20. #ifndef __JUCE_HEADER_F4EEA1EAFD405FD4__
  21. #define __JUCE_HEADER_F4EEA1EAFD405FD4__
  22.  
  23. //[Headers]     -- You can add your own extra header files here --
  24. #include "JuceHeader.h"
  25. #include "CPIComponent.h"
  26. #include "WavefrontObjParser.h"
  27.  
  28.  
  29. struct Attributes;
  30. struct Uniforms;
  31. struct Shape;
  32.  
  33. struct DemoTexture
  34. {
  35.     virtual ~DemoTexture() {}
  36.     virtual bool applyTo(OpenGLTexture&) = 0;
  37.  
  38.     String name;
  39. };
  40.  
  41. //struct BackgroundStar;
  42. //struct SlowerBouncingNumber;
  43.  
  44.  
  45. struct BouncingNumber
  46. {
  47.     BouncingNumber()
  48.         : speed(0.0004 + 0.0007 * Random::getSystemRandom().nextDouble()),
  49.         phase(Random::getSystemRandom().nextDouble())
  50.     {
  51.     }
  52.  
  53.     float getValue() const
  54.     {
  55.         double v = fmod(phase + speed * Time::getMillisecondCounterHiRes(), 2.0);
  56.         return (float)(v >= 1.0 ? (2.0 - v) : v);
  57.     }
  58.  
  59. protected:
  60.     double speed, phase;
  61. };
  62.  
  63. struct SlowerBouncingNumber : public BouncingNumber
  64. {
  65.     SlowerBouncingNumber()
  66.     {
  67.         speed *= 0.3;
  68.     }
  69. };
  70.  
  71. struct BackgroundStar
  72. {
  73.     SlowerBouncingNumber x, y, hue, angle;
  74. };
  75.  
  76.  
  77. static Image resizeImageToPowerOfTwo(Image image)
  78. {
  79.     if (!(isPowerOfTwo(image.getWidth()) && isPowerOfTwo(image.getHeight())))
  80.         return image.rescaled(jmin(1024, nextPowerOfTwo(image.getWidth())),
  81.             jmin(1024, nextPowerOfTwo(image.getHeight())));
  82.  
  83.     return image;
  84. }
  85.  
  86.  
  87. struct BuiltInTexture : public DemoTexture
  88. {
  89.     BuiltInTexture(const char* nm, const void* imageData, size_t imageSize)
  90.         : image(resizeImageToPowerOfTwo(ImageFileFormat::loadFrom(imageData, imageSize)))
  91.     {
  92.         name = nm;
  93.     }
  94.  
  95.     Image image;
  96.  
  97.     bool applyTo(OpenGLTexture& texture)
  98.     {
  99.         texture.loadImage(image);
  100.         return false;
  101.     }
  102. };
  103. //[/Headers]
  104.  
  105.  
  106.  
  107. //==============================================================================
  108. /**
  109.                                                                     //[Comments]
  110.     An auto-generated component, created by the Introjucer.
  111.  
  112.     Describe your class and how it works here!
  113.                                                                     //[/Comments]
  114. */
  115. class HeadAnimation  : public CPIComponent,
  116.                        private OpenGLRenderer
  117. {
  118. public:
  119.     //==============================================================================
  120.     HeadAnimation ();
  121.     ~HeadAnimation();
  122.  
  123.     //==============================================================================
  124.     //[UserMethods]     -- You can add your own custom methods in this section.
  125.     //[/UserMethods]
  126.  
  127.     void paint (Graphics& g);
  128.     void resized();
  129.  
  130.  
  131.  
  132. private:
  133.     //[UserVariables]   -- You can add your own custom variables in this section.
  134.  
  135.     void renderOpenGL();
  136.     void newOpenGLContextCreated();
  137.     void openGLContextClosing();
  138.     void freeAllContextObjects();
  139.     void setTexture(DemoTexture* t);
  140.  
  141.     Matrix3D<float> getProjectionMatrix() const;
  142.     Matrix3D<float> getViewMatrix() const;
  143.     void updateShader();
  144.     void drawBackground2DStuff(float desktopScale);
  145.     void selectTexture(int itemID);
  146.     void setShaderProgram(const String& vertexShader, const String& fragmentShader);
  147.  
  148.     ScopedPointer<OpenGLShaderProgram> shader;
  149.     ScopedPointer<Shape> shape;
  150.     ScopedPointer<Attributes> attributes;
  151.     ScopedPointer<Uniforms> uniforms;
  152.  
  153.     OpenGLContext openGLContext;
  154.  
  155.     OpenGLTexture texture;
  156.     DemoTexture* textureToUse, *lastTexture;
  157.  
  158.     String newVertexShader, newFragmentShader;
  159.     CodeDocument vertexDocument, fragmentDocument;
  160.  
  161.     float scale, rotationSpeed;
  162.     float rotation;
  163.     Draggable3DOrientation draggableOrientation;
  164.     BackgroundStar stars[3];
  165.     bool doBackgroundDrawing;
  166.  
  167.     OwnedArray<DemoTexture> textures;
  168.  
  169.     BouncingNumber bouncingNumber;
  170.  
  171.     ScopedPointer<OpenGLShaderProgram::Attribute> position, normal, sourceColour, textureCoordIn;
  172.     //HeadAnimation& demo;
  173.  
  174.     //[/UserVariables]
  175.  
  176.     //==============================================================================
  177.  
  178.  
  179.     //==============================================================================
  180.     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HeadAnimation)
  181. };
  182.  
  183. //[EndFile] You can add extra defines here...
  184. //[/EndFile]
  185.  
  186. #endif   // __JUCE_HEADER_F4EEA1EAFD405FD4__
Advertisement
RAW Paste Data Copied
Advertisement