@@ -25,15 +25,51 @@ class Window; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
/** | |||||
Base DGL Application class. | |||||
One application instance is required for creating a window. | |||||
There's no single/global application instance in DGL, and multiple | |||||
windows can share the same app instance. | |||||
In standalone mode an application will automatically quit its | |||||
event-loop when all its windows are closed. | |||||
*/ | |||||
class App | class App | ||||
{ | { | ||||
public: | public: | ||||
/** | |||||
Constructor. | |||||
*/ | |||||
App(); | App(); | ||||
/** | |||||
Destructor. | |||||
*/ | |||||
~App(); | ~App(); | ||||
/** | |||||
Idle function. | |||||
This calls all this app Windows' idle functions and idle callbacks. | |||||
*/ | |||||
void idle(); | void idle(); | ||||
/** | |||||
Run the application event-loop until all Windows are closed. | |||||
@idle() is called at regular intervals. | |||||
*/ | |||||
void exec(); | void exec(); | ||||
/** | |||||
Quit the application. | |||||
This stops the event-loop and closes all Windows. | |||||
*/ | |||||
void quit(); | void quit(); | ||||
/** | |||||
Check if the application is about to quit. | |||||
Returning true means there's no event-loop running at the moment. | |||||
*/ | |||||
bool isQuiting() const noexcept; | bool isQuiting() const noexcept; | ||||
private: | private: | ||||
@@ -20,8 +20,8 @@ | |||||
#include "../distrho/extra/d_leakdetector.hpp" | #include "../distrho/extra/d_leakdetector.hpp" | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Define namespace | |||||
/* Define namespace */ | |||||
#ifndef DGL_NAMESPACE | #ifndef DGL_NAMESPACE | ||||
# define DGL_NAMESPACE DGL | # define DGL_NAMESPACE DGL | ||||
#endif | #endif | ||||
@@ -30,14 +30,18 @@ | |||||
#define END_NAMESPACE_DGL } | #define END_NAMESPACE_DGL } | ||||
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; | #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; | ||||
/* GL includes */ | |||||
// ----------------------------------------------------------------------- | |||||
// OpenGL includes | |||||
#ifdef DISTRHO_OS_MAC | #ifdef DISTRHO_OS_MAC | ||||
# include "OpenGL/gl.h" | # include "OpenGL/gl.h" | ||||
#else | #else | ||||
# include "GL/gl.h" | # include "GL/gl.h" | ||||
#endif | #endif | ||||
/* missing GL defines */ | |||||
// ----------------------------------------------------------------------- | |||||
// Missing OpenGL defines | |||||
#if defined(GL_BGR_EXT) && ! defined(GL_BGR) | #if defined(GL_BGR_EXT) && ! defined(GL_BGR) | ||||
# define GL_BGR GL_BGR_EXT | # define GL_BGR GL_BGR_EXT | ||||
#endif | #endif | ||||
@@ -53,9 +57,10 @@ | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Base DGL enums | |||||
/* | |||||
* Convenience symbols for ASCII control characters. | |||||
/** | |||||
Convenience symbols for ASCII control characters. | |||||
*/ | */ | ||||
enum Char { | enum Char { | ||||
CHAR_BACKSPACE = 0x08, | CHAR_BACKSPACE = 0x08, | ||||
@@ -63,8 +68,8 @@ enum Char { | |||||
CHAR_DELETE = 0x7F | CHAR_DELETE = 0x7F | ||||
}; | }; | ||||
/* | |||||
* Special (non-Unicode) keyboard keys. | |||||
/** | |||||
Special (non-Unicode) keyboard keys. | |||||
*/ | */ | ||||
enum Key { | enum Key { | ||||
KEY_F1 = 1, | KEY_F1 = 1, | ||||
@@ -94,8 +99,8 @@ enum Key { | |||||
KEY_SUPER | KEY_SUPER | ||||
}; | }; | ||||
/* | |||||
* Keyboard modifier flags. | |||||
/** | |||||
Keyboard modifier flags. | |||||
*/ | */ | ||||
enum Modifier { | enum Modifier { | ||||
MODIFIER_SHIFT = 1 << 0, /**< Shift key */ | MODIFIER_SHIFT = 1 << 0, /**< Shift key */ | ||||
@@ -105,7 +110,11 @@ enum Modifier { | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Base DGL classes | |||||
/** | |||||
Idle callback. | |||||
*/ | |||||
class IdleCallback | class IdleCallback | ||||
{ | { | ||||
public: | public: | ||||
@@ -22,29 +22,71 @@ | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Forward class names | |||||
template<typename> class Line; | template<typename> class Line; | ||||
template<typename> class Rectangle; | template<typename> class Rectangle; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Point | |||||
template<typename T> | template<typename T> | ||||
class Point | class Point | ||||
{ | { | ||||
public: | public: | ||||
/** | |||||
Constructor for (0, 0) point. | |||||
*/ | |||||
Point() noexcept; | Point() noexcept; | ||||
/** | |||||
Constructor using custom x and y values. | |||||
*/ | |||||
Point(const T& x, const T& y) noexcept; | Point(const T& x, const T& y) noexcept; | ||||
/** | |||||
Constructor using another Point class values. | |||||
*/ | |||||
Point(const Point<T>& pos) noexcept; | Point(const Point<T>& pos) noexcept; | ||||
/** | |||||
Get X value. | |||||
*/ | |||||
const T& getX() const noexcept; | const T& getX() const noexcept; | ||||
/** | |||||
Get Y value. | |||||
*/ | |||||
const T& getY() const noexcept; | const T& getY() const noexcept; | ||||
/** | |||||
Set X value as @a x. | |||||
*/ | |||||
void setX(const T& x) noexcept; | void setX(const T& x) noexcept; | ||||
/** | |||||
Set Y value as @a y. | |||||
*/ | |||||
void setY(const T& y) noexcept; | void setY(const T& y) noexcept; | ||||
/** | |||||
Set X and Y values as @a x and @a y respectively. | |||||
*/ | |||||
void setPos(const T& x, const T& y) noexcept; | void setPos(const T& x, const T& y) noexcept; | ||||
/** | |||||
Set X and Y values according to @a pos. | |||||
*/ | |||||
void setPos(const Point<T>& pos) noexcept; | void setPos(const Point<T>& pos) noexcept; | ||||
/** | |||||
Move this point by @a x and @a y values. | |||||
*/ | |||||
void moveBy(const T& x, const T& y) noexcept; | void moveBy(const T& x, const T& y) noexcept; | ||||
/** | |||||
Move this point by @a pos. | |||||
*/ | |||||
void moveBy(const Point<T>& pos) noexcept; | void moveBy(const Point<T>& pos) noexcept; | ||||
Point<T>& operator=(const Point<T>& pos) noexcept; | Point<T>& operator=(const Point<T>& pos) noexcept; | ||||
@@ -60,24 +102,65 @@ private: | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Size | |||||
template<typename T> | template<typename T> | ||||
class Size | class Size | ||||
{ | { | ||||
public: | public: | ||||
/** | |||||
Constructor for null size (0x0). | |||||
*/ | |||||
Size() noexcept; | Size() noexcept; | ||||
/** | |||||
Constructor using custom width and height values. | |||||
*/ | |||||
Size(const T& width, const T& height) noexcept; | Size(const T& width, const T& height) noexcept; | ||||
/** | |||||
Constructor using another Size class values. | |||||
*/ | |||||
Size(const Size<T>& size) noexcept; | Size(const Size<T>& size) noexcept; | ||||
/** | |||||
Get width. | |||||
*/ | |||||
const T& getWidth() const noexcept; | const T& getWidth() const noexcept; | ||||
/** | |||||
Get height. | |||||
*/ | |||||
const T& getHeight() const noexcept; | const T& getHeight() const noexcept; | ||||
/** | |||||
Set width. | |||||
*/ | |||||
void setWidth(const T& width) noexcept; | void setWidth(const T& width) noexcept; | ||||
/** | |||||
Set height. | |||||
*/ | |||||
void setHeight(const T& height) noexcept; | void setHeight(const T& height) noexcept; | ||||
/** | |||||
Set size using @a width and @a height. | |||||
*/ | |||||
void setSize(const T& width, const T& height) noexcept; | void setSize(const T& width, const T& height) noexcept; | ||||
/** | |||||
Set size. | |||||
*/ | |||||
void setSize(const Size<T>& size) noexcept; | void setSize(const Size<T>& size) noexcept; | ||||
/** | |||||
Grow size by @a multiplier. | |||||
*/ | |||||
void growBy(const T& multiplier) noexcept; | void growBy(const T& multiplier) noexcept; | ||||
/** | |||||
Shrink size by @a divider. | |||||
*/ | |||||
void shrinkBy(const T& divider) noexcept; | void shrinkBy(const T& divider) noexcept; | ||||
Size<T>& operator=(const Size<T>& size) noexcept; | Size<T>& operator=(const Size<T>& size) noexcept; | ||||
@@ -94,39 +177,125 @@ private: | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Line | |||||
template<typename T> | template<typename T> | ||||
class Line | class Line | ||||
{ | { | ||||
public: | public: | ||||
/** | |||||
Constructor for null line ([0, 0] to [0, 0]). | |||||
*/ | |||||
Line() noexcept; | Line() noexcept; | ||||
/** | |||||
Constructor using custom start X, start Y, end X and end Y values. | |||||
*/ | |||||
Line(const T& startX, const T& startY, const T& endX, const T& endY) noexcept; | Line(const T& startX, const T& startY, const T& endX, const T& endY) noexcept; | ||||
/** | |||||
Constructor using custom start X, start Y, end pos values. | |||||
*/ | |||||
Line(const T& startX, const T& startY, const Point<T>& endPos) noexcept; | Line(const T& startX, const T& startY, const Point<T>& endPos) noexcept; | ||||
/** | |||||
Constructor using custom start pos, end X and end Y values. | |||||
*/ | |||||
Line(const Point<T>& startPos, const T& endX, const T& endY) noexcept; | Line(const Point<T>& startPos, const T& endX, const T& endY) noexcept; | ||||
/** | |||||
Constructor using custom start and end pos values. | |||||
*/ | |||||
Line(const Point<T>& startPos, const Point<T>& endPos) noexcept; | Line(const Point<T>& startPos, const Point<T>& endPos) noexcept; | ||||
/** | |||||
Constructor using another Line class values. | |||||
*/ | |||||
Line(const Line<T>& line) noexcept; | Line(const Line<T>& line) noexcept; | ||||
/** | |||||
Get start X value. | |||||
*/ | |||||
const T& getStartX() const noexcept; | const T& getStartX() const noexcept; | ||||
/** | |||||
Get start Y value. | |||||
*/ | |||||
const T& getStartY() const noexcept; | const T& getStartY() const noexcept; | ||||
/** | |||||
Get end X value. | |||||
*/ | |||||
const T& getEndX() const noexcept; | const T& getEndX() const noexcept; | ||||
/** | |||||
Get end Y value. | |||||
*/ | |||||
const T& getEndY() const noexcept; | const T& getEndY() const noexcept; | ||||
/** | |||||
Get start position. | |||||
*/ | |||||
const Point<T>& getStartPos() const noexcept; | const Point<T>& getStartPos() const noexcept; | ||||
/** | |||||
Get end position. | |||||
*/ | |||||
const Point<T>& getEndPos() const noexcept; | const Point<T>& getEndPos() const noexcept; | ||||
/** | |||||
Set start X value as @a x. | |||||
*/ | |||||
void setStartX(const T& x) noexcept; | void setStartX(const T& x) noexcept; | ||||
/** | |||||
Set start Y value as @a y. | |||||
*/ | |||||
void setStartY(const T& y) noexcept; | void setStartY(const T& y) noexcept; | ||||
/** | |||||
Set start X and Y values as @a x and @a y respectively. | |||||
*/ | |||||
void setStartPos(const T& x, const T& y) noexcept; | void setStartPos(const T& x, const T& y) noexcept; | ||||
/** | |||||
Set start X and Y values according to @a pos. | |||||
*/ | |||||
void setStartPos(const Point<T>& pos) noexcept; | void setStartPos(const Point<T>& pos) noexcept; | ||||
/** | |||||
Set end X value as @a x. | |||||
*/ | |||||
void setEndX(const T& x) noexcept; | void setEndX(const T& x) noexcept; | ||||
/** | |||||
Set end Y value as @a y. | |||||
*/ | |||||
void setEndY(const T& y) noexcept; | void setEndY(const T& y) noexcept; | ||||
/** | |||||
Set end X and Y values as @a x and @a y respectively. | |||||
*/ | |||||
void setEndPos(const T& x, const T& y) noexcept; | void setEndPos(const T& x, const T& y) noexcept; | ||||
/** | |||||
Set end X and Y values according to @a pos. | |||||
*/ | |||||
void setEndPos(const Point<T>& pos) noexcept; | void setEndPos(const Point<T>& pos) noexcept; | ||||
/** | |||||
Move this line by @a x and @a y values. | |||||
*/ | |||||
void moveBy(const T& x, const T& y) noexcept; | void moveBy(const T& x, const T& y) noexcept; | ||||
/** | |||||
Move this line by @a pos. | |||||
*/ | |||||
void moveBy(const Point<T>& pos) noexcept; | void moveBy(const Point<T>& pos) noexcept; | ||||
/** | |||||
Draw this line using the current OpenGL state. | |||||
*/ | |||||
void draw(); | void draw(); | ||||
Line<T>& operator=(const Line<T>& line) noexcept; | Line<T>& operator=(const Line<T>& line) noexcept; | ||||
@@ -138,47 +307,155 @@ private: | |||||
}; | }; | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Rectangle | |||||
template<typename T> | template<typename T> | ||||
class Rectangle | class Rectangle | ||||
{ | { | ||||
public: | public: | ||||
/** | |||||
Constructor for null rectangle. | |||||
*/ | |||||
Rectangle() noexcept; | Rectangle() noexcept; | ||||
/** | |||||
Constructor using custom X, Y, width and height values. | |||||
*/ | |||||
Rectangle(const T& x, const T& y, const T& width, const T& height) noexcept; | Rectangle(const T& x, const T& y, const T& width, const T& height) noexcept; | ||||
/** | |||||
Constructor using custom X, Y and size values. | |||||
*/ | |||||
Rectangle(const T& x, const T& y, const Size<T>& size) noexcept; | Rectangle(const T& x, const T& y, const Size<T>& size) noexcept; | ||||
/** | |||||
Constructor using custom pos, width and height values. | |||||
*/ | |||||
Rectangle(const Point<T>& pos, const T& width, const T& height) noexcept; | Rectangle(const Point<T>& pos, const T& width, const T& height) noexcept; | ||||
/** | |||||
Constructor using custom position and size. | |||||
*/ | |||||
Rectangle(const Point<T>& pos, const Size<T>& size) noexcept; | Rectangle(const Point<T>& pos, const Size<T>& size) noexcept; | ||||
/** | |||||
Constructor using another Rectangle class values. | |||||
*/ | |||||
Rectangle(const Rectangle<T>& rect) noexcept; | Rectangle(const Rectangle<T>& rect) noexcept; | ||||
/** | |||||
Get X value. | |||||
*/ | |||||
const T& getX() const noexcept; | const T& getX() const noexcept; | ||||
/** | |||||
Get Y value. | |||||
*/ | |||||
const T& getY() const noexcept; | const T& getY() const noexcept; | ||||
/** | |||||
Get width. | |||||
*/ | |||||
const T& getWidth() const noexcept; | const T& getWidth() const noexcept; | ||||
/** | |||||
Get height. | |||||
*/ | |||||
const T& getHeight() const noexcept; | const T& getHeight() const noexcept; | ||||
/** | |||||
Get position. | |||||
*/ | |||||
const Point<T>& getPos() const noexcept; | const Point<T>& getPos() const noexcept; | ||||
const Size<T>& getSize() const noexcept; | |||||
/** | |||||
Get size. | |||||
*/ | |||||
const Size<T>& getSize() const noexcept; | |||||
/** | |||||
Set X value as @a x. | |||||
*/ | |||||
void setX(const T& x) noexcept; | void setX(const T& x) noexcept; | ||||
/** | |||||
Set Y value as @a y. | |||||
*/ | |||||
void setY(const T& y) noexcept; | void setY(const T& y) noexcept; | ||||
/** | |||||
Set X and Y values as @a x and @a y respectively. | |||||
*/ | |||||
void setPos(const T& x, const T& y) noexcept; | void setPos(const T& x, const T& y) noexcept; | ||||
/** | |||||
Set X and Y values according to @a pos. | |||||
*/ | |||||
void setPos(const Point<T>& pos) noexcept; | void setPos(const Point<T>& pos) noexcept; | ||||
/** | |||||
Move this rectangle by @a x and @a y values. | |||||
*/ | |||||
void moveBy(const T& x, const T& y) noexcept; | void moveBy(const T& x, const T& y) noexcept; | ||||
/** | |||||
Move this rectangle by @a pos. | |||||
*/ | |||||
void moveBy(const Point<T>& pos) noexcept; | void moveBy(const Point<T>& pos) noexcept; | ||||
/** | |||||
Set width. | |||||
*/ | |||||
void setWidth(const T& width) noexcept; | void setWidth(const T& width) noexcept; | ||||
/** | |||||
Set height. | |||||
*/ | |||||
void setHeight(const T& height) noexcept; | void setHeight(const T& height) noexcept; | ||||
/** | |||||
Set size using @a width and @a height. | |||||
*/ | |||||
void setSize(const T& width, const T& height) noexcept; | void setSize(const T& width, const T& height) noexcept; | ||||
/** | |||||
Set size. | |||||
*/ | |||||
void setSize(const Size<T>& size) noexcept; | void setSize(const Size<T>& size) noexcept; | ||||
/** | |||||
Grow size by @a multiplier. | |||||
*/ | |||||
void growBy(const T& multiplier) noexcept; | void growBy(const T& multiplier) noexcept; | ||||
/** | |||||
Shrink size by @a divider. | |||||
*/ | |||||
void shrinkBy(const T& divider) noexcept; | void shrinkBy(const T& divider) noexcept; | ||||
/** | |||||
Check if this rectangle contains the point defined by @a X and @a Y. | |||||
*/ | |||||
bool contains(const T& x, const T& y) const noexcept; | bool contains(const T& x, const T& y) const noexcept; | ||||
/** | |||||
Check if this rectangle contains the point @a pos. | |||||
*/ | |||||
bool contains(const Point<T>& pos) const noexcept; | bool contains(const Point<T>& pos) const noexcept; | ||||
/** | |||||
Check if this rectangle contains X. | |||||
*/ | |||||
bool containsX(const T& x) const noexcept; | bool containsX(const T& x) const noexcept; | ||||
/** | |||||
Check if this rectangle contains Y. | |||||
*/ | |||||
bool containsY(const T& y) const noexcept; | bool containsY(const T& y) const noexcept; | ||||
/** | |||||
Draw this rectangle using the current OpenGL state. | |||||
*/ | |||||
void draw(); | void draw(); | ||||
Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept; | Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept; | ||||
@@ -37,6 +37,9 @@ struct App::PrivateData { | |||||
~PrivateData() | ~PrivateData() | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT(! doLoop); | |||||
DISTRHO_SAFE_ASSERT(visibleWindows == 0); | |||||
windows.clear(); | windows.clear(); | ||||
idleCallbacks.clear(); | idleCallbacks.clear(); | ||||
} | } | ||||
@@ -139,7 +139,7 @@ void d_safe_exception(const char* const exception, const char* const file, const | |||||
// d_*sleep | // d_*sleep | ||||
static inline | static inline | ||||
void d_sleep(const uint secs) | |||||
void d_sleep(const uint secs) noexcept | |||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(secs > 0,); | DISTRHO_SAFE_ASSERT_RETURN(secs > 0,); | ||||
@@ -149,11 +149,11 @@ void d_sleep(const uint secs) | |||||
#else | #else | ||||
::sleep(secs); | ::sleep(secs); | ||||
#endif | #endif | ||||
} DISTRHO_SAFE_EXCEPTION("carla_sleep"); | |||||
} DISTRHO_SAFE_EXCEPTION("d_sleep"); | |||||
} | } | ||||
static inline | static inline | ||||
void d_msleep(const uint msecs) | |||||
void d_msleep(const uint msecs) noexcept | |||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(msecs > 0,); | DISTRHO_SAFE_ASSERT_RETURN(msecs > 0,); | ||||
@@ -163,7 +163,7 @@ void d_msleep(const uint msecs) | |||||
#else | #else | ||||
::usleep(msecs * 1000); | ::usleep(msecs * 1000); | ||||
#endif | #endif | ||||
} DISTRHO_SAFE_EXCEPTION("carla_msleep"); | |||||
} DISTRHO_SAFE_EXCEPTION("d_msleep"); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -37,10 +37,8 @@ | |||||
# define DISTRHO_DLL_EXTENSION "dylib" | # define DISTRHO_DLL_EXTENSION "dylib" | ||||
# elif defined(__HAIKU__) | # elif defined(__HAIKU__) | ||||
# define DISTRHO_OS_HAIKU 1 | # define DISTRHO_OS_HAIKU 1 | ||||
# define DISTRHO_DLL_EXTENSION "so" | |||||
# elif defined(__linux__) | # elif defined(__linux__) | ||||
# define DISTRHO_OS_LINUX 1 | # define DISTRHO_OS_LINUX 1 | ||||
# define DISTRHO_DLL_EXTENSION "so" | |||||
# endif | # endif | ||||
#endif | #endif | ||||
@@ -67,10 +65,10 @@ | |||||
#endif | #endif | ||||
/* Define DISTRHO_SAFE_ASSERT* */ | /* Define DISTRHO_SAFE_ASSERT* */ | ||||
#define DISTRHO_SAFE_ASSERT(cond) if (cond) d_pass(); else d_safe_assert(#cond, __FILE__, __LINE__); | |||||
#define DISTRHO_SAFE_ASSERT_BREAK(cond) if (cond) d_pass(); else { d_safe_assert(#cond, __FILE__, __LINE__); break; } | |||||
#define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (cond) d_pass(); else { d_safe_assert(#cond, __FILE__, __LINE__); continue; } | |||||
#define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (cond) d_pass(); else { d_safe_assert(#cond, __FILE__, __LINE__); return ret; } | |||||
#define DISTRHO_SAFE_ASSERT(cond) if (! (cond)) d_safe_assert(#cond, __FILE__, __LINE__); | |||||
#define DISTRHO_SAFE_ASSERT_BREAK(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); break; } | |||||
#define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); continue; } | |||||
#define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); return ret; } | |||||
/* Define DISTRHO_SAFE_EXCEPTION */ | /* Define DISTRHO_SAFE_EXCEPTION */ | ||||
#define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); } | #define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); } | ||||
@@ -14,13 +14,9 @@ LINK_FLAGS += -L.. -ldgl $(DGL_LIBS) | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
ifeq ($(WIN32),true) | ifeq ($(WIN32),true) | ||||
TARGETS = app.exe color.exe images.exe nekobi-ui.exe | |||||
TARGETS = dgl-app.exe dgl-color.exe dgl-images.exe | |||||
else | else | ||||
ifeq ($(MACOS),true) | |||||
TARGETS = app color images nekobi-ui | |||||
else | |||||
TARGETS = app cairo color images nekobi-ui | |||||
endif | |||||
TARGETS = dgl-app dgl-color dgl-images | |||||
endif | endif | ||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -29,7 +25,7 @@ all: ../libdgl.a $(TARGETS) | |||||
clean: | clean: | ||||
$(MAKE) -C ../dgl clean | $(MAKE) -C ../dgl clean | ||||
$(RM) *.exe app cairo color images nekobi-ui | |||||
$(RM) $(TARGETS) | |||||
debug: | debug: | ||||
$(MAKE) DEBUG=true | $(MAKE) DEBUG=true | ||||
@@ -46,22 +42,21 @@ debug: | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
app: app.cpp ../dgl/* | |||||
dgl-app: dgl-app.cpp ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
cairo: cairo.cpp ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags --libs cairo) $(LINK_FLAGS) -o $@ | |||||
color: color.cpp ../dgl/* | |||||
dgl-color: dgl-color.cpp ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
images: images.cpp images_src/* ../dgl/* | |||||
dgl-images: dgl-images.cpp dgl-images_src/* ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
nekobi-ui: nekobi-ui.cpp nekobi-ui_src/* ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||||
# -------------------------------------------------------------- | |||||
dgl-cairo: dgl-cairo.cpp ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags --libs cairo) $(LINK_FLAGS) -o $@ | |||||
text: text.cpp ../dgl/* | |||||
dgl-text: dgl-text.cpp ../dgl/* | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -1,17 +0,0 @@ | |||||
# qmake project file for app bundle test | |||||
TARGET = nekobi-ui | |||||
# ------------------------------------------------------- | |||||
CONFIG = app_bundle warn_on | |||||
TEMPLATE = app | |||||
VERSION = 1.0.0 | |||||
# ------------------------------------------------------- | |||||
INCLUDEPATH = ../../dgl | |||||
LIBS = ../../libdgl.a -framework OpenGL -framework Cocoa | |||||
SOURCES = ../nekobi-ui.cpp | |||||
# ------------------------------------------------------- |
@@ -17,7 +17,7 @@ | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// Pics | // Pics | ||||
#include "images_src/CatPics.cpp" | |||||
#include "dgl-images_src/CatPics.cpp" | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// DGL Stuff | // DGL Stuff |
@@ -1,54 +0,0 @@ | |||||
/* | |||||
* DISTRHO Plugin Framework (DPF) | |||||
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com> | |||||
* | |||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||||
* or without fee is hereby granted, provided that the above copyright notice and this | |||||
* permission notice appear in all copies. | |||||
* | |||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||||
*/ | |||||
// ------------------------------------------------------ | |||||
// DGL StandaloneWindow | |||||
#include "StandaloneWindow.hpp" | |||||
// ------------------------------------------------------ | |||||
// include all source code here to make building easier | |||||
#include "nekobi-ui_src/DistrhoArtworkNekobi.cpp" | |||||
#include "nekobi-ui_src/DistrhoUINekobi.cpp" | |||||
// ------------------------------------------------------ | |||||
// main entry point | |||||
int main() | |||||
{ | |||||
DGL::StandaloneWindow appWin; | |||||
DGL::Window& win(appWin.getWindow()); | |||||
DistrhoUINekobi gui(win); | |||||
win.setResizable(false); | |||||
win.setSize(gui.getWidth(), gui.getHeight()); | |||||
win.setTitle("DGL UI Test"); | |||||
win.show(); | |||||
DGL::App& app(appWin.getApp()); | |||||
while (! app.isQuiting()) | |||||
{ | |||||
gui.idle(); | |||||
app.idle(); | |||||
d_msleep(10); | |||||
} | |||||
return 0; | |||||
} | |||||
// ------------------------------------------------------ |
@@ -1,90 +0,0 @@ | |||||
/* (Auto-generated binary data file). */ | |||||
#ifndef BINARY_DISTRHOARTWORKNEKOBI_HPP | |||||
#define BINARY_DISTRHOARTWORKNEKOBI_HPP | |||||
namespace DistrhoArtworkNekobi | |||||
{ | |||||
extern const char* aboutData; | |||||
const unsigned int aboutDataSize = 172710; | |||||
const unsigned int aboutWidth = 303; | |||||
const unsigned int aboutHeight = 190; | |||||
extern const char* aboutButtonHoverData; | |||||
const unsigned int aboutButtonHoverDataSize = 5888; | |||||
const unsigned int aboutButtonHoverWidth = 92; | |||||
const unsigned int aboutButtonHoverHeight = 16; | |||||
extern const char* aboutButtonNormalData; | |||||
const unsigned int aboutButtonNormalDataSize = 5888; | |||||
const unsigned int aboutButtonNormalWidth = 92; | |||||
const unsigned int aboutButtonNormalHeight = 16; | |||||
extern const char* backgroundData; | |||||
const unsigned int backgroundDataSize = 206064; | |||||
const unsigned int backgroundWidth = 636; | |||||
const unsigned int backgroundHeight = 108; | |||||
extern const char* claw1Data; | |||||
const unsigned int claw1DataSize = 4096; | |||||
const unsigned int claw1Width = 32; | |||||
const unsigned int claw1Height = 32; | |||||
extern const char* claw2Data; | |||||
const unsigned int claw2DataSize = 4096; | |||||
const unsigned int claw2Width = 32; | |||||
const unsigned int claw2Height = 32; | |||||
extern const char* knobData; | |||||
const unsigned int knobDataSize = 10000; | |||||
const unsigned int knobWidth = 50; | |||||
const unsigned int knobHeight = 50; | |||||
extern const char* run1Data; | |||||
const unsigned int run1DataSize = 4096; | |||||
const unsigned int run1Width = 32; | |||||
const unsigned int run1Height = 32; | |||||
extern const char* run2Data; | |||||
const unsigned int run2DataSize = 4096; | |||||
const unsigned int run2Width = 32; | |||||
const unsigned int run2Height = 32; | |||||
extern const char* run3Data; | |||||
const unsigned int run3DataSize = 4096; | |||||
const unsigned int run3Width = 32; | |||||
const unsigned int run3Height = 32; | |||||
extern const char* run4Data; | |||||
const unsigned int run4DataSize = 4096; | |||||
const unsigned int run4Width = 32; | |||||
const unsigned int run4Height = 32; | |||||
extern const char* scratch1Data; | |||||
const unsigned int scratch1DataSize = 4096; | |||||
const unsigned int scratch1Width = 32; | |||||
const unsigned int scratch1Height = 32; | |||||
extern const char* scratch2Data; | |||||
const unsigned int scratch2DataSize = 4096; | |||||
const unsigned int scratch2Width = 32; | |||||
const unsigned int scratch2Height = 32; | |||||
extern const char* sitData; | |||||
const unsigned int sitDataSize = 4096; | |||||
const unsigned int sitWidth = 32; | |||||
const unsigned int sitHeight = 32; | |||||
extern const char* sliderData; | |||||
const unsigned int sliderDataSize = 6084; | |||||
const unsigned int sliderWidth = 39; | |||||
const unsigned int sliderHeight = 39; | |||||
extern const char* tailData; | |||||
const unsigned int tailDataSize = 4096; | |||||
const unsigned int tailWidth = 32; | |||||
const unsigned int tailHeight = 32; | |||||
} | |||||
#endif // BINARY_DISTRHOARTWORKNEKOBI_HPP | |||||
@@ -1,142 +0,0 @@ | |||||
/* | |||||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | |||||
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
* | |||||
* This program is free software; you can redistribute it and/or | |||||
* modify it under the terms of the GNU General Public License as | |||||
* published by the Free Software Foundation; either version 2 of | |||||
* the License, or any later version. | |||||
* | |||||
* This program 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. | |||||
* | |||||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||||
*/ | |||||
#include "DistrhoUINekobi.hpp" | |||||
using DGL::Point; | |||||
// ----------------------------------------------------------------------- | |||||
DistrhoUINekobi::DistrhoUINekobi(DGL::Window& parent) | |||||
: DGL::Widget(parent), | |||||
fAboutWindow(this) | |||||
{ | |||||
fNeko.setTimerSpeed(15); | |||||
// background | |||||
fImgBackground = Image(DistrhoArtworkNekobi::backgroundData, DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight, GL_BGR); | |||||
Image imageAbout(DistrhoArtworkNekobi::aboutData, DistrhoArtworkNekobi::aboutWidth, DistrhoArtworkNekobi::aboutHeight, GL_BGR); | |||||
fAboutWindow.setImage(imageAbout); | |||||
// slider | |||||
Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight); | |||||
fSliderWaveform = new ImageSlider(this, sliderImage); | |||||
fSliderWaveform->setStartPos(133, 40); | |||||
fSliderWaveform->setEndPos(133, 60); | |||||
fSliderWaveform->setRange(0.0f, 1.0f); | |||||
fSliderWaveform->setValue(0.0f); | |||||
fSliderWaveform->setStep(1.0f); | |||||
// knobs | |||||
Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight); | |||||
// knob Tuning | |||||
fKnobTuning = new ImageKnob(this, knobImage); | |||||
fKnobTuning->setPos(41, 43); | |||||
fKnobTuning->setRange(-12.0f, 12.0f); | |||||
fKnobTuning->setValue(0.0f); | |||||
fKnobTuning->setRotationAngle(305); | |||||
// knob Cutoff | |||||
fKnobCutoff = new ImageKnob(this, knobImage); | |||||
fKnobCutoff->setPos(185, 43); | |||||
fKnobCutoff->setRange(0.0f, 100.0f); | |||||
fKnobCutoff->setValue(25.0f); | |||||
fKnobCutoff->setRotationAngle(305); | |||||
// knob Resonance | |||||
fKnobResonance = new ImageKnob(this, knobImage); | |||||
fKnobResonance->setPos(257, 43); | |||||
fKnobResonance->setRange(0.0f, 95.0f); | |||||
fKnobResonance->setValue(25.0f); | |||||
fKnobResonance->setRotationAngle(305); | |||||
// knob Env Mod | |||||
fKnobEnvMod = new ImageKnob(this, knobImage); | |||||
fKnobEnvMod->setPos(329, 43); | |||||
fKnobEnvMod->setRange(0.0f, 100.0f); | |||||
fKnobEnvMod->setValue(50.0f); | |||||
fKnobEnvMod->setRotationAngle(305); | |||||
// knob Decay | |||||
fKnobDecay = new ImageKnob(this, knobImage); | |||||
fKnobDecay->setPos(400, 43); | |||||
fKnobDecay->setRange(0.0f, 100.0f); | |||||
fKnobDecay->setValue(75.0f); | |||||
fKnobDecay->setRotationAngle(305); | |||||
// knob Accent | |||||
fKnobAccent = new ImageKnob(this, knobImage); | |||||
fKnobAccent->setPos(473, 43); | |||||
fKnobAccent->setRange(0.0f, 100.0f); | |||||
fKnobAccent->setValue(25.0f); | |||||
fKnobAccent->setRotationAngle(305); | |||||
// knob Volume | |||||
fKnobVolume = new ImageKnob(this, knobImage); | |||||
fKnobVolume->setPos(545, 43); | |||||
fKnobVolume->setRange(0.0f, 100.0f); | |||||
fKnobVolume->setValue(75.0f); | |||||
fKnobVolume->setRotationAngle(305); | |||||
// about button | |||||
Image aboutImageNormal(DistrhoArtworkNekobi::aboutButtonNormalData, DistrhoArtworkNekobi::aboutButtonNormalWidth, DistrhoArtworkNekobi::aboutButtonNormalHeight); | |||||
Image aboutImageHover(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | |||||
fButtonAbout->setPos(505, 5); | |||||
fButtonAbout->setCallback(this); | |||||
} | |||||
DistrhoUINekobi::~DistrhoUINekobi() | |||||
{ | |||||
delete fSliderWaveform; | |||||
delete fKnobTuning; | |||||
delete fKnobCutoff; | |||||
delete fKnobResonance; | |||||
delete fKnobEnvMod; | |||||
delete fKnobDecay; | |||||
delete fKnobAccent; | |||||
delete fKnobVolume; | |||||
delete fButtonAbout; | |||||
} | |||||
void DistrhoUINekobi::idle() | |||||
{ | |||||
if (fNeko.idle()) | |||||
repaint(); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
// Widget Callbacks | |||||
void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int) | |||||
{ | |||||
if (button != fButtonAbout) | |||||
return; | |||||
fAboutWindow.exec(); | |||||
} | |||||
void DistrhoUINekobi::onDisplay() | |||||
{ | |||||
fImgBackground.draw(); | |||||
fNeko.draw(); | |||||
} | |||||
// ----------------------------------------------------------------------- |
@@ -1,81 +0,0 @@ | |||||
/* | |||||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | |||||
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
* | |||||
* This program is free software; you can redistribute it and/or | |||||
* modify it under the terms of the GNU General Public License as | |||||
* published by the Free Software Foundation; either version 2 of | |||||
* the License, or any later version. | |||||
* | |||||
* This program 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. | |||||
* | |||||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||||
*/ | |||||
#ifndef DISTRHO_UI_NEKOBI_HPP_INCLUDED | |||||
#define DISTRHO_UI_NEKOBI_HPP_INCLUDED | |||||
#include "ImageAboutWindow.hpp" | |||||
#include "ImageButton.hpp" | |||||
#include "ImageKnob.hpp" | |||||
#include "ImageSlider.hpp" | |||||
#include "DistrhoArtworkNekobi.hpp" | |||||
#include "NekoWidget.hpp" | |||||
using DGL::ImageAboutWindow; | |||||
using DGL::ImageButton; | |||||
using DGL::ImageKnob; | |||||
using DGL::ImageSlider; | |||||
// ----------------------------------------------------------------------- | |||||
class DistrhoUINekobi : public DGL::Widget, | |||||
public ImageButton::Callback | |||||
{ | |||||
public: | |||||
DistrhoUINekobi(DGL::Window& parent); | |||||
~DistrhoUINekobi() override; | |||||
unsigned int getWidth() const noexcept | |||||
{ | |||||
return DistrhoArtworkNekobi::backgroundWidth; | |||||
} | |||||
unsigned int getHeight() const noexcept | |||||
{ | |||||
return DistrhoArtworkNekobi::backgroundHeight; | |||||
} | |||||
void idle(); | |||||
protected: | |||||
// ------------------------------------------------------------------- | |||||
// Widget Callbacks | |||||
void imageButtonClicked(ImageButton* button, int) override; | |||||
void onDisplay() override; | |||||
private: | |||||
Image fImgBackground; | |||||
NekoWidget fNeko; | |||||
ImageKnob* fKnobTuning; | |||||
ImageKnob* fKnobCutoff; | |||||
ImageKnob* fKnobResonance; | |||||
ImageKnob* fKnobEnvMod; | |||||
ImageKnob* fKnobDecay; | |||||
ImageKnob* fKnobAccent; | |||||
ImageKnob* fKnobVolume; | |||||
ImageButton* fButtonAbout; | |||||
ImageSlider* fSliderWaveform; | |||||
ImageAboutWindow fAboutWindow; | |||||
}; | |||||
// ----------------------------------------------------------------------- | |||||
#endif // DISTRHO_UI_NEKOBI_HPP_INCLUDED |
@@ -1,204 +0,0 @@ | |||||
/* | |||||
* Neko widget animation | |||||
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
* | |||||
* This program is free software; you can redistribute it and/or | |||||
* modify it under the terms of the GNU General Public License as | |||||
* published by the Free Software Foundation; either version 2 of | |||||
* the License, or any later version. | |||||
* | |||||
* This program 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. | |||||
* | |||||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||||
*/ | |||||
#ifndef NEKO_WIDGET_HPP_INCLUDED | |||||
#define NEKO_WIDGET_HPP_INCLUDED | |||||
#include "Image.hpp" | |||||
#include "Widget.hpp" | |||||
#include <cstdlib> // rand | |||||
#include "DistrhoArtworkNekobi.hpp" | |||||
using DGL::Image; | |||||
USE_NAMESPACE_DGL; | |||||
// ----------------------------------------------------------------------- | |||||
class NekoWidget | |||||
{ | |||||
public: | |||||
NekoWidget() | |||||
: fPos(0), | |||||
fTimer(0), | |||||
fTimerSpeed(20), | |||||
fCurAction(kActionNone), | |||||
fCurImage(&fImages.sit) | |||||
{ | |||||
// load images | |||||
{ | |||||
using namespace DistrhoArtworkNekobi; | |||||
#define JOIN(a, b) a ## b | |||||
#define LOAD_IMAGE(NAME) fImages.NAME.loadFromMemory(JOIN(NAME, Data), JOIN(NAME, Width), JOIN(NAME, Height)); | |||||
LOAD_IMAGE(sit) | |||||
LOAD_IMAGE(tail) | |||||
LOAD_IMAGE(claw1) | |||||
LOAD_IMAGE(claw2) | |||||
LOAD_IMAGE(scratch1) | |||||
LOAD_IMAGE(scratch2) | |||||
LOAD_IMAGE(run1) | |||||
LOAD_IMAGE(run2) | |||||
LOAD_IMAGE(run3) | |||||
LOAD_IMAGE(run4) | |||||
#undef JOIN | |||||
#undef LOAD_IMAGE | |||||
} | |||||
} | |||||
void draw() | |||||
{ | |||||
int x = fPos+108; | |||||
int y = -2; | |||||
if (fCurImage == &fImages.claw1 || fCurImage == &fImages.claw2) | |||||
{ | |||||
x += 2; | |||||
y += 12; | |||||
} | |||||
fCurImage->drawAt(x, y); | |||||
} | |||||
// returns true if needs repaint | |||||
bool idle() | |||||
{ | |||||
if (++fTimer % fTimerSpeed != 0) // target is 20ms | |||||
return false; | |||||
if (fTimer == fTimerSpeed*9) | |||||
{ | |||||
if (fCurAction == kActionNone) | |||||
fCurAction = static_cast<Action>(std::rand() % kActionCount); | |||||
else | |||||
fCurAction = kActionNone; | |||||
fTimer = 0; | |||||
} | |||||
switch (fCurAction) | |||||
{ | |||||
case kActionNone: | |||||
if (fCurImage == &fImages.sit) | |||||
fCurImage = &fImages.tail; | |||||
else | |||||
fCurImage = &fImages.sit; | |||||
break; | |||||
case kActionClaw: | |||||
if (fCurImage == &fImages.claw1) | |||||
fCurImage = &fImages.claw2; | |||||
else | |||||
fCurImage = &fImages.claw1; | |||||
break; | |||||
case kActionScratch: | |||||
if (fCurImage == &fImages.scratch1) | |||||
fCurImage = &fImages.scratch2; | |||||
else | |||||
fCurImage = &fImages.scratch1; | |||||
break; | |||||
case kActionRunRight: | |||||
if (fTimer == 0 && fPos > 20*9) | |||||
{ | |||||
// run the other way | |||||
--fTimer; | |||||
fCurAction = kActionRunLeft; | |||||
idle(); | |||||
break; | |||||
} | |||||
fPos += 20; | |||||
if (fCurImage == &fImages.run1) | |||||
fCurImage = &fImages.run2; | |||||
else | |||||
fCurImage = &fImages.run1; | |||||
break; | |||||
case kActionRunLeft: | |||||
if (fTimer == 0 && fPos < 20*9) | |||||
{ | |||||
// run the other way | |||||
--fTimer; | |||||
fCurAction = kActionRunRight; | |||||
idle(); | |||||
break; | |||||
} | |||||
fPos -= 20; | |||||
if (fCurImage == &fImages.run3) | |||||
fCurImage = &fImages.run4; | |||||
else | |||||
fCurImage = &fImages.run3; | |||||
break; | |||||
case kActionCount: | |||||
break; | |||||
} | |||||
return true; | |||||
} | |||||
void setTimerSpeed(int speed) | |||||
{ | |||||
fTimer = 0; | |||||
fTimerSpeed = speed; | |||||
} | |||||
// ------------------------------------------------------------------- | |||||
private: | |||||
enum Action { | |||||
kActionNone, // bounce tail | |||||
kActionClaw, | |||||
kActionScratch, | |||||
kActionRunRight, | |||||
kActionRunLeft, | |||||
kActionCount | |||||
}; | |||||
struct Images { | |||||
Image sit; | |||||
Image tail; | |||||
Image claw1; | |||||
Image claw2; | |||||
Image scratch1; | |||||
Image scratch2; | |||||
Image run1; | |||||
Image run2; | |||||
Image run3; | |||||
Image run4; | |||||
} fImages; | |||||
int fPos; | |||||
int fTimer; | |||||
int fTimerSpeed; | |||||
Action fCurAction; | |||||
Image* fCurImage; | |||||
}; | |||||
// ----------------------------------------------------------------------- | |||||
#endif // NEKO_WIDGET_HPP_INCLUDED |
@@ -1,36 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
void main() | |||||
{ | |||||
gl_FragColor = gl_Color; | |||||
} |
@@ -1,45 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform mat4 model; | |||||
uniform mat4 view; | |||||
uniform mat4 projection; | |||||
uniform vec4 Color; | |||||
attribute vec3 vertex; | |||||
attribute vec4 color; | |||||
void main() | |||||
{ | |||||
gl_FrontColor = color*Color; | |||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex,1.0); | |||||
//gl_Position = projection*(view*(model*vec4(vertex,1.0))); | |||||
} |
@@ -1,43 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform sampler2D texture; | |||||
void main(void) | |||||
{ | |||||
vec4 color = texture2D(texture, gl_TexCoord[0].st); | |||||
float dist = color.r; | |||||
float width = fwidth(dist); | |||||
float alpha = smoothstep(0.5-width, 0.5+width, dist); | |||||
gl_FragColor = vec4(gl_Color.rgb, alpha*gl_Color.a); | |||||
} | |||||
@@ -1,47 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform sampler2D texture; | |||||
uniform mat4 model; | |||||
uniform mat4 view; | |||||
uniform mat4 projection; | |||||
uniform vec4 Color; | |||||
attribute vec3 vertex; | |||||
attribute vec2 tex_coord; | |||||
attribute vec4 color; | |||||
void main() | |||||
{ | |||||
gl_TexCoord[0].xy = tex_coord.xy; | |||||
gl_FrontColor = color*Color; | |||||
gl_Position = projection*(view*(model*vec4(vertex,1.0))); | |||||
} |
@@ -1,43 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform sampler2D texture; | |||||
void main(void) | |||||
{ | |||||
vec3 color = vec3(0.0,0.0,0.0); | |||||
float dist = texture2D(texture, gl_TexCoord[0].st).r; | |||||
float width = fwidth(dist); | |||||
float alpha = smoothstep(0.5-width, 0.5+width, dist); | |||||
gl_FragColor = vec4(color, alpha); | |||||
} | |||||
@@ -1,70 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform sampler2D texture; | |||||
vec3 glyph_color = vec3(1.0,1.0,1.0); | |||||
const float glyph_center = 0.50; | |||||
vec3 outline_color = vec3(0.0,0.0,0.0); | |||||
const float outline_center = 0.55; | |||||
vec3 glow_color = vec3(1.0,1.0,1.0); | |||||
const float glow_center = 1.25; | |||||
void main(void) | |||||
{ | |||||
vec4 color = texture2D(texture, gl_TexCoord[0].st); | |||||
float dist = color.r; | |||||
float width = fwidth(dist); | |||||
float alpha = smoothstep(glyph_center-width, glyph_center+width, dist); | |||||
// Smooth | |||||
// gl_FragColor = vec4(glyph_color, alpha); | |||||
// Outline | |||||
// float mu = smoothstep(outline_center-width, outline_center+width, dist); | |||||
// vec3 rgb = mix(outline_color, glyph_color, mu); | |||||
// gl_FragColor = vec4(rgb, max(alpha,mu)); | |||||
// Glow | |||||
//vec3 rgb = mix(glow_color, glyph_color, alpha); | |||||
//float mu = smoothstep(glyph_center, glow_center, sqrt(dist)); | |||||
//gl_FragColor = vec4(rgb, max(alpha,mu)); | |||||
// Glow + outline | |||||
vec3 rgb = mix(glow_color, glyph_color, alpha); | |||||
float mu = smoothstep(glyph_center, glow_center, sqrt(dist)); | |||||
color = vec4(rgb, max(alpha,mu)); | |||||
float beta = smoothstep(outline_center-width, outline_center+width, dist); | |||||
rgb = mix(outline_color, color.rgb, beta); | |||||
gl_FragColor = vec4(rgb, max(color.a,beta)); | |||||
} | |||||
@@ -1,40 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
void main(void) | |||||
{ | |||||
gl_FrontColor = gl_Color; | |||||
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy; | |||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | |||||
} | |||||
@@ -1,152 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
vec3 | |||||
energy_distribution( vec4 previous, vec4 current, vec4 next ) | |||||
{ | |||||
float primary = 1.0/3.0; | |||||
float secondary = 1.0/3.0; | |||||
float tertiary = 0.0; | |||||
// Energy distribution as explained on: | |||||
// http://www.grc.com/freeandclear.htm | |||||
// | |||||
// .. v.. | |||||
// RGB RGB RGB | |||||
// previous.g + previous.b + current.r + current.g + current.b | |||||
// | |||||
// . .v. . | |||||
// RGB RGB RGB | |||||
// previous.b + current.r + current.g + current.b + next.r | |||||
// | |||||
// ..v .. | |||||
// RGB RGB RGB | |||||
// current.r + current.g + current.b + next.r + next.g | |||||
float r = | |||||
tertiary * previous.g + | |||||
secondary * previous.b + | |||||
primary * current.r + | |||||
secondary * current.g + | |||||
tertiary * current.b; | |||||
float g = | |||||
tertiary * previous.b + | |||||
secondary * current.r + | |||||
primary * current.g + | |||||
secondary * current.b + | |||||
tertiary * next.r; | |||||
float b = | |||||
tertiary * current.r + | |||||
secondary * current.g + | |||||
primary * current.b + | |||||
secondary * next.r + | |||||
tertiary * next.g; | |||||
return vec3(r,g,b); | |||||
} | |||||
uniform sampler2D texture; | |||||
uniform vec3 pixel; | |||||
varying float vgamma; | |||||
varying float vshift; | |||||
void main() | |||||
{ | |||||
vec2 uv = gl_TexCoord[0].xy; | |||||
float shift = vshift; | |||||
// LCD Off | |||||
if( pixel.z == 1.0) | |||||
{ | |||||
float a = texture2D(texture, uv).r; | |||||
gl_FragColor = gl_Color * pow( a, 1.0/vgamma ); | |||||
return; | |||||
} | |||||
// LCD On | |||||
vec4 current = texture2D(texture, uv); | |||||
vec4 previous= texture2D(texture, uv+vec2(-1.,0.)*pixel.xy); | |||||
vec4 next = texture2D(texture, uv+vec2(+1.,0.)*pixel.xy); | |||||
current = pow(current, vec4(1.0/vgamma)); | |||||
previous= pow(previous, vec4(1.0/vgamma)); | |||||
float r = current.r; | |||||
float g = current.g; | |||||
float b = current.b; | |||||
if( shift <= 0.333 ) | |||||
{ | |||||
float z = shift/0.333; | |||||
r = mix(current.r, previous.b, z); | |||||
g = mix(current.g, current.r, z); | |||||
b = mix(current.b, current.g, z); | |||||
} | |||||
else if( shift <= 0.666 ) | |||||
{ | |||||
float z = (shift-0.33)/0.333; | |||||
r = mix(previous.b, previous.g, z); | |||||
g = mix(current.r, previous.b, z); | |||||
b = mix(current.g, current.r, z); | |||||
} | |||||
else if( shift < 1.0 ) | |||||
{ | |||||
float z = (shift-0.66)/0.334; | |||||
r = mix(previous.g, previous.r, z); | |||||
g = mix(previous.b, previous.g, z); | |||||
b = mix(current.r, previous.b, z); | |||||
} | |||||
float t = max(max(r,g),b); | |||||
vec4 color = vec4(gl_Color.rgb, (r+g+b)/3.0); | |||||
color = t*color + (1.0-t)*vec4(r,g,b, min(min(r,g),b)); | |||||
gl_FragColor = vec4( color.rgb, gl_Color.a*color.a); | |||||
// gl_FragColor = vec4(pow(vec3(r,g,b),vec3(1.0/vgamma)),a); | |||||
/* | |||||
vec3 color = energy_distribution(previous, vec4(r,g,b,1), next); | |||||
color = pow( color, vec3(1.0/vgamma)); | |||||
vec3 color = vec3(r,g,b); //pow( vec3(r,g,b), vec3(1.0/vgamma)); | |||||
gl_FragColor.rgb = color; //*gl_Color.rgb; | |||||
gl_FragColor.a = (color.r+color.g+color.b)/3.0 * gl_Color.a; | |||||
*/ | |||||
// gl_FragColor = vec4(pow(vec3(r,g,b),vec3(1.0/vgamma)),a); | |||||
//gl_FragColor = vec4(r,g,b,a); | |||||
} |
@@ -1,55 +0,0 @@ | |||||
/* ============================================================================ | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ---------------------------------------------------------------------------- | |||||
* Copyright 2011,2012 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ============================================================================ | |||||
*/ | |||||
uniform sampler2D texture; | |||||
uniform vec3 pixel; | |||||
uniform mat4 model; | |||||
uniform mat4 view; | |||||
uniform mat4 projection; | |||||
attribute vec3 vertex; | |||||
attribute vec4 color; | |||||
attribute vec2 tex_coord; | |||||
attribute float ashift; | |||||
attribute float agamma; | |||||
varying float vshift; | |||||
varying float vgamma; | |||||
void main() | |||||
{ | |||||
vshift = ashift; | |||||
vgamma = agamma; | |||||
gl_FrontColor = color; | |||||
gl_TexCoord[0].xy = tex_coord.xy; | |||||
gl_Position = projection*(view*(model*vec4(vertex,1.0))); | |||||
} |
@@ -1,36 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
void main() | |||||
{ | |||||
gl_FragColor = gl_Color; | |||||
} |
@@ -1,43 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform mat4 model; | |||||
uniform mat4 view; | |||||
uniform mat4 projection; | |||||
attribute vec3 vertex; | |||||
attribute vec4 color; | |||||
void main() | |||||
{ | |||||
gl_FrontColor = color; | |||||
gl_Position = projection*(view*(model*vec4(vertex,1.0))); | |||||
} |
@@ -1,38 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform sampler2D texture; | |||||
void main() | |||||
{ | |||||
float a = texture2D(texture, gl_TexCoord[0].xy).r; | |||||
gl_FragColor = vec4(gl_Color.rgb, gl_Color.a*a); | |||||
} |
@@ -1,45 +0,0 @@ | |||||
/* ========================================================================= | |||||
* Freetype GL - A C OpenGL Freetype engine | |||||
* Platform: Any | |||||
* WWW: http://code.google.com/p/freetype-gl/ | |||||
* ------------------------------------------------------------------------- | |||||
* Copyright 2011 Nicolas P. Rougier. All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright notice, | |||||
* this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |||||
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of Nicolas P. Rougier. | |||||
* ========================================================================= */ | |||||
uniform mat4 model; | |||||
uniform mat4 view; | |||||
uniform mat4 projection; | |||||
attribute vec3 vertex; | |||||
attribute vec2 tex_coord; | |||||
attribute vec4 color; | |||||
void main() | |||||
{ | |||||
gl_TexCoord[0].xy = tex_coord.xy; | |||||
gl_FrontColor = color; | |||||
gl_Position = projection*(view*(model*vec4(vertex,1.0))); | |||||
} |