Format the code via clang-format

This commit is contained in:
Maschell 2022-02-05 14:28:08 +01:00
parent 7895e05264
commit 4a0e27624b
79 changed files with 1372 additions and 1302 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

25
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: CI-PR
on: [pull_request]
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
with:
name: binary
path: "lib/*.a"

View File

@ -4,8 +4,16 @@ on:
branches:
- master
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include
build:
runs-on: ubuntu-latest
needs: clang-format
steps:
- uses: actions/checkout@master
- name: Get release version

3
Dockerfile.buildlocal Normal file
View File

@ -0,0 +1,3 @@
FROM wiiuenv/devkitppc:20211229
WORKDIR project

View File

@ -1,22 +1,16 @@
[![Publish Docker Image](https://github.com/wiiu-env/libgui/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libgui/actions/workflows/push_image.yml)
# libgui
[![Build Status](https://travis-ci.org/Maschell/libgui.svg?branch=wut)](https://travis-ci.org/Maschell/libgui/tree/wut)
# build
```
pacman -Syu ppc-portlibs
pacman -Syu ppc-glm ppc-libmad
```
## Usage
Following steps are required for initialization:
```C
memoryInitialize(); // Initialize memory management
libgui_memoryInitialize(); // Initialize memory management
//DO GUI STUFF HERE!
memoryRelease();
libgui_memoryRelease();
```
Link the application with:
@ -39,6 +33,20 @@ To be able to use libgui, you need to install the following dependencies:
- [wut](https://github.com/devkitPro/wut/)
- Install the required portlibs via `(dkp-)pacman -Syu ppc-zlib ppc-libmad ppc-libogg ppc-libgd ppc-freetype ppc-libjpeg-turbo ppc-libpng ppc-libvorbisidec ppc-glm ppc-bzip2`
## Use this lib in Dockerfiles.
A prebuilt version of this lib can found on dockerhub. To use it for your projects, add this to your Dockerfile.
```
[...]
COPY --from=wiiuenv/libgui:[tag] /artifacts $DEVKITPRO
[...]
```
Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libgui/tags).
It's highly recommended to pin the version to the **latest date** instead of using `latest`.
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i`
# Credits
- Orignally based on https://github.com/dborth/libwiigui
- Wii U port / modification / new functions / sound / much more by dimok.

View File

@ -22,16 +22,16 @@
#pragma once
#include <string>
#include <ft2build.h>
#include <string>
#include FT_FREETYPE_H
#include FT_BITMAP_H
#include <malloc.h>
#include <string.h>
#include <wchar.h>
#include <map>
#include <mutex>
#include <string.h>
#include <wchar.h>
#include <gui/gx2_ext.h>
@ -47,12 +47,12 @@
* Font face character glyph relevant data structure.
*/
typedef struct ftgxCharData_ {
int16_t renderOffsetX; /**< Texture X axis bearing offset. */
int16_t renderOffsetX; /**< Texture X axis bearing offset. */
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
uint16_t glyphAdvanceY; /**< Character glyph Y coordinate advance in pixels. */
uint32_t glyphIndex; /**< Charachter glyph index in the font face. */
uint32_t glyphIndex; /**< Charachter glyph index in the font face. */
int16_t renderOffsetY; /**< Texture Y axis bearing offset. */
int16_t renderOffsetY; /**< Texture Y axis bearing offset. */
int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
@ -64,15 +64,15 @@ typedef struct ftgxCharData_ {
* Offset structure which hold both a maximum and minimum value.
*/
typedef struct ftgxDataOffset_ {
int16_t ascender; /**< Maximum data offset. */
int16_t ascender; /**< Maximum data offset. */
int16_t descender; /**< Minimum data offset. */
int16_t max; /**< Maximum data offset. */
int16_t min; /**< Minimum data offset. */
int16_t max; /**< Maximum data offset. */
int16_t min; /**< Minimum data offset. */
} ftgxDataOffset;
typedef struct ftgxCharData_ ftgxCharData;
typedef struct ftgxDataOffset_ ftgxDataOffset;
#define _TEXT(t) L ## t /**< Unicode helper macro. */
#define _TEXT(t) L##t /**< Unicode helper macro. */
#define FTGX_NULL 0x0000
#define FTGX_JUSTIFY_LEFT 0x0001
@ -94,9 +94,8 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
#define FTGX_STYLE_MASK 0xf000
/**< Constant color value used only to sanitize Doxygen documentation. */
static const GX2ColorF32 ftgxWhite = (GX2ColorF32) {
1.0f, 1.0f, 1.0f, 1.0f
};
static const GX2ColorF32 ftgxWhite = (GX2ColorF32){
1.0f, 1.0f, 1.0f, 1.0f};
//! forward declaration
@ -113,10 +112,10 @@ class CVideo;
*/
class FreeTypeGX {
private:
FT_Library ftLibrary; /**< FreeType FT_Library instance. */
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
FT_Library ftLibrary; /**< FreeType FT_Library instance. */
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
uint8_t vertexIndex; /**< Vertex format descriptor index. */
uint8_t vertexIndex; /**< Vertex format descriptor index. */
GX2Sampler ftSampler;
std::recursive_mutex faceMutex;
std::recursive_mutex fontDataMutex;

View File

@ -30,13 +30,13 @@
#include <gui/GuiImageAsync.h>
#include <gui/GuiImageData.h>
#include <gui/GuiParticleImage.h>
#include <gui/GuiScrollbar.h>
#include <gui/GuiSelectBox.h>
#include <gui/GuiSound.h>
#include <gui/GuiSwitch.h>
#include <gui/GuiText.h>
#include <gui/GuiToggle.h>
#include <gui/GuiTrigger.h>
#include <gui/GuiScrollbar.h>
#include <gui/VPadController.h>
#include <gui/WPadController.h>

View File

@ -17,11 +17,11 @@
#ifndef GUI_BUTTON_H_
#define GUI_BUTTON_H_
#include <gui/GuiElement.h>
#include <gui/GuiText.h>
#include <gui/GuiController.h>
#include <gui/GuiElement.h>
#include <gui/GuiImage.h>
#include <gui/GuiSound.h>
#include <gui/GuiText.h>
#include <gui/GuiTrigger.h>
#include <gui/gx2_ext.h>
@ -110,22 +110,23 @@ public:
sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> clicked;
sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> held;
sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> released;
protected:
static const int32_t iMaxGuiTriggers = 10;
GuiImage *image; //!< Button image (default)
GuiImage *imageOver; //!< Button image for STATE_SELECTED
GuiImage *imageHold; //!< Button image for STATE_HELD
GuiImage *image; //!< Button image (default)
GuiImage *imageOver; //!< Button image for STATE_SELECTED
GuiImage *imageHold; //!< Button image for STATE_HELD
GuiImage *imageClick; //!< Button image for STATE_CLICKED
GuiImage *icon;
GuiImage *iconOver;
GuiText *label[4]; //!< Label(s) to display (default)
GuiText *labelOver[4]; //!< Label(s) to display for STATE_SELECTED
GuiText *labelHold[4]; //!< Label(s) to display for STATE_HELD
GuiText *labelClick[4]; //!< Label(s) to display for STATE_CLICKED
GuiSound *soundOver; //!< Sound to play for STATE_SELECTED
GuiSound *soundHold; //!< Sound to play for STATE_HELD
GuiSound *soundClick; //!< Sound to play for STATE_CLICKED
GuiText *label[4]; //!< Label(s) to display (default)
GuiText *labelOver[4]; //!< Label(s) to display for STATE_SELECTED
GuiText *labelHold[4]; //!< Label(s) to display for STATE_HELD
GuiText *labelClick[4]; //!< Label(s) to display for STATE_CLICKED
GuiSound *soundOver; //!< Sound to play for STATE_SELECTED
GuiSound *soundHold; //!< Sound to play for STATE_HELD
GuiSound *soundClick; //!< Sound to play for STATE_CLICKED
GuiTrigger *trigger[iMaxGuiTriggers]; //!< GuiTriggers (input actions) that this element responds to
GuiTrigger *clickedTrigger;
GuiTrigger *heldTrigger;

View File

@ -17,9 +17,9 @@
#ifndef GUI_CHECKBOX_H_
#define GUI_CHECKBOX_H_
#include <gui/GuiToggle.h>
#include <gui/GuiImage.h>
#include <gui/GuiImageData.h>
#include <gui/GuiToggle.h>
//!A simple CheckBox
class GuiCheckBox : public GuiToggle {
@ -38,8 +38,8 @@ public:
void setImageHighlighted(GuiImage *img);
protected:
GuiImage *backgroundImg = NULL;
GuiImage *selectedImg = NULL;
GuiImage *backgroundImg = NULL;
GuiImage *selectedImg = NULL;
GuiImage *highlightedImg = NULL;
void update(GuiController *c);

View File

@ -17,14 +17,14 @@
#ifndef GUI_CONTROLLER_H_
#define GUI_CONTROLLER_H_
#include <string.h>
#include <gui/GuiTrigger.h>
#include <string.h>
class GuiController {
public:
//!Constructor
GuiController(int32_t channel)
: chan(channel) {
: chan(channel) {
memset(&lastData, 0, sizeof(lastData));
memset(&data, 0, sizeof(data));
@ -68,7 +68,6 @@ public:
int32_t chanIdx;
PadData data;
PadData lastData;
};
#endif

View File

@ -17,10 +17,10 @@
#ifndef GUI_DRAG_LISTENER_H_
#define GUI_DRAG_LISTENER_H_
#include <gui/GuiElement.h>
#include <gui/GuiController.h>
#include <gui/GuiTrigger.h>
#include <gui/GuiButton.h>
#include <gui/GuiController.h>
#include <gui/GuiElement.h>
#include <gui/GuiTrigger.h>
class GuiDragListener : public GuiElement {
public:
@ -44,6 +44,7 @@ public:
void update(GuiController *c);
sigslot::signal5<GuiDragListener *, const GuiController *, GuiTrigger *, int32_t, int32_t> dragged;
protected:
static const int32_t iMaxGuiTriggers = 10;

View File

@ -21,45 +21,45 @@
#include <vector>
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>
#include <math.h>
#include <gui/gx2_ext.h>
#include <gui/sigslot.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <gui/sigslot.h>
enum {
EFFECT_NONE = 0x00,
EFFECT_SLIDE_TOP = 0x01,
EFFECT_SLIDE_BOTTOM = 0x02,
EFFECT_SLIDE_RIGHT = 0x04,
EFFECT_SLIDE_LEFT = 0x08,
EFFECT_SLIDE_IN = 0x10,
EFFECT_SLIDE_OUT = 0x20,
EFFECT_SLIDE_FROM = 0x40,
EFFECT_FADE = 0x80,
EFFECT_SCALE = 0x100,
EFFECT_COLOR_TRANSITION = 0x200
EFFECT_NONE = 0x00,
EFFECT_SLIDE_TOP = 0x01,
EFFECT_SLIDE_BOTTOM = 0x02,
EFFECT_SLIDE_RIGHT = 0x04,
EFFECT_SLIDE_LEFT = 0x08,
EFFECT_SLIDE_IN = 0x10,
EFFECT_SLIDE_OUT = 0x20,
EFFECT_SLIDE_FROM = 0x40,
EFFECT_FADE = 0x80,
EFFECT_SCALE = 0x100,
EFFECT_COLOR_TRANSITION = 0x200
};
enum {
ALIGN_LEFT = 0x01,
ALIGN_CENTER = 0x02,
ALIGN_RIGHT = 0x04,
ALIGN_TOP = 0x10,
ALIGN_MIDDLE = 0x20,
ALIGN_BOTTOM = 0x40,
ALIGN_TOP_LEFT = ALIGN_LEFT | ALIGN_TOP,
ALIGN_TOP_CENTER = ALIGN_CENTER | ALIGN_TOP,
ALIGN_TOP_RIGHT = ALIGN_RIGHT | ALIGN_TOP,
ALIGN_CENTERED = ALIGN_CENTER | ALIGN_MIDDLE,
ALIGN_LEFT = 0x01,
ALIGN_CENTER = 0x02,
ALIGN_RIGHT = 0x04,
ALIGN_TOP = 0x10,
ALIGN_MIDDLE = 0x20,
ALIGN_BOTTOM = 0x40,
ALIGN_TOP_LEFT = ALIGN_LEFT | ALIGN_TOP,
ALIGN_TOP_CENTER = ALIGN_CENTER | ALIGN_TOP,
ALIGN_TOP_RIGHT = ALIGN_RIGHT | ALIGN_TOP,
ALIGN_CENTERED = ALIGN_CENTER | ALIGN_MIDDLE,
};
//!Forward declaration
@ -154,21 +154,21 @@ public:
if (alignment & ALIGN_TOP) {
float pHeight = 0.0f;
float pScale = 0.0f;
float pScale = 0.0f;
if (parentElement) {
pHeight = parentElement->getHeight();
pScale = parentElement->getScaleY();
pScale = parentElement->getScaleY();
}
pCenterY += pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY();
} else if (alignment & ALIGN_BOTTOM) {
float pHeight = 0.0f;
float pScale = 0.0f;
float pScale = 0.0f;
if (parentElement) {
pHeight = parentElement->getHeight();
pScale = parentElement->getScaleY();
pScale = parentElement->getScaleY();
}
pCenterY -= pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY();
@ -202,7 +202,7 @@ public:
//!\param w Width of element
//!\param h Height of element
virtual void setSize(float w, float h) {
width = w;
width = w;
height = h;
}
@ -471,10 +471,7 @@ public:
//!\param y Y coordinate
//!\return true if contained within, false otherwise
virtual bool isInside(float x, float y) {
return (x > (this->getCenterX() - getScaleX() * getWidth() * 0.5f)
&& x < (this->getCenterX() + getScaleX() * getWidth() * 0.5f)
&& y > (this->getCenterY() - getScaleY() * getHeight() * 0.5f)
&& y < (this->getCenterY() + getScaleY() * getHeight() * 0.5f));
return (x > (this->getCenterX() - getScaleX() * getWidth() * 0.5f) && x < (this->getCenterX() + getScaleX() * getWidth() * 0.5f) && y > (this->getCenterY() - getScaleY() * getHeight() * 0.5f) && y < (this->getCenterY() + getScaleY() * getHeight() * 0.5f));
}
//!Sets the element's position
@ -545,15 +542,15 @@ public:
} POINT;
enum {
STATE_DEFAULT = 0,
STATE_SELECTED = 0x01,
STATE_CLICKED = 0x02,
STATE_HELD = 0x04,
STATE_OVER = 0x08,
STATE_HIDDEN = 0x10,
STATE_DEFAULT = 0,
STATE_SELECTED = 0x01,
STATE_CLICKED = 0x02,
STATE_HELD = 0x04,
STATE_OVER = 0x08,
STATE_HIDDEN = 0x10,
STATE_DISABLE_INPUT = 0x20,
STATE_CLICKED_TOUCH = 0x40,
STATE_DISABLED = 0x80
STATE_DISABLED = 0x80
};
//! Switch pointer from control to screen position
@ -574,37 +571,38 @@ public:
sigslot::signal2<GuiElement *, bool> visibleChanged;
sigslot::signal3<GuiElement *, int32_t, int32_t> stateChanged;
sigslot::signal1<GuiElement *> effectFinished;
protected:
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
bool visible; //!< Visibility of the element. If false, Draw() is skipped
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
bool holdable; //!< Whether or not this element is holdable (can change to HELD state)
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
bool visible; //!< Visibility of the element. If false, Draw() is skipped
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
bool holdable; //!< Whether or not this element is holdable (can change to HELD state)
bool drawOverOnlyWhenSelected; //!< Whether or not this element is holdable (can change to HELD state)
float width; //!< Element width
float height; //!< Element height
float xoffset; //!< Element X offset
float yoffset; //!< Element Y offset
float zoffset; //!< Element Z offset
float alpha; //!< Element alpha value (0-255)
float angle; //!< Angle of the object (0-360)
float scaleX; //!< Element scale (1 = 100%)
float scaleY; //!< Element scale (1 = 100%)
float scaleZ; //!< Element scale (1 = 100%)
int32_t alignment; //!< Horizontal element alignment, respective to parent element
int32_t state[5]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
int32_t stateChan; //!< Which controller channel is responsible for the last change in state
GuiElement *parentElement; //!< Parent element
float width; //!< Element width
float height; //!< Element height
float xoffset; //!< Element X offset
float yoffset; //!< Element Y offset
float zoffset; //!< Element Z offset
float alpha; //!< Element alpha value (0-255)
float angle; //!< Angle of the object (0-360)
float scaleX; //!< Element scale (1 = 100%)
float scaleY; //!< Element scale (1 = 100%)
float scaleZ; //!< Element scale (1 = 100%)
int32_t alignment; //!< Horizontal element alignment, respective to parent element
int32_t state[5]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
int32_t stateChan; //!< Which controller channel is responsible for the last change in state
GuiElement *parentElement; //!< Parent element
//! TODO: Move me to some Animator class
int32_t xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects)
int32_t yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
float alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
float scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
int32_t effects; //!< Currently enabled effect(s). 0 when no effects are enabled
int32_t effectAmount; //!< Effect amount. Used by different effects for different purposes
int32_t effectTarget; //!< Effect target amount. Used by different effects for different purposes
int32_t effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event
int32_t xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects)
int32_t yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
float alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
float scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
int32_t effects; //!< Currently enabled effect(s). 0 when no effects are enabled
int32_t effectAmount; //!< Effect amount. Used by different effects for different purposes
int32_t effectTarget; //!< Effect target amount. Used by different effects for different purposes
int32_t effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event
int32_t effectAmountOver; //!< EffectAmount to set when wiimote cursor is over this element
int32_t effectTargetOver; //!< EffectTarget to set when wiimote cursor is over this element
};

View File

@ -17,10 +17,10 @@
#ifndef GUI_FRAME_H_
#define GUI_FRAME_H_
#include <vector>
#include <mutex>
#include <gui/GuiElement.h>
#include <gui/sigslot.h>
#include <mutex>
#include <vector>
//!Allows GuiElements to be grouped together into a "window"
class GuiFrame : public GuiElement {
@ -116,9 +116,10 @@ public:
//! Signals
//! On Closing
sigslot::signal1<GuiFrame *> closing;
protected:
bool dim; //! Enable/disable dim of a window only
GuiFrame *parent; //!< Parent Window
bool dim; //! Enable/disable dim of a window only
GuiFrame *parent; //!< Parent Window
std::vector<GuiElement *> elements; //!< Contains all elements within the GuiFrame
std::recursive_mutex mutex;
};

View File

@ -17,10 +17,10 @@
#ifndef GUI_IMAGE_H_
#define GUI_IMAGE_H_
#include <gui/video/shaders/Shader.h>
#include <gui/GuiElement.h>
#include <gui/GuiImageData.h>
#include <gui/gx2_ext.h>
#include <gui/video/shaders/Shader.h>
//!Display, manage, and manipulate images in the GUI
class GuiImage : public GuiElement {
@ -103,10 +103,10 @@ public:
protected:
void internalInit(int32_t w, int32_t h);
int32_t imgType; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA)
GuiImageData *imageData; //!< Poiner to image data. May be shared with GuiImageData data
int32_t tileHorizontal; //!< Number of times to draw (tile) the image horizontally
int32_t tileVertical; //!< Number of times to draw (tile) the image vertically
int32_t imgType; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA)
GuiImageData *imageData; //!< Poiner to image data. May be shared with GuiImageData data
int32_t tileHorizontal; //!< Number of times to draw (tile) the image horizontally
int32_t tileVertical; //!< Number of times to draw (tile) the image vertically
//! Internally used variables for rendering
uint8_t *colorVtxs;

View File

@ -17,10 +17,10 @@
#ifndef _GUIIMAGEASYNC_H_
#define _GUIIMAGEASYNC_H_
#include <mutex>
#include <vector>
#include <gui/GuiImage.h>
#include <gui/system/CThread.h>
#include <mutex>
#include <vector>
class GuiImageAsync : public GuiImage {
public:

View File

@ -51,15 +51,21 @@ public:
//!Gets the image width
//!\return image width
int32_t getWidth() const {
if (texture) { return texture->surface.width; }
else { return 0; }
if (texture) {
return texture->surface.width;
} else {
return 0;
}
};
//!Gets the image height
//!\return image height
int32_t getHeight() const {
if (texture) { return texture->surface.height; }
else { return 0; }
if (texture) {
return texture->surface.height;
} else {
return 0;
}
};
//! release memory of the image data

View File

@ -24,8 +24,8 @@
#ifndef GUI_SCROLLBAR_HPP_
#define GUI_SCROLLBAR_HPP_
#include <gui/GuiElement.h>
#include <gui/GuiButton.h>
#include <gui/GuiElement.h>
class GuiScrollbar : public GuiElement, public sigslot::has_slots<> {
public:
@ -139,9 +139,9 @@ protected:
GuiSound *clickSound = NULL;
GuiImage *scrollbarLineImage = NULL;
GuiImage *arrowDownImage = NULL;
GuiImage *arrowUpImage = NULL;
GuiImage *scrollbarBoxImage = NULL;
GuiImage *arrowDownImage = NULL;
GuiImage *arrowUpImage = NULL;
GuiImage *scrollbarBoxImage = NULL;
GuiTrigger touchTrigger;
GuiTrigger wpadTouchTrigger;

View File

@ -101,12 +101,12 @@ protected:
bool opened;
std::string captionText;
GuiFrame valuesFrame;
GuiImage *topBackgroundImg = NULL;
GuiImage *topBackgroundImg = NULL;
GuiImage *topHighlightedImg = NULL;
GuiButton topValueButton;
GuiImageData *valueImageData = NULL;
GuiImageData *valueSelectedImageData = NULL;
GuiImageData *valueImageData = NULL;
GuiImageData *valueSelectedImageData = NULL;
GuiImageData *valueHighlightedImageData = NULL;
GuiText topValueText;
@ -134,7 +134,6 @@ protected:
std::map<GuiButton *, std::string> buttonToValue;
std::vector<SelectBoxValueButton> valueButtons;
};
#endif

View File

@ -17,9 +17,9 @@
#ifndef GUI_SWTICH_H_
#define GUI_SWTICH_H_
#include <gui/GuiToggle.h>
#include <gui/GuiImage.h>
#include <gui/GuiImageData.h>
#include <gui/GuiToggle.h>
//!A simple switch
class GuiSwitch : public GuiToggle {
@ -40,10 +40,9 @@ public:
void setImageHighlighted(GuiImage *img);
protected:
GuiImage *backgroundImg = NULL;
GuiImage *onImg = NULL;
GuiImage *offImg = NULL;
GuiImage *backgroundImg = NULL;
GuiImage *onImg = NULL;
GuiImage *offImg = NULL;
GuiImage *highlightedImg = NULL;
void draw(CVideo *v);

View File

@ -152,7 +152,7 @@ public:
virtual void setSize(float w, float h) {
//! We calculate the size based on the text.
this->width = 0;
this->width = 0;
this->height = 0;
}
@ -167,6 +167,7 @@ public:
SCROLL_HORIZONTAL,
SCROLL_NONE
};
protected:
static FreeTypeGX *presentFont;
static int32_t presetSSAA;
@ -193,11 +194,11 @@ protected:
wchar_t *text;
std::vector<wchar_t *> textDyn;
std::vector<uint16_t> textDynWidth;
int32_t wrapMode; //!< Wrapping toggle
int32_t textScrollPos; //!< Current starting index of text string for scrolling
int32_t wrapMode; //!< Wrapping toggle
int32_t textScrollPos; //!< Current starting index of text string for scrolling
int32_t textScrollInitialDelay; //!< Delay to wait before starting to scroll
int32_t textScrollDelay; //!< Scrolling speed
int32_t maxWidth; //!< Maximum width of the generated text object (for text wrapping)
int32_t textScrollDelay; //!< Scrolling speed
int32_t maxWidth; //!< Maximum width of the generated text object (for text wrapping)
FreeTypeGX *font;
int32_t currentSize;
int32_t linestodraw;

View File

@ -40,7 +40,6 @@ public:
void setChecked() {
setValue(true);
}
void setUnchecked() {
@ -56,7 +55,6 @@ public:
void OnToggleClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
protected:
bool selected;
bool bChanged;

View File

@ -25,49 +25,49 @@ class GuiController;
class GuiTrigger {
public:
enum eClicked {
CLICKED_NONE = 0x00,
CLICKED_TOUCH = 0x01,
CLICKED_BUTTON = 0x02,
CLICKED_NONE = 0x00,
CLICKED_TOUCH = 0x01,
CLICKED_BUTTON = 0x02,
};
enum eChannels {
CHANNEL_1 = 0x01,
CHANNEL_2 = 0x02,
CHANNEL_3 = 0x04,
CHANNEL_4 = 0x08,
CHANNEL_5 = 0x10,
CHANNEL_ALL = 0xFF
CHANNEL_1 = 0x01,
CHANNEL_2 = 0x02,
CHANNEL_3 = 0x04,
CHANNEL_4 = 0x08,
CHANNEL_5 = 0x10,
CHANNEL_ALL = 0xFF
};
enum eButtons {
BUTTON_NONE = 0x0000,
VPAD_TOUCH = 0x80000000,
BUTTON_Z = 0x20000,
BUTTON_C = 0x10000,
BUTTON_A = 0x8000,
BUTTON_B = 0x4000,
BUTTON_X = 0x2000,
BUTTON_Y = 0x1000,
BUTTON_1 = BUTTON_Y,
BUTTON_2 = BUTTON_X,
BUTTON_LEFT = 0x0800,
BUTTON_RIGHT = 0x0400,
BUTTON_UP = 0x0200,
BUTTON_DOWN = 0x0100,
BUTTON_ZL = 0x0080,
BUTTON_ZR = 0x0040,
BUTTON_L = 0x0020,
BUTTON_R = 0x0010,
BUTTON_PLUS = 0x0008,
BUTTON_MINUS = 0x0004,
BUTTON_HOME = 0x0002,
BUTTON_SYNC = 0x0001,
STICK_R_LEFT = 0x04000000,
STICK_R_RIGHT = 0x02000000,
STICK_R_UP = 0x01000000,
STICK_R_DOWN = 0x00800000,
STICK_L_LEFT = 0x40000000,
STICK_L_RIGHT = 0x20000000,
STICK_L_UP = 0x10000000,
STICK_L_DOWN = 0x08000000
BUTTON_NONE = 0x0000,
VPAD_TOUCH = 0x80000000,
BUTTON_Z = 0x20000,
BUTTON_C = 0x10000,
BUTTON_A = 0x8000,
BUTTON_B = 0x4000,
BUTTON_X = 0x2000,
BUTTON_Y = 0x1000,
BUTTON_1 = BUTTON_Y,
BUTTON_2 = BUTTON_X,
BUTTON_LEFT = 0x0800,
BUTTON_RIGHT = 0x0400,
BUTTON_UP = 0x0200,
BUTTON_DOWN = 0x0100,
BUTTON_ZL = 0x0080,
BUTTON_ZR = 0x0040,
BUTTON_L = 0x0020,
BUTTON_R = 0x0010,
BUTTON_PLUS = 0x0008,
BUTTON_MINUS = 0x0004,
BUTTON_HOME = 0x0002,
BUTTON_SYNC = 0x0001,
STICK_R_LEFT = 0x04000000,
STICK_R_RIGHT = 0x02000000,
STICK_R_UP = 0x01000000,
STICK_R_DOWN = 0x00800000,
STICK_L_LEFT = 0x40000000,
STICK_L_RIGHT = 0x20000000,
STICK_L_UP = 0x10000000,
STICK_L_DOWN = 0x08000000
};
//!Constructor

View File

@ -24,7 +24,7 @@ class VPadController : public GuiController {
public:
//!Constructor
VPadController(int32_t channel)
: GuiController(channel) {
: GuiController(channel) {
memset(&vpad, 0, sizeof(vpad));
}
@ -38,11 +38,11 @@ public:
VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) {
data.buttons_r = vpad.release;
data.buttons_h = vpad.hold;
data.buttons_d = vpad.trigger;
data.buttons_r = vpad.release;
data.buttons_h = vpad.hold;
data.buttons_d = vpad.trigger;
data.validPointer = !vpad.tpNormal.validity;
data.touched = vpad.tpNormal.touched;
data.touched = vpad.tpNormal.touched;
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1);

View File

@ -25,7 +25,7 @@ class WPadController : public GuiController {
public:
//!Constructor
WPadController(int32_t channel)
: GuiController(channel) {
: GuiController(channel) {
memset(&kpadData, 0, sizeof(kpadData));
}

View File

@ -1,5 +1,5 @@
#ifndef __GX2_EXTENSION_H
#define __GX2_EXTENSION_H
#define __GX2_EXTENSION_H
#ifdef __cplusplus
extern "C" {
@ -14,19 +14,19 @@ extern "C" {
#include <gx2/surface.h>
#include <gx2/texture.h>
#define GX2_AA_BUFFER_CLEAR_VALUE 0xCC
#define GX2_AA_BUFFER_CLEAR_VALUE 0xCC
#define GX2_COMP_SEL_NONE 0x04040405
#define GX2_COMP_SEL_X001 0x00040405
#define GX2_COMP_SEL_XY01 0x00010405
#define GX2_COMP_SEL_XYZ1 0x00010205
#define GX2_COMP_SEL_XYZW 0x00010203
#define GX2_COMP_SEL_XXXX 0x00000000
#define GX2_COMP_SEL_YYYY 0x01010101
#define GX2_COMP_SEL_ZZZZ 0x02020202
#define GX2_COMP_SEL_WWWW 0x03030303
#define GX2_COMP_SEL_WZYX 0x03020100
#define GX2_COMP_SEL_WXYZ 0x03000102
#define GX2_COMP_SEL_NONE 0x04040405
#define GX2_COMP_SEL_X001 0x00040405
#define GX2_COMP_SEL_XY01 0x00010405
#define GX2_COMP_SEL_XYZ1 0x00010205
#define GX2_COMP_SEL_XYZW 0x00010203
#define GX2_COMP_SEL_XXXX 0x00000000
#define GX2_COMP_SEL_YYYY 0x01010101
#define GX2_COMP_SEL_ZZZZ 0x02020202
#define GX2_COMP_SEL_WWWW 0x03030303
#define GX2_COMP_SEL_WZYX 0x03020100
#define GX2_COMP_SEL_WXYZ 0x03000102
typedef struct _GX2Color {
uint8_t r, g, b, a;
@ -40,8 +40,7 @@ static const uint32_t attribute_dest_comp_selector[20] = {
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001,
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1,
GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW
};
GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW};
static const uint32_t texture_comp_selector[54] = {
GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001,
@ -52,58 +51,56 @@ static const uint32_t texture_comp_selector[54] = {
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001,
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1,
GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01
};
GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01};
static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, GX2SurfaceDim dim, uint32_t width, uint32_t height, uint32_t depth, GX2SurfaceFormat format, GX2AAMode aa) {
depthBuffer->surface.dim = dim;
depthBuffer->surface.width = width;
depthBuffer->surface.height = height;
depthBuffer->surface.depth = depth;
depthBuffer->surface.dim = dim;
depthBuffer->surface.width = width;
depthBuffer->surface.height = height;
depthBuffer->surface.depth = depth;
depthBuffer->surface.mipLevels = 1;
depthBuffer->surface.format = format;
depthBuffer->surface.aa = aa;
depthBuffer->surface.use = (GX2SurfaceUse) (((format == GX2_SURFACE_FORMAT_UNORM_R24_X8) || (format == GX2_SURFACE_FORMAT_FLOAT_D24_S8)) ?
GX2_SURFACE_USE_DEPTH_BUFFER : (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE));
depthBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
depthBuffer->surface.swizzle = 0;
depthBuffer->viewMip = 0;
depthBuffer->viewFirstSlice = 0;
depthBuffer->viewNumSlices = depth;
depthBuffer->depthClear = 1.0f;
depthBuffer->stencilClear = 0;
depthBuffer->hiZPtr = NULL;
depthBuffer->hiZSize = 0;
depthBuffer->surface.format = format;
depthBuffer->surface.aa = aa;
depthBuffer->surface.use = (GX2SurfaceUse) (((format == GX2_SURFACE_FORMAT_UNORM_R24_X8) || (format == GX2_SURFACE_FORMAT_FLOAT_D24_S8)) ? GX2_SURFACE_USE_DEPTH_BUFFER : (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE));
depthBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
depthBuffer->surface.swizzle = 0;
depthBuffer->viewMip = 0;
depthBuffer->viewFirstSlice = 0;
depthBuffer->viewNumSlices = depth;
depthBuffer->depthClear = 1.0f;
depthBuffer->stencilClear = 0;
depthBuffer->hiZPtr = NULL;
depthBuffer->hiZSize = 0;
GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface);
GX2InitDepthBufferRegs(depthBuffer);
}
static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim dim, uint32_t width, uint32_t height, uint32_t depth, GX2SurfaceFormat format, GX2AAMode aa) {
colorBuffer->surface.dim = dim;
colorBuffer->surface.width = width;
colorBuffer->surface.height = height;
colorBuffer->surface.depth = depth;
colorBuffer->surface.mipLevels = 1;
colorBuffer->surface.format = format;
colorBuffer->surface.aa = aa;
colorBuffer->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
colorBuffer->surface.imageSize = 0;
colorBuffer->surface.image = NULL;
colorBuffer->surface.dim = dim;
colorBuffer->surface.width = width;
colorBuffer->surface.height = height;
colorBuffer->surface.depth = depth;
colorBuffer->surface.mipLevels = 1;
colorBuffer->surface.format = format;
colorBuffer->surface.aa = aa;
colorBuffer->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
colorBuffer->surface.imageSize = 0;
colorBuffer->surface.image = NULL;
colorBuffer->surface.mipmapSize = 0;
colorBuffer->surface.mipmaps = NULL;
colorBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
colorBuffer->surface.swizzle = 0;
colorBuffer->surface.alignment = 0;
colorBuffer->surface.pitch = 0;
colorBuffer->surface.mipmaps = NULL;
colorBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
colorBuffer->surface.swizzle = 0;
colorBuffer->surface.alignment = 0;
colorBuffer->surface.pitch = 0;
uint32_t i;
for (i = 0; i < 13; i++) {
colorBuffer->surface.mipLevelOffset[i] = 0;
}
colorBuffer->viewMip = 0;
colorBuffer->viewMip = 0;
colorBuffer->viewFirstSlice = 0;
colorBuffer->viewNumSlices = depth;
colorBuffer->aaBuffer = NULL;
colorBuffer->aaSize = 0;
colorBuffer->viewNumSlices = depth;
colorBuffer->aaBuffer = NULL;
colorBuffer->aaSize = 0;
for (i = 0; i < 5; i++) {
colorBuffer->regs[i] = 0;
}
@ -113,42 +110,42 @@ static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim
}
static inline void GX2InitAttribStream(GX2AttribStream *attr, uint32_t location, uint32_t buffer, uint32_t offset, GX2AttribFormat format) {
attr->location = location;
attr->buffer = buffer;
attr->offset = offset;
attr->format = format;
attr->type = GX2_ATTRIB_INDEX_PER_VERTEX;
attr->location = location;
attr->buffer = buffer;
attr->offset = offset;
attr->format = format;
attr->type = GX2_ATTRIB_INDEX_PER_VERTEX;
attr->aluDivisor = 0;
attr->mask = attribute_dest_comp_selector[format & 0xff];
attr->mask = attribute_dest_comp_selector[format & 0xff];
attr->endianSwap = GX2_ENDIAN_SWAP_DEFAULT;
}
static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevels, GX2SurfaceFormat format, GX2SurfaceDim dim, GX2TileMode tile) {
tex->surface.dim = dim;
tex->surface.width = width;
tex->surface.height = height;
tex->surface.depth = depth;
tex->surface.mipLevels = mipLevels;
tex->surface.format = format;
tex->surface.aa = GX2_AA_MODE1X;
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
tex->surface.imageSize = 0;
tex->surface.image = NULL;
tex->surface.dim = dim;
tex->surface.width = width;
tex->surface.height = height;
tex->surface.depth = depth;
tex->surface.mipLevels = mipLevels;
tex->surface.format = format;
tex->surface.aa = GX2_AA_MODE1X;
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
tex->surface.imageSize = 0;
tex->surface.image = NULL;
tex->surface.mipmapSize = 0;
tex->surface.mipmaps = NULL;
tex->surface.tileMode = tile;
tex->surface.swizzle = 0;
tex->surface.alignment = 0;
tex->surface.pitch = 0;
tex->surface.mipmaps = NULL;
tex->surface.tileMode = tile;
tex->surface.swizzle = 0;
tex->surface.alignment = 0;
tex->surface.pitch = 0;
uint32_t i;
for (i = 0; i < 13; i++) {
tex->surface.mipLevelOffset[i] = 0;
}
tex->viewFirstMip = 0;
tex->viewNumMips = mipLevels;
tex->viewFirstMip = 0;
tex->viewNumMips = mipLevels;
tex->viewFirstSlice = 0;
tex->viewNumSlices = depth;
tex->compMap = texture_comp_selector[format & 0x3f];
tex->viewNumSlices = depth;
tex->compMap = texture_comp_selector[format & 0x3f];
for (i = 0; i < 5; i++) {
tex->regs[i] = 0;
}
@ -162,4 +159,3 @@ static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t heig
#endif
#endif

View File

@ -21,6 +21,7 @@
extern "C" {
#endif
#include <cstdint>
#include <malloc.h>
void libgui_memoryInitialize(void);

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,9 @@
#ifndef BUFFER_CIRCLE_HPP_
#define BUFFER_CIRCLE_HPP_
#include <vector>
#include <cstddef>
#include <stdint.h>
#include <vector>
class BufferCircle {
public:
@ -67,8 +68,11 @@ public:
//!> Get a buffer at a position
uint8_t *GetBuffer(int32_t pos) {
if (!Valid(pos)) { return NULL; }
else { return SoundBuffer[pos]; }
if (!Valid(pos)) {
return NULL;
} else {
return SoundBuffer[pos];
}
};
//!> Get current buffer size
@ -78,8 +82,11 @@ public:
//!> Get buffer size at position
uint32_t GetBufferSize(int32_t pos) {
if (!Valid(pos)) { return 0; }
else { return BufferSize[pos]; }
if (!Valid(pos)) {
return 0;
} else {
return BufferSize[pos];
}
};
//!> Is current buffer ready
@ -89,8 +96,11 @@ public:
//!> Is a buffer at a position ready
bool IsBufferReady(int32_t pos) {
if (!Valid(pos)) { return false; }
else { return BufferReady[pos]; }
if (!Valid(pos)) {
return false;
} else {
return BufferReady[pos];
}
};
//!> Set a buffer at a position to a ready state
@ -110,8 +120,11 @@ public:
}
inline uint16_t Prev() {
if (Size() == 0) { return 0; }
else { return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1; }
if (Size() == 0) {
return 0;
} else {
return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1;
}
}
protected:

View File

@ -26,9 +26,9 @@
#ifndef SOUND_DECODER_HPP
#define SOUND_DECODER_HPP
#include <string>
#include <mutex>
#include <gui/sounds/BufferCircle.hpp>
#include <mutex>
#include <string>
class CFile;
@ -91,7 +91,7 @@ public:
}
virtual void SetLoop(bool l) {
Loop = l;
Loop = l;
EndOfFile = false;
}
@ -119,12 +119,12 @@ public:
void EnableUpsample(void);
enum SoundFormats {
FORMAT_PCM_16_BIT = 0x0A,
FORMAT_PCM_8_BIT = 0x19,
FORMAT_PCM_16_BIT = 0x0A,
FORMAT_PCM_8_BIT = 0x19,
};
enum SoundChannels {
CHANNELS_MONO = 0x100,
CHANNELS_STEREO = 0x200
CHANNELS_MONO = 0x100,
CHANNELS_STEREO = 0x200
};
enum SoundType {
@ -133,6 +133,7 @@ public:
SOUND_OGG,
SOUND_WAV
};
protected:
void Init();

View File

@ -28,12 +28,12 @@
#include <vector>
#include <gui/system/CThread.h>
#include <gui/sounds/SoundDecoder.hpp>
#include <gui/sounds/Voice.h>
#include <gui/system/CThread.h>
#include <sndcore2/voice.h>
#define MAX_DECODERS 16 // can be increased up to 96
#define MAX_DECODERS 16 // can be increased up to 96
class SoundHandler : public CThread {
public:
@ -70,6 +70,7 @@ public:
bool IsDecoding() {
return Decoding;
};
protected:
SoundHandler();

View File

@ -17,12 +17,11 @@
#ifndef _AXSOUND_H_
#define _AXSOUND_H_
#include <sndcore2/voice.h>
#include <sndcore2/core.h>
#include <sndcore2/voice.h>
class Voice {
public:
enum VoicePriorities {
PRIO_MIN = 1,
PRIO_MAX = 31
@ -36,9 +35,9 @@ public:
};
Voice(int32_t prio)
: state(STATE_STOPPED) {
: state(STATE_STOPPED) {
lastLoopCounter = 0;
nextBufferSize = 0;
nextBufferSize = 0;
voice = AXAcquireVoice(prio, 0, 0);
if (voice) {
@ -50,9 +49,9 @@ public:
AXVoiceDeviceMixData mix[6];
memset(mix, 0, sizeof(mix));
mix[0].bus[0].volume = 0x8000;
mix[0].bus[0].delta = 0;
mix[0].bus[0].delta = 0;
mix[1].bus[0].volume = 0x8000;
mix[1].bus[0].delta = 0;
mix[1].bus[0].delta = 0;
AXSetVoiceDeviceMix(voice, 0, 0, mix);
AXSetVoiceDeviceMix(voice, 1, 0, mix);
@ -74,13 +73,13 @@ public:
memset(&voiceBuffer, 0, sizeof(voiceBuffer));
voiceBuffer.data = buffer;
voiceBuffer.dataType = format;
voiceBuffer.data = buffer;
voiceBuffer.dataType = format;
voiceBuffer.loopingEnabled = (nextBuffer == NULL) ? 0 : 1;
voiceBuffer.currentOffset = 0;
voiceBuffer.endOffset = (bufferSize >> 1) - 1;
voiceBuffer.loopOffset = ((nextBuffer - buffer) >> 1);
nextBufferSize = nextBufSize;
voiceBuffer.currentOffset = 0;
voiceBuffer.endOffset = (bufferSize >> 1) - 1;
voiceBuffer.loopOffset = ((nextBuffer - buffer) >> 1);
nextBufferSize = nextBufSize;
// TODO: handle support for 3.1.0 with dynamic libs instead of static linking it
//uint32_t samplesPerSec = (AXGetInputSamplesPerSec != 0) ? AXGetInputSamplesPerSec() : 32000;
@ -105,7 +104,7 @@ public:
if (voice) {
AXVoiceVeData data;
data.volume = vol >> 16;
data.delta = vol & 0xFFFF;
data.delta = vol & 0xFFFF;
AXSetVoiceVe(voice, &data);
}
}
@ -113,7 +112,7 @@ public:
void setNextBuffer(const uint8_t *buffer, uint32_t bufferSize) {
voiceBuffer.loopOffset = ((buffer - (const uint8_t *) voiceBuffer.data) >> 1);
nextBufferSize = bufferSize;
nextBufferSize = bufferSize;
AXSetVoiceLoopOffset(voice, voiceBuffer.loopOffset);
}

View File

@ -17,9 +17,9 @@
#ifndef CTHREAD_H_
#define CTHREAD_H_
#include <coreinit/thread.h>
#include <malloc.h>
#include <unistd.h>
#include <coreinit/thread.h>
class CThread {
public:
@ -27,7 +27,7 @@ public:
//! constructor
CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL)
: pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) {
: pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) {
//! save attribute assignment
iAttributes = iAttr;
//! allocate the thread
@ -127,19 +127,20 @@ public:
free(pThread);
}
pThread = NULL;
pThread = NULL;
pThreadStack = NULL;
}
//! Thread attributes
enum eCThreadAttributes {
eAttributeNone = 0x07,
eAttributeAffCore0 = 0x01,
eAttributeAffCore1 = 0x02,
eAttributeAffCore2 = 0x04,
eAttributeDetach = 0x08,
eAttributePinnedAff = 0x10
eAttributeNone = 0x07,
eAttributeAffCore0 = 0x01,
eAttributeAffCore1 = 0x02,
eAttributeAffCore2 = 0x04,
eAttributeDetach = 0x08,
eAttributePinnedAff = 0x10
};
private:
static int32_t threadCallback(int32_t argc, const char **argv) {
//! After call to start() continue with the internal function

View File

@ -17,16 +17,16 @@
#ifndef __CVIDEO_H_
#define __CVIDEO_H_
#include <gx2/sampler.h>
#include <gx2/draw.h>
#include <gx2/registers.h>
#include <gx2/context.h>
#include <gx2/clear.h>
#include <gx2/swap.h>
#include <gx2/state.h>
#include <gx2/event.h>
#include <gx2/display.h>
#include <gui/gx2_ext.h>
#include <gx2/clear.h>
#include <gx2/context.h>
#include <gx2/display.h>
#include <gx2/draw.h>
#include <gx2/event.h>
#include <gx2/registers.h>
#include <gx2/sampler.h>
#include <gx2/state.h>
#include <gx2/swap.h>
#include <gui/video/shaders/Shader.h>
@ -38,15 +38,15 @@ public:
void prepareTvRendering(void) {
currContextState = tvContextState;
currColorBuffer = &tvColorBuffer;
currDepthBuffer = &tvDepthBuffer;
currColorBuffer = &tvColorBuffer;
currDepthBuffer = &tvDepthBuffer;
prepareRendering();
}
void prepareDrcRendering(void) {
currContextState = drcContextState;
currColorBuffer = &drcColorBuffer;
currDepthBuffer = &drcDepthBuffer;
currColorBuffer = &drcColorBuffer;
currDepthBuffer = &drcDepthBuffer;
prepareRendering();
}
@ -156,7 +156,7 @@ public:
glm::vec4 rayStart(posX, posY, 0.0f, 1.0f);
glm::vec4 rayEnd(posX, posY, 1.0f, 1.0f);
glm::mat4 IMV = glm::inverse(projectionMtx * viewMtx);
glm::mat4 IMV = glm::inverse(projectionMtx * viewMtx);
glm::vec4 rayStartWorld = IMV * rayStart;
rayStartWorld /= rayStartWorld.w;
@ -166,7 +166,7 @@ public:
glm::vec3 rayDirectionWorld(rayEndWorld - rayStartWorld);
rayDirectionWorld = glm::normalize(rayDirectionWorld);
rayOrigin = glm::vec3(rayStartWorld);
rayOrigin = glm::vec3(rayStartWorld);
rayDirection = glm::normalize(rayDirectionWorld);
}

View File

@ -19,8 +19,8 @@
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
class CursorDrawer {

View File

@ -17,9 +17,9 @@
#ifndef __COLOR_SHADER_H_
#define __COLOR_SHADER_H_
#include <gui/video/shaders/VertexShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/FetchShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/VertexShader.h>
class ColorShader : public Shader {
private:
@ -27,7 +27,7 @@ private:
virtual ~ColorShader();
static const uint32_t cuAttributeCount = 2;
static const uint32_t cuAttributeCount = 2;
static const uint32_t cuPositionVtxsSize = 4 * cuVertexAttrSize;
static ColorShader *shaderInstance;
@ -44,6 +44,7 @@ private:
uint32_t colorLocation;
uint32_t colorIntensityLocation;
uint32_t positionLocation;
public:
static const uint32_t cuColorVtxsSize = 4 * cuColorAttrSize;

View File

@ -17,9 +17,9 @@
#ifndef __FXAA_SHADER_H_
#define __FXAA_SHADER_H_
#include <gui/video/shaders/VertexShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/FetchShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/VertexShader.h>
class FXAAShader : public Shader {
public:
@ -62,8 +62,8 @@ private:
virtual ~FXAAShader();
static const uint32_t cuAttributeCount = 2;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t cuAttributeCount = 2;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
static FXAAShader *shaderInstance;

View File

@ -22,7 +22,7 @@
class FetchShader : public Shader {
public:
FetchShader(GX2AttribStream *attributes, uint32_t attrCount, GX2FetchShaderType type = GX2_FETCH_SHADER_TESSELLATION_NONE, GX2TessellationMode tess = GX2_TESSELLATION_MODE_DISCRETE)
: fetchShader(NULL), fetchShaderProgramm(NULL) {
: fetchShader(NULL), fetchShaderProgramm(NULL) {
uint32_t shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess);
fetchShaderProgramm = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, shaderSize);
if (fetchShaderProgramm) {

View File

@ -22,7 +22,7 @@
class PixelShader : public Shader {
public:
PixelShader()
: pixelShader((GX2PixelShader *) memalign(0x40, sizeof(GX2PixelShader))) {
: pixelShader((GX2PixelShader *) memalign(0x40, sizeof(GX2PixelShader))) {
if (pixelShader) {
memset(pixelShader, 0, sizeof(GX2PixelShader));
pixelShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
@ -77,7 +77,7 @@ public:
}
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
pixelShader->size = programSize;
pixelShader->size = programSize;
pixelShader->program = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, pixelShader->size);
if (pixelShader->program) {
memcpy(pixelShader->program, program, pixelShader->size);

View File

@ -19,11 +19,11 @@
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <gx2/shaders.h>
#include <gx2/mem.h>
#include <gx2/enum.h>
#include <gx2/registers.h>
#include <gx2/draw.h>
#include <gx2/enum.h>
#include <gx2/mem.h>
#include <gx2/registers.h>
#include <gx2/shaders.h>
#include <malloc.h>
class Shader {
@ -33,9 +33,9 @@ protected:
virtual ~Shader() {}
public:
static const uint16_t cuVertexAttrSize = sizeof(float) * 3;
static const uint16_t cuVertexAttrSize = sizeof(float) * 3;
static const uint16_t cuTexCoordAttrSize = sizeof(float) * 2;
static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4;
static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4;
static void setLineWidth(const float &width) {
GX2SetLineWidth(width);

View File

@ -17,9 +17,9 @@
#ifndef SHADER_3D_H_
#define SHADER_3D_H_
#include <gui/video/shaders/VertexShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/FetchShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/VertexShader.h>
class Shader3D : public Shader {
private:
@ -30,8 +30,8 @@ private:
static Shader3D *shaderInstance;
static const unsigned char cuAttributeCount = 2;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
FetchShader *fetchShader;
VertexShader vertexShader;
@ -50,6 +50,7 @@ private:
uint32_t fadeDistanceLocation;
uint32_t fadeOutLocation;
uint32_t samplerLocation;
public:
static Shader3D *instance() {
if (!shaderInstance) {

View File

@ -17,9 +17,9 @@
#ifndef SHADER_FRACTAL_COLOR_H_
#define SHADER_FRACTAL_COLOR_H_
#include <gui/video/shaders/VertexShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/FetchShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/VertexShader.h>
class ShaderFractalColor : public Shader {
private:
@ -30,9 +30,9 @@ private:
static ShaderFractalColor *shaderInstance;
static const unsigned char cuAttributeCount = 3;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
static const uint32_t ciColorVtxsSize = 4 * cuColorAttrSize;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
static const uint32_t ciColorVtxsSize = 4 * cuColorAttrSize;
FetchShader *fetchShader;
VertexShader vertexShader;
@ -53,6 +53,7 @@ private:
uint32_t colorIntensityLocation;
uint32_t fadeOutLocation;
uint32_t fractalLocation;
public:
static ShaderFractalColor *instance() {
if (!shaderInstance) {

View File

@ -17,9 +17,9 @@
#ifndef __TEXTURE_2D_SHADER_H_
#define __TEXTURE_2D_SHADER_H_
#include <gui/video/shaders/VertexShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/FetchShader.h>
#include <gui/video/shaders/PixelShader.h>
#include <gui/video/shaders/VertexShader.h>
class Texture2DShader : public Shader {
@ -28,8 +28,8 @@ private:
virtual ~Texture2DShader();
static const uint32_t cuAttributeCount = 2;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t cuAttributeCount = 2;
static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize;
static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize;
static Texture2DShader *shaderInstance;
@ -49,6 +49,7 @@ private:
uint32_t samplerLocation;
uint32_t positionLocation;
uint32_t texCoordLocation;
public:
static Texture2DShader *instance() {
if (!shaderInstance) {

View File

@ -17,14 +17,14 @@
#ifndef VERTEX_SHADER_H
#define VERTEX_SHADER_H
#include <string.h>
#include <gui/video/shaders/Shader.h>
#include <gui/gx2_ext.h>
#include <gui/video/shaders/Shader.h>
#include <string.h>
class VertexShader : public Shader {
public:
VertexShader(uint32_t numAttr)
: attributesCount(numAttr), attributes(new GX2AttribStream[attributesCount]), vertexShader((GX2VertexShader *) memalign(0x40, sizeof(GX2VertexShader))) {
: attributesCount(numAttr), attributes(new GX2AttribStream[attributesCount]), vertexShader((GX2VertexShader *) memalign(0x40, sizeof(GX2VertexShader))) {
if (vertexShader) {
memset(vertexShader, 0, sizeof(GX2VertexShader));
vertexShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
@ -89,7 +89,7 @@ public:
}
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
vertexShader->size = programSize;
vertexShader->size = programSize;
vertexShader->program = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, vertexShader->size);
if (vertexShader->program) {
memcpy(vertexShader->program, program, vertexShader->size);

View File

@ -1,15 +1,15 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <fs/CFile.hpp>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
CFile::CFile() {
iFd = -1;
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
pos = 0;
}
CFile::CFile(const std::string &filepath, eOpenTypes mode) {
@ -35,7 +35,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) {
switch (mode) {
default:
case ReadOnly: // file must exist
case ReadOnly: // file must exist
openMode = O_RDONLY;
break;
case WriteOnly: // file will be created / zerod
@ -79,10 +79,10 @@ void CFile::close() {
::close(iFd);
}
iFd = -1;
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
pos = 0;
}
int32_t CFile::read(uint8_t *ptr, size_t size) {
@ -133,7 +133,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) {
}
int32_t CFile::seek(long int offset, int32_t origin) {
int32_t ret = 0;
int32_t ret = 0;
int64_t newPos = pos;
if (origin == SEEK_SET) {
@ -165,7 +165,7 @@ int32_t CFile::seek(long int offset, int32_t origin) {
int32_t CFile::fwrite(const char *format, ...) {
char tmp[512];
tmp[0] = 0;
tmp[0] = 0;
int32_t result = -1;
va_list va;
@ -178,5 +178,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result;
}

View File

@ -1,10 +1,10 @@
#ifndef CFILE_HPP_
#define CFILE_HPP_
#include <stdio.h>
#include <string>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <wut_types.h>

View File

@ -75,8 +75,8 @@ FreeTypeGX::~FreeTypeGX() {
wchar_t *FreeTypeGX::charToWideChar(const char *strChar) {
if (!strChar) { return NULL; }
size_t len = strlen(strChar) + 1;
wchar_t *strWChar = new(std::nothrow) wchar_t[len];
size_t len = strlen(strChar) + 1;
wchar_t *strWChar = new (std::nothrow) wchar_t[len];
if (!strWChar) { return NULL; }
size_t bt = mbstowcs(strWChar, strChar, len);
@ -112,7 +112,7 @@ char *FreeTypeGX::wideCharToUTF8(const wchar_t *strChar) {
}
}
char *pOut = new(std::nothrow) char[len];
char *pOut = new (std::nothrow) char[len];
if (!pOut) {
return NULL;
}
@ -194,7 +194,7 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
FT_Set_Pixel_Sizes(ftFace, 0, pixelSize);
ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6;
ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6;
ftData->ftgxAlign.descender = (int16_t) ftFace->size->metrics.descender >> 6;
FT_UInt gIndex;
@ -205,7 +205,7 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
if (ftFace->glyph->format == FT_GLYPH_FORMAT_BITMAP) {
FT_Bitmap *glyphBitmap = &ftFace->glyph->bitmap;
textureWidth = ALIGN4(glyphBitmap->width);
textureWidth = ALIGN4(glyphBitmap->width);
textureHeight = ALIGN4(glyphBitmap->rows);
if (textureWidth == 0) {
textureWidth = 4;
@ -214,19 +214,19 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
textureHeight = 4;
}
ftgxCharData *charData = &ftData->ftgxCharMap[charCode];
charData->renderOffsetX = (int16_t) ftFace->glyph->bitmap_left;
charData->glyphAdvanceX = (uint16_t) (ftFace->glyph->advance.x >> 6);
charData->glyphAdvanceY = (uint16_t) (ftFace->glyph->advance.y >> 6);
charData->glyphIndex = (uint32_t) gIndex;
charData->renderOffsetY = (int16_t) ftFace->glyph->bitmap_top;
ftgxCharData *charData = &ftData->ftgxCharMap[charCode];
charData->renderOffsetX = (int16_t) ftFace->glyph->bitmap_left;
charData->glyphAdvanceX = (uint16_t) (ftFace->glyph->advance.x >> 6);
charData->glyphAdvanceY = (uint16_t) (ftFace->glyph->advance.y >> 6);
charData->glyphIndex = (uint32_t) gIndex;
charData->renderOffsetY = (int16_t) ftFace->glyph->bitmap_top;
charData->renderOffsetMax = (int16_t) ftFace->glyph->bitmap_top;
charData->renderOffsetMin = (int16_t) glyphBitmap->rows - ftFace->glyph->bitmap_top;
int16_t oldMax = ftData->ftgxAlign.max;
int16_t oldMax = ftData->ftgxAlign.max;
ftData->ftgxAlign.max = charData->renderOffsetMax > oldMax ? charData->renderOffsetMax : oldMax;
int16_t oldMin = ftData->ftgxAlign.min;
int16_t oldMin = ftData->ftgxAlign.min;
ftData->ftgxAlign.min = charData->renderOffsetMin > oldMin ? charData->renderOffsetMin : oldMin;
//! Initialize texture
@ -290,13 +290,13 @@ bool FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
memset(charData->texture->surface.image, 0x00, charData->texture->surface.imageSize);
uint8_t *src = (uint8_t *) bmp->buffer;
uint8_t *src = (uint8_t *) bmp->buffer;
uint16_t *dst = (uint16_t *) charData->texture->surface.image;
uint32_t x, y;
for (y = 0; y < bmp->rows; y++) {
for (x = 0; x < bmp->width; x++) {
uint8_t intensity = src[y * bmp->width + x] >> 3;
uint8_t intensity = src[y * bmp->width + x] >> 3;
dst[y * charData->texture->surface.pitch + x] = intensity ? ((intensity << 11) | (intensity << 6) | (intensity << 1) | 1) : 0;
}
}
@ -317,7 +317,9 @@ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
return 0;
} else if (format & FTGX_JUSTIFY_CENTER) {
return -(width >> 1);
} else if (format & FTGX_JUSTIFY_RIGHT) { return -width; }
} else if (format & FTGX_JUSTIFY_RIGHT) {
return -width;
}
return 0;
}
@ -434,7 +436,7 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) {
if (!text) { return 0; }
uint16_t strWidth = 0;
int32_t i = 0;
int32_t i = 0;
while (text[i]) {
strWidth += getCharWidth(text[i], pixelSize, i > 0 ? text[i - 1] : 0);
++i;
@ -446,7 +448,7 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) {
* Single char width
*/
uint16_t FreeTypeGX::getCharWidth(const wchar_t wChar, int16_t pixelSize, const wchar_t prevChar) {
uint16_t strWidth = 0;
uint16_t strWidth = 0;
ftgxCharData *glyphData = cacheGlyphData(wChar, pixelSize);
if (glyphData != NULL) {
@ -510,12 +512,12 @@ uint16_t FreeTypeGX::getHeight(const wchar_t *text, int16_t pixelSize) {
void FreeTypeGX::copyTextureToFramebuffer(CVideo *pVideo, GX2Texture *texture, int16_t x, int16_t y, int16_t z, const glm::vec4 &color, const float &defaultBlur, const float &blurIntensity, const glm::vec4 &blurColor,
const float &superSamplingScale) {
static const float imageAngle = 0.0f;
static const float blurScale = (2.0f);
static const float blurScale = (2.0f);
float offsetLeft = blurScale * (1.0f / superSamplingScale) * ((float) x + 0.5f * (float) texture->surface.width) * (float) pVideo->getWidthScaleFactor();
float offsetTop = blurScale * (1.0f / superSamplingScale) * ((float) y - 0.5f * (float) texture->surface.height) * (float) pVideo->getHeightScaleFactor();
float offsetTop = blurScale * (1.0f / superSamplingScale) * ((float) y - 0.5f * (float) texture->surface.height) * (float) pVideo->getHeightScaleFactor();
float widthScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.width * pVideo->getWidthScaleFactor();
float widthScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.width * pVideo->getWidthScaleFactor();
float heightScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.height * pVideo->getHeightScaleFactor();
glm::vec3 positionOffsets(offsetLeft, offsetTop, (float) z);

View File

@ -3,8 +3,8 @@
#include <gui/video/shaders/Shader3D.h>
GameBgImage::GameBgImage(const std::string &filename, GuiImageData *preloadImage)
: GuiImageAsync(filename, preloadImage) {
identity = glm::mat4(1.0f);
: GuiImageAsync(filename, preloadImage) {
identity = glm::mat4(1.0f);
alphaFadeOut = glm::vec4(1.0f, 0.075f, 5.305f, 2.0f);
}
@ -17,15 +17,15 @@ void GameBgImage::draw(CVideo *pVideo) {
}
//! first setup 2D GUI positions
float currPosX = getCenterX();
float currPosY = getCenterY();
float currPosZ = getDepth();
float currPosX = getCenterX();
float currPosY = getCenterY();
float currPosZ = getDepth();
float currScaleX = getScaleX() * (float) getWidth() * pVideo->getWidthScaleFactor();
float currScaleY = getScaleY() * (float) getHeight() * pVideo->getHeightScaleFactor();
float currScaleZ = getScaleZ() * (float) getWidth() * pVideo->getDepthScaleFactor();
glm::mat4 m_modelView = glm::translate(identity, glm::vec3(currPosX, currPosY, currPosZ));
m_modelView = glm::scale(m_modelView, glm::vec3(currScaleX, currScaleY, currScaleZ));
m_modelView = glm::scale(m_modelView, glm::vec3(currScaleX, currScaleY, currScaleZ));
Shader3D::instance()->setShaders();
Shader3D::instance()->setProjectionMtx(identity);

View File

@ -1,25 +1,25 @@
#include "utils/utils.h"
#include <gui/GridBackground.h>
#include <gui/video/CVideo.h>
#include <gui/video/shaders/Shader3D.h>
#include "utils/utils.h"
static const float bgRepeat = 1000.0f;
static const float bgRepeat = 1000.0f;
static const float bgTexRotate = 39.0f;
GridBackground::GridBackground(GuiImageData *img)
: GuiImage(img) {
colorIntensity = glm::vec4(1.0f, 1.0f, 1.0f, 0.9f);
alphaFadeOut = glm::vec4(0.0f);
: GuiImage(img) {
colorIntensity = glm::vec4(1.0f, 1.0f, 1.0f, 0.9f);
alphaFadeOut = glm::vec4(0.0f);
distanceFadeOut = 0.15f;
vtxCount = 4;
//! texture and vertex coordinates
float *m_posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuVertexAttrSize);
float *m_posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuVertexAttrSize);
float *m_texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuTexCoordAttrSize);
if (m_posVtxs) {
int32_t i = 0;
int32_t i = 0;
m_posVtxs[i++] = -1.0f;
m_posVtxs[i++] = 0.0f;
m_posVtxs[i++] = 1.0f;
@ -49,13 +49,11 @@ GridBackground::GridBackground(GuiImageData *img)
const float cosRot = cosf(DegToRad(bgTexRotate));
const float sinRot = sinf(DegToRad(bgTexRotate));
glm::mat2 texRotateMtx({
cosRot, -sinRot,
sinRot, cosRot
});
glm::mat2 texRotateMtx({cosRot, -sinRot,
sinRot, cosRot});
for (int32_t i = 0; i < 4; i++) {
texCoordVec[i] = texRotateMtx * texCoordVec[i];
texCoordVec[i] = texRotateMtx * texCoordVec[i];
m_texCoords[i * 2 + 0] = texCoordVec[i][0];
m_texCoords[i * 2 + 1] = texCoordVec[i][1];
}
@ -64,7 +62,7 @@ GridBackground::GridBackground(GuiImageData *img)
}
//! assign to internal variables which are const but oh well
posVtxs = m_posVtxs;
posVtxs = m_posVtxs;
texCoords = m_texCoords;
}

View File

@ -15,41 +15,41 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/GuiButton.h>
#include <gui/GuiTrigger.h>
#include <gui/GuiController.h>
#include <gui/GuiTrigger.h>
/**
* Constructor for the GuiButton class.
*/
GuiButton::GuiButton(float w, float h) {
width = w;
height = h;
image = NULL;
imageOver = NULL;
imageHold = NULL;
width = w;
height = h;
image = NULL;
imageOver = NULL;
imageHold = NULL;
imageClick = NULL;
icon = NULL;
iconOver = NULL;
icon = NULL;
iconOver = NULL;
for (int32_t i = 0; i < 4; i++) {
label[i] = NULL;
labelOver[i] = NULL;
labelHold[i] = NULL;
label[i] = NULL;
labelOver[i] = NULL;
labelHold[i] = NULL;
labelClick[i] = NULL;
}
for (int32_t i = 0; i < iMaxGuiTriggers; i++) {
trigger[i] = NULL;
}
soundOver = NULL;
soundHold = NULL;
soundClick = NULL;
soundOver = NULL;
soundHold = NULL;
soundClick = NULL;
clickedTrigger = NULL;
heldTrigger = NULL;
selectable = true;
holdable = false;
clickable = true;
heldTrigger = NULL;
selectable = true;
holdable = false;
clickable = true;
}
/**
@ -135,7 +135,7 @@ void GuiButton::setTrigger(GuiTrigger *t, int32_t idx) {
void GuiButton::resetState(void) {
clickedTrigger = NULL;
heldTrigger = NULL;
heldTrigger = NULL;
GuiElement::resetState();
}
@ -193,7 +193,7 @@ void GuiButton::update(GuiController *c) {
if (effectsOver && !effects) {
// initiate effects
effects = effectsOver;
effects = effectsOver;
effectAmount = effectAmountOver;
effectTarget = effectTargetOver;
}
@ -206,7 +206,7 @@ void GuiButton::update(GuiController *c) {
if (effectTarget == effectTargetOver && effectAmount == effectAmountOver) {
// initiate effects (in reverse)
effects = effectsOver;
effects = effectsOver;
effectAmount = -effectAmountOver;
effectTarget = 100;
}
@ -223,8 +223,7 @@ void GuiButton::update(GuiController *c) {
int32_t isClicked = trigger[i]->clicked(c);
if (!clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE)
&& (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
if (!clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE) && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
if (soundClick) {
soundClick->Play();
}
@ -253,8 +252,7 @@ void GuiButton::update(GuiController *c) {
if (holdable) {
bool isHeld = trigger[i]->held(c);
if ((!heldTrigger || heldTrigger == trigger[i]) && isHeld
&& (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
if ((!heldTrigger || heldTrigger == trigger[i]) && isHeld && (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
heldTrigger = trigger[i];
if (!isStateSet(STATE_HELD, c->chanIdx)) {

View File

@ -23,7 +23,7 @@
*/
GuiCheckBox::GuiCheckBox(GuiImage *background, bool checked, float width, float height)
: GuiToggle(checked, width, height) {
: GuiToggle(checked, width, height) {
setImageBackground(background);
}
@ -31,7 +31,6 @@ GuiCheckBox::GuiCheckBox(GuiImage *background, bool checked, float width, float
* Destructor for the GuiCheckBox class.
*/
GuiCheckBox::~GuiCheckBox() {
}
void GuiCheckBox::setImageBackground(GuiImage *img) {

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/GuiDragListener.h>
#include <gui/GuiController.h>
#include <gui/GuiDragListener.h>
/**
* Constructor for the GuiDragListener class.
*/
GuiDragListener::GuiDragListener(float w, float h) {
width = w;
width = w;
height = h;
for (int32_t i = 0; i < iMaxGuiTriggers; i++) {
trigger[i] = NULL;

View File

@ -17,7 +17,7 @@
#include <gui/GuiElement.h>
//! TODO remove this!
static int32_t screenwidth = 1280;
static int32_t screenwidth = 1280;
static int32_t screenheight = 720;
/**
@ -27,34 +27,34 @@ GuiElement::GuiElement() {
xoffset = 0.0f;
yoffset = 0.0f;
zoffset = 0.0f;
width = 0.0f;
height = 0.0f;
alpha = 1.0f;
scaleX = 1.0f;
scaleY = 1.0f;
scaleZ = 1.0f;
width = 0.0f;
height = 0.0f;
alpha = 1.0f;
scaleX = 1.0f;
scaleY = 1.0f;
scaleZ = 1.0f;
for (int32_t i = 0; i < 5; i++) {
state[i] = STATE_DEFAULT;
}
stateChan = -1;
parentElement = NULL;
rumble = true;
selectable = false;
clickable = false;
holdable = false;
stateChan = -1;
parentElement = NULL;
rumble = true;
selectable = false;
clickable = false;
holdable = false;
drawOverOnlyWhenSelected = false;
visible = true;
yoffsetDyn = 0;
xoffsetDyn = 0;
alphaDyn = -1;
scaleDyn = 1;
effects = EFFECT_NONE;
effectAmount = 0;
effectTarget = 0;
effectsOver = EFFECT_NONE;
effectAmountOver = 0;
effectTargetOver = 0;
angle = 0.0f;
visible = true;
yoffsetDyn = 0;
xoffsetDyn = 0;
alphaDyn = -1;
scaleDyn = 1;
effects = EFFECT_NONE;
effectAmount = 0;
effectTarget = 0;
effectsOver = EFFECT_NONE;
effectAmountOver = 0;
effectTargetOver = 0;
angle = 0.0f;
// default alignment - align to top left
alignment = (ALIGN_CENTER | ALIGN_MIDDLE);
@ -66,13 +66,13 @@ GuiElement::GuiElement() {
* @return Left position in pixel.
*/
float GuiElement::getLeft() {
float pWidth = 0;
float pLeft = 0;
float pWidth = 0;
float pLeft = 0;
float pScaleX = 1.0f;
if (parentElement) {
pWidth = parentElement->getWidth();
pLeft = parentElement->getLeft();
pWidth = parentElement->getWidth();
pLeft = parentElement->getLeft();
pScaleX = parentElement->getScaleX();
}
@ -97,12 +97,12 @@ float GuiElement::getLeft() {
*/
float GuiElement::getTop() {
float pHeight = 0;
float pTop = 0;
float pTop = 0;
float pScaleY = 1.0f;
if (parentElement) {
pHeight = parentElement->getHeight();
pTop = parentElement->getTop();
pTop = parentElement->getTop();
pScaleY = parentElement->getScaleY();
}
@ -170,14 +170,14 @@ void GuiElement::setEffectOnOver(int32_t e, int32_t a, int32_t t) {
}
void GuiElement::resetEffects() {
yoffsetDyn = 0;
xoffsetDyn = 0;
alphaDyn = -1;
scaleDyn = 1;
effects = EFFECT_NONE;
effectAmount = 0;
effectTarget = 0;
effectsOver = EFFECT_NONE;
yoffsetDyn = 0;
xoffsetDyn = 0;
alphaDyn = -1;
scaleDyn = 1;
effects = EFFECT_NONE;
effectAmount = 0;
effectTarget = 0;
effectsOver = EFFECT_NONE;
effectAmountOver = 0;
effectTargetOver = 0;
}
@ -194,7 +194,7 @@ void GuiElement::updateEffects() {
if (xoffsetDyn >= 0) {
xoffsetDyn = 0;
effects = 0;
effects = 0;
effectFinished(this);
}
} else if (effects & EFFECT_SLIDE_RIGHT) {
@ -202,7 +202,7 @@ void GuiElement::updateEffects() {
if (xoffsetDyn <= 0) {
xoffsetDyn = 0;
effects = 0;
effects = 0;
effectFinished(this);
}
} else if (effects & EFFECT_SLIDE_TOP) {
@ -210,7 +210,7 @@ void GuiElement::updateEffects() {
if (yoffsetDyn >= 0) {
yoffsetDyn = 0;
effects = 0;
effects = 0;
effectFinished(this);
}
} else if (effects & EFFECT_SLIDE_BOTTOM) {
@ -218,7 +218,7 @@ void GuiElement::updateEffects() {
if (yoffsetDyn <= 0) {
yoffsetDyn = 0;
effects = 0;
effects = 0;
effectFinished(this);
}
}
@ -270,20 +270,19 @@ void GuiElement::updateEffects() {
if (effectAmount < 0 && alphaDyn <= 0) {
alphaDyn = 0;
effects = 0; // shut off effect
effects = 0; // shut off effect
effectFinished(this);
} else if (effectAmount > 0 && alphaDyn >= alpha) {
alphaDyn = alpha;
effects = 0; // shut off effect
effects = 0; // shut off effect
effectFinished(this);
}
} else if (effects & EFFECT_SCALE) {
scaleDyn += effectAmount * 0.01f;
if ((effectAmount < 0 && scaleDyn <= (effectTarget * 0.01f))
|| (effectAmount > 0 && scaleDyn >= (effectTarget * 0.01f))) {
if ((effectAmount < 0 && scaleDyn <= (effectTarget * 0.01f)) || (effectAmount > 0 && scaleDyn >= (effectTarget * 0.01f))) {
scaleDyn = effectTarget * 0.01f;
effects = 0; // shut off effect
effects = 0; // shut off effect
effectFinished(this);
}
}

View File

@ -18,9 +18,9 @@
GuiFrame::GuiFrame(GuiFrame *p) {
parent = p;
width = 0;
width = 0;
height = 0;
dim = false;
dim = false;
if (parent) {
parent->append(this);
@ -29,9 +29,9 @@ GuiFrame::GuiFrame(GuiFrame *p) {
GuiFrame::GuiFrame(float w, float h, GuiFrame *p) {
parent = p;
width = w;
width = w;
height = h;
dim = false;
dim = false;
if (parent) {
parent->append(this);

View File

@ -14,17 +14,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "utils/utils.h"
#include <gui/GuiImage.h>
#include <gui/video/CVideo.h>
#include <gui/video/shaders/Texture2DShader.h>
#include <gui/video/shaders/ColorShader.h>
#include "utils/utils.h"
#include <gui/video/shaders/Texture2DShader.h>
static const float fPiDiv180 = ((float) M_PI / 180.0f);
GuiImage::GuiImage(GuiImageData *img) {
if (img && img->getTexture()) {
width = img->getWidth();
width = img->getWidth();
height = img->getHeight();
}
@ -34,7 +34,7 @@ GuiImage::GuiImage(GuiImageData *img) {
GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color &c, int32_t type) {
internalInit(w, h);
imgType = type;
imgType = type;
colorCount = ColorShader::cuColorVtxsSize / ColorShader::cuColorAttrSize;
colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, colorCount * ColorShader::cuColorAttrSize);
@ -47,7 +47,7 @@ GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color &c, int32_t type) {
GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color *c, uint32_t color_count, int32_t type) {
internalInit(w, h);
imgType = type;
imgType = type;
colorCount = ColorShader::cuColorVtxsSize / ColorShader::cuColorAttrSize;
if (colorCount < color_count) {
colorCount = color_count;
@ -74,33 +74,33 @@ GuiImage::~GuiImage() {
}
void GuiImage::internalInit(int32_t w, int32_t h) {
imageData = NULL;
width = w;
height = h;
imageData = NULL;
width = w;
height = h;
tileHorizontal = -1;
tileVertical = -1;
imgType = IMAGE_TEXTURE;
tileVertical = -1;
imgType = IMAGE_TEXTURE;
colorVtxsDirty = false;
colorVtxs = NULL;
colorCount = 0;
posVtxs = NULL;
texCoords = NULL;
vtxCount = 4;
primitive = GX2_PRIMITIVE_MODE_QUADS;
colorVtxs = NULL;
colorCount = 0;
posVtxs = NULL;
texCoords = NULL;
vtxCount = 4;
primitive = GX2_PRIMITIVE_MODE_QUADS;
imageAngle = 0.0f;
blurDirection = glm::vec3(0.0f);
imageAngle = 0.0f;
blurDirection = glm::vec3(0.0f);
positionOffsets = glm::vec3(0.0f);
scaleFactor = glm::vec3(1.0f);
colorIntensity = glm::vec4(1.0f);
scaleFactor = glm::vec3(1.0f);
colorIntensity = glm::vec4(1.0f);
}
void GuiImage::setImageData(GuiImageData *img) {
imageData = img;
width = 0;
height = 0;
width = 0;
height = 0;
if (img && img->getTexture()) {
width = img->getWidth();
width = img->getWidth();
height = img->getHeight();
}
imgType = IMAGE_TEXTURE;
@ -108,12 +108,11 @@ void GuiImage::setImageData(GuiImageData *img) {
GX2Color GuiImage::getPixel(int32_t x, int32_t y) {
if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) {
return (GX2Color) {
0, 0, 0, 0
};
return (GX2Color){
0, 0, 0, 0};
}
uint32_t pitch = imageData->getTexture()->surface.pitch;
uint32_t pitch = imageData->getTexture()->surface.pitch;
uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image;
uint32_t color_u32 = imagePtr[y * pitch + x];
@ -131,8 +130,8 @@ void GuiImage::setPixel(int32_t x, int32_t y, const GX2Color &color) {
}
uint32_t pitch = imageData->getTexture()->surface.pitch;
uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image;
uint32_t pitch = imageData->getTexture()->surface.pitch;
uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image;
imagePtr[y * pitch + x] = (color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0);
}
@ -146,7 +145,7 @@ void GuiImage::setImageColor(const GX2Color &c, int32_t idx) {
colorVtxs[(idx << 2) + 1] = c.g;
colorVtxs[(idx << 2) + 2] = c.b;
colorVtxs[(idx << 2) + 3] = c.a;
colorVtxsDirty = true;
colorVtxsDirty = true;
} else if (colorVtxs) {
for (uint32_t i = 0; i < (ColorShader::cuColorVtxsSize / sizeof(uint8_t)); i += 4) {
colorVtxs[i + 0] = c.r;
@ -159,14 +158,14 @@ void GuiImage::setImageColor(const GX2Color &c, int32_t idx) {
}
void GuiImage::setSize(int32_t w, int32_t h) {
width = w;
width = w;
height = h;
}
void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float *texCoord, uint32_t vtxcount) {
primitive = prim;
vtxCount = vtxcount;
posVtxs = posVtx;
vtxCount = vtxcount;
posVtxs = posVtx;
texCoords = texCoord;
if (imgType == IMAGE_COLOR) {
@ -174,7 +173,7 @@ void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float
for (uint32_t i = 0; i < vtxCount; i++) {
int32_t newColorIdx = (i << 2);
int32_t colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2);
int32_t colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2);
newColorVtxs[newColorIdx + 0] = colorVtxs[colorIdx + 0];
newColorVtxs[newColorIdx + 1] = colorVtxs[colorIdx + 1];
@ -183,8 +182,8 @@ void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float
}
free(colorVtxs);
colorVtxs = newColorVtxs;
colorCount = vtxCount;
colorVtxs = newColorVtxs;
colorCount = vtxCount;
colorVtxsDirty = true;
}
}
@ -211,38 +210,38 @@ void GuiImage::draw(CVideo *pVideo) {
//! angle of the object
imageAngle = DegToRad(getAngle());
// if(image && tileHorizontal > 0 && tileVertical > 0)
// {
// for(int32_t n=0; n<tileVertical; n++)
// for(int32_t i=0; i<tileHorizontal; i++)
// {
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft+width*i, currTop+width*n, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft+width*i, currTop+width*n, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
// else if(image && tileHorizontal > 0)
// {
// for(int32_t i=0; i<tileHorizontal; i++)
// {
// int32_t widthTile = (imageangle == 90 || imageangle == 270) ? height : width;
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft+widthTile*i, currTop, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft+widthTile*i, currTop, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
// else if(image && tileVertical > 0)
// {
// for(int32_t i=0; i<tileVertical; i++)
// {
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft, currTop+height*i, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft, currTop+height*i, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
// if(image && tileHorizontal > 0 && tileVertical > 0)
// {
// for(int32_t n=0; n<tileVertical; n++)
// for(int32_t i=0; i<tileHorizontal; i++)
// {
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft+width*i, currTop+width*n, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft+width*i, currTop+width*n, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
// else if(image && tileHorizontal > 0)
// {
// for(int32_t i=0; i<tileHorizontal; i++)
// {
// int32_t widthTile = (imageangle == 90 || imageangle == 270) ? height : width;
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft+widthTile*i, currTop, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft+widthTile*i, currTop, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
// else if(image && tileVertical > 0)
// {
// for(int32_t i=0; i<tileVertical; i++)
// {
// if(bUnCut)
// Menu_DrawImg(image, width, height, format, currLeft, currTop+height*i, currZ, imageangle, currScaleX, currScaleY, currAlpha);
// else
// Menu_DrawImgCut(image, width, height, format, currLeft, currTop+height*i, currZ, imageangle, currScaleX, currScaleY, currAlpha, cutBoundsRect.x1(), cutBoundsRect.x2(), cutBoundsRect.y1(), cutBoundsRect.y2());
// }
// }
if (colorVtxsDirty && colorVtxs) {
//! flush color vertex only on main GX2 thread
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, colorVtxs, colorCount * ColorShader::cuColorAttrSize);

View File

@ -14,25 +14,25 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <unistd.h>
#include <gui/GuiImageAsync.h>
#include "../fs/CFile.hpp"
#include <gui/GuiImageAsync.h>
#include <unistd.h>
std::vector<GuiImageAsync *> GuiImageAsync::imageQueue;
CThread *GuiImageAsync::pThread = NULL;
CThread *GuiImageAsync::pThread = NULL;
std::recursive_mutex *GuiImageAsync::pMutex = NULL;
uint32_t GuiImageAsync::threadRefCounter = 0;
bool GuiImageAsync::bExitRequested = false;
GuiImageAsync *GuiImageAsync::pInUse = NULL;
uint32_t GuiImageAsync::threadRefCounter = 0;
bool GuiImageAsync::bExitRequested = false;
GuiImageAsync *GuiImageAsync::pInUse = NULL;
GuiImageAsync::GuiImageAsync(const uint8_t *imageBuffer, const uint32_t &imageBufferSize, GuiImageData *preloadImg)
: GuiImage(preloadImg), imgData(NULL), imgBuffer(imageBuffer), imgBufferSize(imageBufferSize) {
: GuiImage(preloadImg), imgData(NULL), imgBuffer(imageBuffer), imgBufferSize(imageBufferSize) {
threadInit();
threadAddImage(this);
}
GuiImageAsync::GuiImageAsync(const std::string &file, GuiImageData *preloadImg)
: GuiImage(preloadImg), imgData(NULL), filename(file), imgBuffer(NULL), imgBufferSize(0) {
: GuiImage(preloadImg), imgData(NULL), filename(file), imgBuffer(NULL), imgBufferSize(0) {
threadInit();
threadAddImage(this);
}
@ -93,17 +93,17 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
if (pInUse->imgBuffer && pInUse->imgBufferSize) {
pInUse->imgData = new GuiImageData(pInUse->imgBuffer, pInUse->imgBufferSize);
} else {
uint8_t *buffer = NULL;
uint8_t *buffer = NULL;
uint64_t bufferSize = 0;
CFile file(pInUse->filename, CFile::ReadOnly);
if (file.isOpen()) {
uint64_t filesize = file.size();
buffer = (uint8_t *) malloc(filesize);
buffer = (uint8_t *) malloc(filesize);
if (buffer != NULL) {
uint32_t blocksize = 0x4000;
uint32_t done = 0;
int32_t readBytes = 0;
uint32_t done = 0;
int32_t readBytes = 0;
while (done < filesize) {
if (done + blocksize > filesize) {
blocksize = filesize - done;
@ -133,8 +133,8 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
if (pInUse->imgData) {
if (pInUse->imgData->getTexture()) {
pInUse->width = pInUse->imgData->getWidth();
pInUse->height = pInUse->imgData->getHeight();
pInUse->width = pInUse->imgData->getWidth();
pInUse->height = pInUse->imgData->getHeight();
pInUse->imageData = pInUse->imgData;
} else {
delete pInUse->imgData;
@ -150,8 +150,8 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
void GuiImageAsync::threadInit() {
if (pThread == NULL) {
bExitRequested = false;
pMutex = new std::recursive_mutex();
pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10);
pMutex = new std::recursive_mutex();
pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10);
pThread->resumeThread();
}
@ -168,6 +168,6 @@ void GuiImageAsync::threadExit() {
delete pThread;
delete pMutex;
pThread = NULL;
pMutex = NULL;
pMutex = NULL;
}
}

View File

@ -14,18 +14,18 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <malloc.h>
#include <string.h>
#include <stdint.h>
#include <gui/GuiImageData.h>
#include <gui/memory.h>
#include <malloc.h>
#include <stdint.h>
#include <string.h>
/**
* Constructor for the GuiImageData class.
*/
GuiImageData::GuiImageData() {
texture = NULL;
sampler = NULL;
texture = NULL;
sampler = NULL;
memoryType = eMemTypeMEM2;
}
@ -90,7 +90,7 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod
// IMAGE_PNG
gdImg = gdImageCreateFromPngPtr(imgSize, (uint8_t *) img);
}
//!This must be last since it can also intefere with outher formats
//!This must be last since it can also intefere with outher formats
else if (img[0] == 0x00) {
// Try loading TGA image
gdImg = gdImageCreateFromTgaPtr(imgSize, (uint8_t *) img);
@ -100,7 +100,7 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod
return;
}
uint32_t width = (gdImageSX(gdImg));
uint32_t width = (gdImageSX(gdImg));
uint32_t height = (gdImageSY(gdImg));
//! Initialize texture
@ -116,16 +116,16 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod
}
//! allocate memory for the surface
memoryType = eMemTypeMEM2;
memoryType = eMemTypeMEM2;
texture->surface.image = memalign(texture->surface.alignment, texture->surface.imageSize);
//! try MEM1 on failure
if (!texture->surface.image) {
memoryType = eMemTypeMEM1;
memoryType = eMemTypeMEM1;
texture->surface.image = MEM1_alloc(texture->surface.imageSize, texture->surface.alignment);
}
//! try MEM bucket on failure
if (!texture->surface.image) {
memoryType = eMemTypeMEMBucket;
memoryType = eMemTypeMEMBucket;
texture->surface.image = MEMBucket_alloc(texture->surface.imageSize, texture->surface.alignment);
}
//! check if memory is available for image

View File

@ -14,12 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "utils/utils.h"
#include <gui/GuiParticleImage.h>
#include <gui/video/CVideo.h>
#include <gui/video/shaders/ColorShader.h>
#include "utils/utils.h"
#define CIRCLE_VERTEX_COUNT 36
#define CIRCLE_VERTEX_COUNT 36
static inline float getRandZeroToOneF32() {
return (rand() % 10000) * 0.0001f;
@ -30,16 +30,16 @@ static inline float getRandMinusOneToOneF32() {
}
GuiParticleImage::GuiParticleImage(int32_t w, int32_t h, uint32_t particleCount, float minRadius, float maxRadius, float minSpeed, float maxSpeed)
: GuiImage(NULL) {
width = w;
height = h;
imgType = IMAGE_COLOR;
: GuiImage(NULL) {
width = w;
height = h;
imgType = IMAGE_COLOR;
this->minRadius = minRadius;
this->maxRadius = maxRadius;
this->minSpeed = minSpeed;
this->maxSpeed = maxSpeed;
this->minSpeed = minSpeed;
this->maxSpeed = maxSpeed;
posVertexs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT);
posVertexs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT);
colorVertexs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuColorAttrSize * CIRCLE_VERTEX_COUNT);
for (uint32_t i = 0; i < CIRCLE_VERTEX_COUNT; i++) {
@ -61,10 +61,10 @@ GuiParticleImage::GuiParticleImage(int32_t w, int32_t h, uint32_t particleCount,
particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f;
particles[i].position.y = getRandMinusOneToOneF32() * getHeight() * 0.5f;
particles[i].position.z = 0.0f;
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius;
particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed;
particles[i].direction = getRandMinusOneToOneF32();
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius;
particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed;
particles[i].direction = getRandMinusOneToOneF32();
}
}
@ -93,10 +93,10 @@ void GuiParticleImage::draw(CVideo *pVideo) {
if (particles[i].position.y > (getHeight() * 0.5f + 30.0f)) {
particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f;
particles[i].position.y = -getHeight() * 0.5f - 30.0f;
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius;
particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed;
particles[i].direction = getRandMinusOneToOneF32();
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius;
particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed;
particles[i].direction = getRandMinusOneToOneF32();
}
if (particles[i].position.x < (-getWidth() * 0.5f - 50.0f)) {
particles[i].position.x = -particles[i].position.x;

View File

@ -21,14 +21,14 @@
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <gui/GuiScrollbar.h>
#include "utils/utils.h"
#include <gui/GuiScrollbar.h>
GuiScrollbar::GuiScrollbar(int32_t h)
: touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) {
SelItem = 0;
SelInd = 0;
PageSize = 0;
: touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) {
SelItem = 0;
SelInd = 0;
PageSize = 0;
EntrieCount = 0;
SetScrollSpeed(15);
ScrollState = 0;
@ -133,10 +133,10 @@ void GuiScrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *contr
if (newSelected <= 0) {
SelItem = 0;
SelInd = 0;
SelInd = 0;
} else if (newSelected >= EntrieCount - 1) {
SelItem = (PageSize - 1 < EntrieCount - 1) ? PageSize - 1 : EntrieCount - 1;
SelInd = EntrieCount - PageSize;
SelInd = EntrieCount - PageSize;
} else if (newSelected < PageSize && SelInd == 0 && diff < 0) {
SelItem = std::max(SelItem + diff, (int32_t) 0);
} else if (EntrieCount - newSelected < PageSize && SelInd == EntrieCount - PageSize && diff > 0) {
@ -219,4 +219,3 @@ void GuiScrollbar::update(GuiController *t) {
++ScrollState;
}

View File

@ -14,28 +14,28 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <vector>
#include <string>
#include <vector>
#include <gui/GuiSelectBox.h>
#include <gui/GuiImage.h>
#include <gui/GuiTrigger.h>
#include <gui/GuiImageData.h>
#include <gui/GuiSelectBox.h>
#include <gui/GuiTrigger.h>
/**
* Constructor for the GuiCheckBox class.
*/
GuiSelectBox::GuiSelectBox(GuiImage *background, std::string caption, float width, float height, GuiFrame *parent)
: GuiFrame(width, height, parent), selected(0), captionText(caption), topValueButton(0, 0), touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH),
wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A), buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true),
buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true), buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true),
buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true), DPADButtons(0, 0) {
: GuiFrame(width, height, parent), selected(0), captionText(caption), topValueButton(0, 0), touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH),
wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A), buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true),
buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true), buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true),
buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true), DPADButtons(0, 0) {
setImageTopBackground(background);
showValues = false;
bChanged = false;
showValues = false;
bChanged = false;
bSelectedChanged = false;
opened = false;
opened = false;
topValueText.setFontSize(32);
topValueText.setAlignment(ALIGN_LEFT);
topValueText.setPosition(10, -7);
@ -58,7 +58,7 @@ GuiSelectBox::GuiSelectBox(GuiImage *background, std::string caption, float widt
append(&topValueButton);
showValues = false;
bChanged = true;
bChanged = true;
}
void GuiSelectBox::setSize(float width, float height) {
@ -97,7 +97,7 @@ void GuiSelectBox::OnTopValueClicked(GuiButton *button, const GuiController *con
void GuiSelectBox::ShowHideValues(bool showhide) {
showValues = showhide;
bChanged = true;
bChanged = true;
}
void GuiSelectBox::OnDPADClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
@ -129,7 +129,7 @@ void GuiSelectBox::Init(std::map<std::string, std::string> values, int32_t value
valueID = 0;
}
selected = valueID;
selected = valueID;
bSelectedChanged = true;
DeleteValueData();
@ -140,7 +140,7 @@ void GuiSelectBox::Init(std::map<std::string, std::string> values, int32_t value
valueButtons.resize(values.size());
int32_t i = 0;
int32_t i = 0;
float imgScale = 1.0f;
std::map<std::string, std::string>::iterator itr;
for (itr = values.begin(); itr != values.end(); itr++) {
@ -148,11 +148,11 @@ void GuiSelectBox::Init(std::map<std::string, std::string> values, int32_t value
topValueText.setText(itr->first.c_str());
}
valueButtons[i].valueButtonImg = new GuiImage(valueImageData);
valueButtons[i].valueButtonCheckedImg = new GuiImage(valueSelectedImageData);
valueButtons[i].valueButtonImg = new GuiImage(valueImageData);
valueButtons[i].valueButtonCheckedImg = new GuiImage(valueSelectedImageData);
valueButtons[i].valueButtonHighlightedImg = new GuiImage(valueHighlightedImageData);
valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale);
valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale);
valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(), 32, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
valueButtons[i].valueButtonText->setMaxWidth(valueButtons[i].valueButtonImg->getWidth() * imgScale - 20.0f, GuiText::WRAP);
@ -187,7 +187,7 @@ void GuiSelectBox::Init(std::map<std::string, std::string> values, int32_t value
//Collapse the thing!
showValues = false;
bChanged = true;
bChanged = true;
}
void GuiSelectBox::DeleteValueData() {
@ -208,8 +208,8 @@ void GuiSelectBox::DeleteValueData() {
*/
GuiSelectBox::~GuiSelectBox() {
DeleteValueData();
bChanged = false;
selected = 0;
bChanged = false;
selected = 0;
showValues = false;
}

View File

@ -14,11 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <string.h>
#include <string>
#include <stdio.h>
#include <gui/GuiSound.h>
#include <gui/sounds/SoundHandler.hpp>
#include <stdio.h>
#include <string.h>
#include <string>
GuiSound::GuiSound(const char *filepath) {
voice = -1;
@ -102,8 +102,6 @@ void GuiSound::Play() {
if (v) {
v->setState(Voice::STATE_START);
}
}
void GuiSound::Stop() {

View File

@ -14,16 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/GuiSwitch.h>
#include <gui/GuiImage.h>
#include <gui/GuiImageData.h>
#include <gui/GuiSwitch.h>
/**
* Constructor for the GuiSwitch class.
*/
GuiSwitch::GuiSwitch(GuiImage *background, bool checked, float w, float h)
: GuiToggle(checked, w, h) {
: GuiToggle(checked, w, h) {
setImageBackground(background);
}
@ -31,7 +31,6 @@ GuiSwitch::GuiSwitch(GuiImage *background, bool checked, float w, float h)
* Destructor for the GuiSwitch class.
*/
GuiSwitch::~GuiSwitch() {
}
void GuiSwitch::setImageBackground(GuiImage *img) {

View File

@ -14,69 +14,68 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/GuiText.h>
#include <gui/FreeTypeGX.h>
#include <gui/GuiText.h>
#include <gui/video/CVideo.h>
FreeTypeGX *GuiText::presentFont = NULL;
int32_t GuiText::presetSSAA = 2;
int32_t GuiText::presetSize = 28;
int32_t GuiText::presetMaxWidth = 0xFFFF;
int32_t GuiText::presetSSAA = 2;
int32_t GuiText::presetSize = 28;
int32_t GuiText::presetMaxWidth = 0xFFFF;
int32_t GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE;
GX2ColorF32 GuiText::presetColor = (GX2ColorF32) {
1.0f, 1.0f, 1.0f, 1.0f
};
GX2ColorF32 GuiText::presetColor = (GX2ColorF32){
1.0f, 1.0f, 1.0f, 1.0f};
#define TEXT_SCROLL_DELAY 6
#define TEXT_SCROLL_INITIAL_DELAY 10
#define MAX_LINES_TO_DRAW 10
#define TEXT_SCROLL_DELAY 6
#define TEXT_SCROLL_INITIAL_DELAY 10
#define MAX_LINES_TO_DRAW 10
/**
* Constructor for the GuiText class.
*/
GuiText::GuiText() {
text = NULL;
currentSize = presetSize;
color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a);
alpha = presetColor.a;
alignment = presetAlignment;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
text = NULL;
currentSize = presetSize;
color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a);
alpha = presetColor.a;
alignment = presetAlignment;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
}
GuiText::GuiText(const char *t, int32_t s, const glm::vec4 &c) {
text = NULL;
currentSize = s;
color = c;
alpha = c[3];
alignment = ALIGN_CENTER | ALIGN_MIDDLE;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
text = NULL;
currentSize = s;
color = c;
alpha = c[3];
alignment = ALIGN_CENTER | ALIGN_MIDDLE;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
if (t) {
textMutex.lock();
@ -86,29 +85,29 @@ GuiText::GuiText(const char *t, int32_t s, const glm::vec4 &c) {
}
GuiText::GuiText(const wchar_t *t, int32_t s, const glm::vec4 &c) {
text = NULL;
currentSize = s;
color = c;
alpha = c[3];
alignment = ALIGN_CENTER | ALIGN_MIDDLE;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
text = NULL;
currentSize = s;
color = c;
alpha = c[3];
alignment = ALIGN_CENTER | ALIGN_MIDDLE;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
if (t) {
textMutex.lock();
text = new(std::nothrow) wchar_t[wcslen(t) + 1];
text = new (std::nothrow) wchar_t[wcslen(t) + 1];
if (!text) {
textMutex.unlock();
return;
@ -123,25 +122,25 @@ GuiText::GuiText(const wchar_t *t, int32_t s, const glm::vec4 &c) {
* Constructor for the GuiText class, uses presets
*/
GuiText::GuiText(const char *t) {
text = NULL;
currentSize = presetSize;
color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a);
alpha = presetColor.a;
alignment = presetAlignment;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
text = NULL;
currentSize = presetSize;
color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a);
alpha = presetColor.a;
alignment = presetAlignment;
maxWidth = presetMaxWidth;
internalSSAA = presetSSAA;
wrapMode = 0;
font = presentFont;
linestodraw = MAX_LINES_TO_DRAW;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
textScrollDelay = TEXT_SCROLL_DELAY;
defaultBlur = 4.0f;
blurGlowIntensity = 0.0f;
blurAlpha = 0.0f;
blurGlowColor = glm::vec4(0.0f);
width = 0;
height = 0;
if (t) {
textMutex.lock();
@ -174,7 +173,7 @@ void GuiText::setText(const char *t) {
clearDynamicText();
textScrollPos = 0;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if (t) {
@ -190,7 +189,7 @@ void GuiText::setTextf(const char *format, ...) {
}
int32_t max_len = strlen(format) + 8192;
char *tmp = new(std::nothrow) char[max_len];
char *tmp = new (std::nothrow) char[max_len];
va_list va;
va_start(va, format);
if ((vsnprintf(tmp, max_len, format, va) >= 0) && tmp) {
@ -213,11 +212,11 @@ void GuiText::setText(const wchar_t *t) {
clearDynamicText();
textScrollPos = 0;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if (t) {
text = new(std::nothrow) wchar_t[wcslen(t) + 1];
text = new (std::nothrow) wchar_t[wcslen(t) + 1];
if (!text) {
textMutex.unlock();
return;
@ -241,11 +240,10 @@ void GuiText::clearDynamicText() {
}
void GuiText::setPresets(int32_t sz, const glm::vec4 &c, int32_t w, int32_t a) {
presetSize = sz;
presetColor = (GX2ColorF32) {
(float) c.r / 255.0f, (float) c.g / 255.0f, (float) c.b / 255.0f, (float) c.a / 255.0f
};
presetMaxWidth = w;
presetSize = sz;
presetColor = (GX2ColorF32){
(float) c.r / 255.0f, (float) c.g / 255.0f, (float) c.b / 255.0f, (float) c.a / 255.0f};
presetMaxWidth = w;
presetAlignment = a;
}
@ -262,9 +260,9 @@ void GuiText::setMaxWidth(int32_t width, int32_t w) {
wrapMode = w;
if (w == SCROLL_HORIZONTAL) {
textScrollPos = 0;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
}
clearDynamicText();
@ -276,9 +274,9 @@ void GuiText::setColor(const glm::vec4 &c) {
}
void GuiText::setBlurGlowColor(float blur, const glm::vec4 &c) {
blurGlowColor = c;
blurGlowColor = c;
blurGlowIntensity = blur;
blurAlpha = c[3];
blurAlpha = c[3];
}
int32_t GuiText::getTextWidth(int32_t ind) {
@ -297,7 +295,7 @@ int32_t GuiText::getTextWidth(int32_t ind) {
int32_t GuiText::getTextWidth() {
textMutex.lock();
auto res = font->getWidth(text, currentSize);
res = res > maxWidth && maxWidth > 0 ? maxWidth : res;
res = res > maxWidth && maxWidth > 0 ? maxWidth : res;
textMutex.unlock();
return res;
}
@ -365,7 +363,7 @@ void GuiText::makeDottedText() {
textDyn.resize(pos + 1);
int32_t i = 0, currentWidth = 0;
textDyn[pos] = new(std::nothrow) wchar_t[maxWidth];
textDyn[pos] = new (std::nothrow) wchar_t[maxWidth];
if (!textDyn[pos]) {
textDyn.resize(pos);
textMutex.unlock();
@ -377,7 +375,7 @@ void GuiText::makeDottedText() {
if (currentWidth >= maxWidth && i > 2) {
textDyn[pos][i - 2] = '.';
textDyn[pos][i - 1] = '.';
textDyn[pos][i] = '.';
textDyn[pos][i] = '.';
i++;
break;
}
@ -397,7 +395,7 @@ void GuiText::scrollText(uint32_t frameCount) {
int32_t i = 0, currentWidth = 0;
textDyn.resize(pos + 1);
textDyn[pos] = new(std::nothrow) wchar_t[maxWidth];
textDyn[pos] = new (std::nothrow) wchar_t[maxWidth];
if (!textDyn[pos]) {
textDyn.resize(pos);
textMutex.unlock();
@ -431,15 +429,15 @@ void GuiText::scrollText(uint32_t frameCount) {
++textScrollPos;
if (textScrollPos > stringlen) {
textScrollPos = 0;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
}
int32_t ch = textScrollPos;
int32_t ch = textScrollPos;
int32_t pos = textDyn.size() - 1;
if (!textDyn[pos]) {
textDyn[pos] = new(std::nothrow) wchar_t[maxWidth];
textDyn[pos] = new (std::nothrow) wchar_t[maxWidth];
}
if (!textDyn[pos]) {
@ -481,37 +479,37 @@ void GuiText::wrapText() {
return;
}
int32_t i = 0;
int32_t ch = 0;
int32_t linenum = 0;
int32_t lastSpace = -1;
int32_t i = 0;
int32_t ch = 0;
int32_t linenum = 0;
int32_t lastSpace = -1;
int32_t lastSpaceIndex = -1;
int32_t currentWidth = 0;
int32_t currentWidth = 0;
while (text[ch] && linenum < linestodraw) {
if (linenum >= (int32_t) textDyn.size()) {
textDyn.resize(linenum + 1);
textDyn[linenum] = new(std::nothrow) wchar_t[maxWidth];
textDyn[linenum] = new (std::nothrow) wchar_t[maxWidth];
if (!textDyn[linenum]) {
textDyn.resize(linenum);
break;
}
}
textDyn[linenum][i] = text[ch];
textDyn[linenum][i] = text[ch];
textDyn[linenum][i + 1] = 0;
currentWidth += font->getCharWidth(text[ch], currentSize, ch > 0 ? text[ch - 1] : 0x0000);
if (currentWidth >= maxWidth || (text[ch] == '\n')) {
if (text[ch] == '\n') {
lastSpace = -1;
lastSpace = -1;
lastSpaceIndex = -1;
} else if (lastSpace >= 0) {
textDyn[linenum][lastSpaceIndex] = 0; // discard space, and everything after
ch = lastSpace; // go backwards to the last space
lastSpace = -1; // we have used this space
lastSpaceIndex = -1;
textDyn[linenum][lastSpaceIndex] = 0; // discard space, and everything after
ch = lastSpace; // go backwards to the last space
lastSpace = -1; // we have used this space
lastSpaceIndex = -1;
}
if (linenum + 1 == linestodraw && text[ch + 1] != 0x0000) {
@ -521,7 +519,7 @@ void GuiText::wrapText() {
textDyn[linenum][i - 2] = '.';
textDyn[linenum][i - 1] = '.';
textDyn[linenum][i] = '.';
textDyn[linenum][i] = '.';
textDyn[linenum][i + 1] = 0;
}
@ -530,7 +528,7 @@ void GuiText::wrapText() {
i = -1;
}
if (text[ch] == ' ' && i >= 0) {
lastSpace = ch;
lastSpace = ch;
lastSpaceIndex = i;
}
++ch;
@ -589,21 +587,21 @@ float GuiText::getCenterY(void) {
if (alignment & ALIGN_TOP) {
float pHeight = 0.0f;
float pScale = 0.0f;
float pScale = 0.0f;
if (parentElement) {
pHeight = parentElement->getHeight();
pScale = parentElement->getScaleY();
pScale = parentElement->getScaleY();
}
pCenterY += pHeight * 0.5f * pScale;
} else if (alignment & ALIGN_BOTTOM) {
float pHeight = 0.0f;
float pScale = 0.0f;
float pScale = 0.0f;
if (parentElement) {
pHeight = parentElement->getHeight();
pScale = parentElement->getScaleY();
pScale = parentElement->getScaleY();
}
pCenterY -= pHeight * 0.5f * pScale;
@ -626,12 +624,12 @@ void GuiText::draw(CVideo *pVideo) {
return;
}
color[3] = getAlpha();
color[3] = getAlpha();
blurGlowColor[3] = blurAlpha * getAlpha();
auto internalRenderingScale = internalSSAA == 0 ? 1 : internalSSAA << 1;
int32_t normal_size = currentSize * getScale();
int32_t normal_size = currentSize * getScale();
int32_t internalRenderingSize = normal_size * internalRenderingScale;
auto textWidth = font->getWidth(text, normal_size);

View File

@ -21,7 +21,7 @@
*/
GuiToggle::GuiToggle(bool checked, float width, float height)
: GuiButton(width, height) {
: GuiButton(width, height) {
bChanged = false;
selected = checked;
clicked.connect(this, &GuiToggle::OnToggleClick);
@ -48,4 +48,3 @@ void GuiToggle::OnToggleClick(GuiButton *button, const GuiController *controller
void GuiToggle::update(GuiController *c) {
GuiButton::update(c);
}

View File

@ -14,19 +14,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/GuiElement.h>
#include <gui/GuiController.h>
#include <gui/GuiElement.h>
#include <gui/GuiTrigger.h>
/**
* Constructor for the GuiTrigger class.
*/
GuiTrigger::GuiTrigger()
: chan(CHANNEL_ALL), btns(BUTTON_NONE), bClickEverywhere(false), bHoldEverywhere(false), bSelectionClickEverywhere(false), bLastTouched(false) {
: chan(CHANNEL_ALL), btns(BUTTON_NONE), bClickEverywhere(false), bHoldEverywhere(false), bSelectionClickEverywhere(false), bLastTouched(false) {
}
GuiTrigger::GuiTrigger(uint32_t ch, uint32_t btn, bool clickEverywhere, bool holdEverywhere, bool selectionClickEverywhere)
: chan(ch), btns(btn), bClickEverywhere(clickEverywhere), bHoldEverywhere(holdEverywhere), bSelectionClickEverywhere(selectionClickEverywhere), bLastTouched(false) {
: chan(ch), btns(btn), bClickEverywhere(clickEverywhere), bHoldEverywhere(holdEverywhere), bSelectionClickEverywhere(selectionClickEverywhere), bLastTouched(false) {
}
/**
@ -141,4 +141,3 @@ bool GuiTrigger::released(const GuiController *controller) const {
return bResult;
}

View File

@ -23,12 +23,12 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <gui/sounds/BufferCircle.hpp>
#include <malloc.h>
#include <utils/utils.h>
#include <gui/sounds/BufferCircle.hpp>
BufferCircle::BufferCircle() {
which = 0;
which = 0;
BufferBlockSize = 0;
}
@ -52,7 +52,7 @@ void BufferCircle::SetBufferBlockSize(int32_t size) {
}
SoundBuffer[i] = (uint8_t *) memalign(32, ALIGN32(BufferBlockSize));
BufferSize[i] = 0;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
@ -73,7 +73,7 @@ void BufferCircle::Resize(int32_t size) {
} else {
SoundBuffer[i] = NULL;
}
BufferSize[i] = 0;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
@ -94,7 +94,7 @@ void BufferCircle::RemoveBuffer(int32_t pos) {
void BufferCircle::ClearBuffer() {
for (int32_t i = 0; i < Size(); i++) {
BufferSize[i] = 0;
BufferSize[i] = 0;
BufferReady[i] = false;
}
which = 0;
@ -107,14 +107,14 @@ void BufferCircle::FreeBuffer() {
}
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::LoadNext() {
BufferReady[which] = false;
BufferSize[which] = 0;
BufferSize[which] = 0;
which = Next();
}

View File

@ -23,20 +23,20 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <string>
#include <string.h>
#include "fs/CFile.hpp"
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <gui/sounds/Mp3Decoder.hpp>
#include <limits.h>
#include <unistd.h>
#include <malloc.h>
#include <math.h>
#include <coreinit/time.h>
#include <coreinit/thread.h>
#include <gui/sounds/Mp3Decoder.hpp>
#include "fs/CFile.hpp"
#include <string.h>
#include <string>
#include <unistd.h>
Mp3Decoder::Mp3Decoder(const char *filepath)
: SoundDecoder(filepath) {
SoundType = SOUND_MP3;
: SoundDecoder(filepath) {
SoundType = SOUND_MP3;
ReadBuffer = NULL;
mad_timer_reset(&Timer);
mad_stream_init(&Stream);
@ -51,8 +51,8 @@ Mp3Decoder::Mp3Decoder(const char *filepath)
}
Mp3Decoder::Mp3Decoder(const uint8_t *snd, int32_t len)
: SoundDecoder(snd, len) {
SoundType = SOUND_MP3;
: SoundDecoder(snd, len) {
SoundType = SOUND_MP3;
ReadBuffer = NULL;
mad_timer_reset(&Timer);
mad_stream_init(&Stream);
@ -82,7 +82,7 @@ Mp3Decoder::~Mp3Decoder() {
}
void Mp3Decoder::OpenFile() {
GuardPtr = NULL;
GuardPtr = NULL;
ReadBuffer = (uint8_t *) memalign(32, SoundBlockSize * SoundBlocks);
if (!ReadBuffer) {
if (file_fd) {
@ -103,7 +103,7 @@ void Mp3Decoder::OpenFile() {
}
SampleRate = (uint32_t) Frame.header.samplerate;
Format = ((MAD_NCHANNELS(&Frame.header) == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO));
Format = ((MAD_NCHANNELS(&Frame.header) == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO));
Rewind();
}
@ -170,8 +170,8 @@ int32_t Mp3Decoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
if (Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN) {
uint8_t *ReadStart = ReadBuffer;
int32_t ReadSize = SoundBlockSize * SoundBlocks;
int32_t Remaining = 0;
int32_t ReadSize = SoundBlockSize * SoundBlocks;
int32_t Remaining = 0;
if (Stream.next_frame != NULL) {
Remaining = Stream.bufend - Stream.next_frame;

View File

@ -23,12 +23,12 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#include <coreinit/time.h>
#include <coreinit/thread.h>
#include <gui/sounds/OggDecoder.hpp>
#include "fs/CFile.hpp"
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <gui/sounds/OggDecoder.hpp>
#include <malloc.h>
#include <unistd.h>
static int ogg_read(void *punt, int bytes, int blocks, int *f) {
return ((CFile *) f)->read((uint8_t *) punt, bytes * blocks);
@ -48,14 +48,13 @@ static long ogg_tell(int *f) {
}
static ov_callbacks callbacks = {
(size_t (*)(void *, size_t, size_t, void *)) ogg_read,
(size_t(*)(void *, size_t, size_t, void *)) ogg_read,
(int (*)(void *, ogg_int64_t, int)) ogg_seek,
(int (*)(void *)) ogg_close,
(long (*)(void *)) ogg_tell
};
(long (*)(void *)) ogg_tell};
OggDecoder::OggDecoder(const char *filepath)
: SoundDecoder(filepath) {
: SoundDecoder(filepath) {
SoundType = SOUND_OGG;
if (!file_fd) {
@ -66,7 +65,7 @@ OggDecoder::OggDecoder(const char *filepath)
}
OggDecoder::OggDecoder(const uint8_t *snd, int32_t len)
: SoundDecoder(snd, len) {
: SoundDecoder(snd, len) {
SoundType = SOUND_OGG;
if (!file_fd) {
@ -101,7 +100,7 @@ void OggDecoder::OpenFile() {
return;
}
Format = ((ogg_info->channels == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO));
Format = ((ogg_info->channels == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO));
SampleRate = ogg_info->rate;
}
@ -111,8 +110,8 @@ int32_t OggDecoder::Rewind() {
}
int32_t ret = ov_time_seek(&ogg_file, 0);
CurPos = 0;
EndOfFile = false;
CurPos = 0;
EndOfFile = false;
return ret;
}

View File

@ -15,14 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "fs/CFile.hpp"
#include <coreinit/cache.h>
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <gui/sounds/SoundDecoder.hpp>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <coreinit/time.h>
#include <coreinit/thread.h>
#include <coreinit/cache.h>
#include <gui/sounds/SoundDecoder.hpp>
#include "fs/CFile.hpp"
static const uint32_t FixedPointShift = 15;
static const uint32_t FixedPointScale = 1 << FixedPointShift;
@ -67,24 +67,24 @@ int32_t SoundDecoder::Seek(int32_t pos) {
}
void SoundDecoder::Init() {
SoundType = SOUND_RAW;
SoundBlocks = 8;
SoundBlockSize = 0x4000;
SoundType = SOUND_RAW;
SoundBlocks = 8;
SoundBlockSize = 0x4000;
ResampleTo48kHz = false;
CurPos = 0;
whichLoad = 0;
Loop = false;
EndOfFile = false;
Decoding = false;
ExitRequested = false;
CurPos = 0;
whichLoad = 0;
Loop = false;
EndOfFile = false;
Decoding = false;
ExitRequested = false;
SoundBuffer.SetBufferBlockSize(SoundBlockSize);
SoundBuffer.Resize(SoundBlocks);
ResampleBuffer = NULL;
ResampleRatio = 0;
ResampleRatio = 0;
}
int32_t SoundDecoder::Rewind() {
CurPos = 0;
CurPos = 0;
EndOfFile = false;
file_fd->rewind();
@ -99,12 +99,9 @@ int32_t SoundDecoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) {
}
void SoundDecoder::EnableUpsample(void) {
if ((ResampleBuffer == NULL)
&& IsStereo() && Is16Bit()
&& SampleRate != 32000
&& SampleRate != 48000) {
if ((ResampleBuffer == NULL) && IsStereo() && Is16Bit() && SampleRate != 32000 && SampleRate != 48000) {
ResampleBuffer = (uint8_t *) memalign(32, SoundBlockSize);
ResampleRatio = (FixedPointScale * SampleRate) / 48000;
ResampleRatio = (FixedPointScale * SampleRate) / 48000;
SoundBlockSize = (SoundBlockSize * ResampleRatio) / FixedPointScale;
SoundBlockSize &= ~0x03;
// set new sample rate
@ -118,10 +115,10 @@ void SoundDecoder::Upsample(int16_t *src, int16_t *dst, uint32_t nr_src_samples,
for (uint32_t i = 0, n = 0; i < nr_dst_samples; i += 2) {
if ((n + 3) < nr_src_samples) {
// simple fixed point linear interpolation
dst[i] = src[n] + (((src[n + 2] - src[n]) * timer) >> FixedPointShift);
dst[i] = src[n] + (((src[n + 2] - src[n]) * timer) >> FixedPointShift);
dst[i + 1] = src[n + 1] + (((src[n + 3] - src[n + 1]) * timer) >> FixedPointShift);
} else {
dst[i] = src[n];
dst[i] = src[n];
dst[i + 1] = src[n + 1];
}
@ -141,19 +138,17 @@ void SoundDecoder::Decode() {
// check if we are not at the pre-last buffer (last buffer is playing)
uint16_t whichPlaying = SoundBuffer.Which();
if (((whichPlaying == 0) && (whichLoad == SoundBuffer.Size() - 2))
|| ((whichPlaying == 1) && (whichLoad == SoundBuffer.Size() - 1))
|| (whichLoad == (whichPlaying - 2))) {
if (((whichPlaying == 0) && (whichLoad == SoundBuffer.Size() - 2)) || ((whichPlaying == 1) && (whichLoad == SoundBuffer.Size() - 1)) || (whichLoad == (whichPlaying - 2))) {
return;
}
Decoding = true;
int32_t done = 0;
int32_t done = 0;
uint8_t *write_buf = SoundBuffer.GetBuffer(whichLoad);
if (!write_buf) {
ExitRequested = true;
Decoding = false;
Decoding = false;
return;
}
@ -182,7 +177,7 @@ void SoundDecoder::Decode() {
if (ResampleBuffer && ResampleRatio) {
memcpy(ResampleBuffer, write_buf, done);
int32_t src_samples = done >> 1;
int32_t src_samples = done >> 1;
int32_t dest_samples = (src_samples * FixedPointScale) / ResampleRatio;
dest_samples &= ~0x01;
Upsample((int16_t *) ResampleBuffer, (int16_t *) write_buf, src_samples, dest_samples);
@ -192,7 +187,7 @@ void SoundDecoder::Decode() {
//! TODO: remove this later and add STEREO support with two voices, for now we convert to MONO
if (IsStereo()) {
int16_t *monoBuf = (int16_t *) write_buf;
done = done >> 1;
done = done >> 1;
for (int32_t i = 0; i < done; i++) {
monoBuf[i] = monoBuf[i << 1];
@ -214,4 +209,3 @@ void SoundDecoder::Decode() {
Decoding = false;
}

View File

@ -23,24 +23,24 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#include <fs/CFile.hpp>
#include <gui/sounds/SoundHandler.hpp>
#include <gui/sounds/WavDecoder.hpp>
#include <gui/sounds/Mp3Decoder.hpp>
#include <gui/sounds/OggDecoder.hpp>
#include <gui/sounds/SoundHandler.hpp>
#include <gui/sounds/WavDecoder.hpp>
#include <malloc.h>
#include <sndcore2/core.h>
#include <unistd.h>
SoundHandler *SoundHandler::handlerInstance = NULL;
SoundHandler::SoundHandler()
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x8000) {
Decoding = false;
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x8000) {
Decoding = false;
ExitRequested = false;
for (uint32_t i = 0; i < MAX_DECODERS; ++i) {
DecoderList[i] = NULL;
voiceList[i] = NULL;
voiceList[i] = NULL;
}
resumeThread();
@ -115,19 +115,19 @@ void SoundHandler::ClearDecoderList() {
static inline bool CheckMP3Signature(const uint8_t *buffer) {
const char MP3_Magic[][3] = {
{'I', 'D', '3'}, //'ID3'
{0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'),
{'I', 'D', '3'}, //'ID3'
{0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'),
};
if (buffer[0] == MP3_Magic[0][0] && buffer[1] == MP3_Magic[0][1] &&
@ -176,7 +176,7 @@ SoundDecoder *SoundHandler::GetSoundDecoder(const char *filepath) {
SoundDecoder *SoundHandler::GetSoundDecoder(const uint8_t *sound, int32_t length) {
const uint8_t *check = sound;
int32_t counter = 0;
int32_t counter = 0;
while (check[0] == 0 && counter < length) {
check++;
@ -224,7 +224,7 @@ void SoundHandler::executeThread() {
// we would need MAX_DECODERS > Voice::PRIO_MAX
for (uint32_t i = 0; i < MAX_DECODERS; ++i) {
int32_t priority = (MAX_DECODERS - i) * Voice::PRIO_MAX / MAX_DECODERS;
voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority
voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority
}
AXRegisterAppFrameCallback(SoundHandler::axFrameCallback);
@ -279,15 +279,15 @@ void SoundHandler::axFrameCallback(void) {
SoundDecoder *decoder = handlerInstance->getDecoder(i);
decoder->Lock();
if (decoder->IsBufferReady()) {
const uint8_t *buffer = decoder->GetBuffer();
const uint8_t *buffer = decoder->GetBuffer();
const uint32_t bufferSize = decoder->GetBufferSize();
decoder->LoadNext();
const uint8_t *nextBuffer = NULL;
uint32_t nextBufferSize = 0;
uint32_t nextBufferSize = 0;
if (decoder->IsBufferReady()) {
nextBuffer = decoder->GetBuffer();
nextBuffer = decoder->GetBuffer();
nextBufferSize = decoder->GetBufferSize();
decoder->LoadNext();
}

View File

@ -23,16 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <string.h>
#include <gui/sounds/WavDecoder.hpp>
#include "fs/CFile.hpp"
#include "utils/utils.h"
#include <gui/sounds/WavDecoder.hpp>
#include <string.h>
WavDecoder::WavDecoder(const char *filepath)
: SoundDecoder(filepath) {
SoundType = SOUND_WAV;
: SoundDecoder(filepath) {
SoundType = SOUND_WAV;
SampleRate = 48000;
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
if (!file_fd) {
return;
@ -42,10 +42,10 @@ WavDecoder::WavDecoder(const char *filepath)
}
WavDecoder::WavDecoder(const uint8_t *snd, int32_t len)
: SoundDecoder(snd, len) {
SoundType = SOUND_WAV;
: SoundDecoder(snd, len) {
SoundType = SOUND_WAV;
SampleRate = 48000;
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT;
if (!file_fd) {
return;
@ -94,8 +94,8 @@ void WavDecoder::OpenFile() {
}
DataOffset += 8;
DataSize = le32(DataChunk.size);
Is16Bit = (le16(FmtChunk.bps) == 16);
DataSize = le32(DataChunk.size);
Is16Bit = (le16(FmtChunk.bps) == 16);
SampleRate = le32(FmtChunk.freq);
if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1) {

View File

@ -14,35 +14,35 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "memory.h"
#include <coreinit/memexpheap.h>
#include <coreinit/memfrmheap.h>
#include <coreinit/memheap.h>
#include <malloc.h>
#include <string.h>
#include <coreinit/memheap.h>
#include <coreinit/memfrmheap.h>
#include <coreinit/memexpheap.h>
#include "memory.h"
#define MEMORY_ARENA_1 0
#define MEMORY_ARENA_2 1
#define MEMORY_ARENA_3 2
#define MEMORY_ARENA_4 3
#define MEMORY_ARENA_5 4
#define MEMORY_ARENA_6 5
#define MEMORY_ARENA_7 6
#define MEMORY_ARENA_8 7
#define MEMORY_ARENA_FG_BUCKET 8
#define MEMORY_ARENA_1 0
#define MEMORY_ARENA_2 1
#define MEMORY_ARENA_3 2
#define MEMORY_ARENA_4 3
#define MEMORY_ARENA_5 4
#define MEMORY_ARENA_6 5
#define MEMORY_ARENA_7 6
#define MEMORY_ARENA_8 7
#define MEMORY_ARENA_FG_BUCKET 8
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//! Memory functions
//! This is the only place where those are needed so lets keep them more or less private
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
static MEMHeapHandle mem1_heap = NULL;
static MEMHeapHandle mem1_heap = NULL;
static MEMHeapHandle bucket_heap = NULL;
void libgui_memoryInitialize(void) {
if (!mem1_heap) {
MEMHeapHandle mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1);
uint32_t mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4);
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
if (mem1_memory)
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0);
}
@ -50,7 +50,7 @@ void libgui_memoryInitialize(void) {
if (!bucket_heap) {
MEMHeapHandle bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET);
uint32_t bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4);
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
if (bucket_memory)
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0);
}

View File

@ -7,23 +7,24 @@
extern "C" {
#endif
#define LIMIT(x, min, max) \
({ \
typeof( x ) _x = x; \
typeof( min ) _min = min; \
typeof( max ) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
})
#define LIMIT(x, min, max) \
({ \
typeof(x) _x = x; \
typeof(min) _min = min; \
typeof(max) _max = max; \
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
: (_x)); \
})
#define DegToRad(a) ( (a) * 0.01745329252f )
#define RadToDeg(a) ( (a) * 57.29577951f )
#define DegToRad(a) ((a) *0.01745329252f)
#define RadToDeg(a) ((a) *57.29577951f)
#define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31)
#define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31)
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
//Needs to have log_init() called beforehand.
void dumpHex(const void *data, size_t size);

View File

@ -14,19 +14,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <malloc.h>
#include <string.h>
#include <gui/video/CVideo.h>
#include "utils/utils.h"
#include <cstdint>
#include <gui/memory.h>
#include <gui/video/shaders/Texture2DShader.h>
#include <gui/video/CVideo.h>
#include <gui/video/shaders/ColorShader.h>
#include <gui/video/shaders/FXAAShader.h>
#include <gui/video/shaders/Shader3D.h>
#include <gui/video/shaders/ShaderFractalColor.h>
#include <gui/video/shaders/FXAAShader.h>
#include "utils/utils.h"
#include <gui/video/shaders/Texture2DShader.h>
#include <malloc.h>
#include <string.h>
CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
tvEnabled = false;
tvEnabled = false;
drcEnabled = false;
//! allocate MEM2 command buffer memory
@ -46,43 +47,43 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
GX2Init(gx2_init_attributes);
uint32_t scanBufferSize = 0;
uint32_t scaleNeeded = 0;
uint32_t scaleNeeded = 0;
int32_t tvScanMode = ((forceTvScanMode >= 0) ? forceTvScanMode : (int32_t) GX2GetSystemTVScanMode());
int32_t tvScanMode = ((forceTvScanMode >= 0) ? forceTvScanMode : (int32_t) GX2GetSystemTVScanMode());
int32_t drcScanMode = ((forceDrcScanMode >= 0) ? forceDrcScanMode : (int32_t) GX2GetSystemDRCScanMode());
int32_t tvRenderMode;
uint32_t tvWidth = 0;
uint32_t tvWidth = 0;
uint32_t tvHeight = 0;
switch (tvScanMode) {
case GX2_TV_SCAN_MODE_480I:
case GX2_TV_SCAN_MODE_480P:
tvWidth = 854;
tvHeight = 480;
tvWidth = 854;
tvHeight = 480;
tvRenderMode = GX2_TV_RENDER_MODE_WIDE_480P;
break;
case GX2_TV_SCAN_MODE_1080I:
case GX2_TV_SCAN_MODE_1080P:
tvWidth = 1920;
tvHeight = 1080;
tvWidth = 1920;
tvHeight = 1080;
tvRenderMode = GX2_TV_RENDER_MODE_WIDE_1080P;
break;
case GX2_TV_SCAN_MODE_720P:
default:
tvWidth = 1280;
tvHeight = 720;
tvWidth = 1280;
tvHeight = 720;
tvRenderMode = GX2_TV_RENDER_MODE_WIDE_720P;
break;
}
int32_t tvAAMode = GX2_AA_MODE1X;
int32_t tvAAMode = GX2_AA_MODE1X;
int32_t drcAAMode = GX2_AA_MODE4X;
//! calculate the scale factor for later texture resize
widthScaleFactor = 1.0f / (float) tvWidth;
widthScaleFactor = 1.0f / (float) tvWidth;
heightScaleFactor = 1.0f / (float) tvHeight;
depthScaleFactor = widthScaleFactor;
depthScaleFactor = widthScaleFactor;
//! calculate the size needed for the TV scan buffer and allocate the buffer from bucket memory
GX2CalcTVSize((GX2TVRenderMode) tvRenderMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &scanBufferSize, &scaleNeeded);
@ -197,9 +198,9 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
GX2InitSampler(&aaSampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR);
GX2InitTexture(&tvAaTexture, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, 0, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_SURFACE_DIM_TEXTURE_2D, GX2_TILE_MODE_DEFAULT);
tvAaTexture.surface.image = tvColorBuffer.surface.image;
tvAaTexture.surface.image = tvColorBuffer.surface.image;
tvAaTexture.surface.imageSize = tvColorBuffer.surface.imageSize;
tvAaTexture.surface.mipmaps = tvColorBuffer.surface.mipmaps;
tvAaTexture.surface.mipmaps = tvColorBuffer.surface.mipmaps;
}
CVideo::~CVideo() {

View File

@ -18,12 +18,12 @@
#include <stdlib.h>
#include <string.h>
#include <gui/video/CursorDrawer.h>
#include <gui/video/shaders/ColorShader.h>
#include <gui/video/shaders/FXAAShader.h>
#include <gui/video/shaders/Shader3D.h>
#include <gui/video/shaders/ShaderFractalColor.h>
#include <gui/video/shaders/Texture2DShader.h>
#include <gui/video/CursorDrawer.h>
CursorDrawer *CursorDrawer::instance = NULL;
@ -48,7 +48,6 @@ void CursorDrawer::init_colorVtxs() {
if (!this->colorVtxs) {
this->colorVtxs = (uint8_t *) memalign(0x40, sizeof(uint8_t) * 16);
if (this->colorVtxs == NULL) { return; }
}
memset(this->colorVtxs, 0xFF, 16 * sizeof(uint8_t));
@ -62,7 +61,7 @@ void CursorDrawer::draw_Cursor(float x, float y) {
return;
}
float widthScaleFactor = 1.0f / (float) 1280;
float widthScaleFactor = 1.0f / (float) 1280;
float heightScaleFactor = 1.0f / (float) 720;
int32_t width = 20;

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/video/shaders/ColorShader.h>
#include <malloc.h>
#include <string.h>
#include <gui/video/shaders/ColorShader.h>
static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00008009, 0x20000000, 0x000078a0,
@ -51,8 +51,7 @@ static const uint32_t cpVertexShaderProgram[] = {
0x02c49f80, 0x80000060, 0x02e08f01, 0xfe0c620f,
0x02c01f80, 0x7f00622f, 0xfe242000, 0x10000000,
0xfe20a080, 0x10000020, 0xf2178647, 0x49c0e9fb,
0xfbbdb2ab, 0x768ac733
};
0xfbbdb2ab, 0x768ac733};
static const uint32_t cpVertexShaderRegs[] = {
0x00000103, 0x00000000, 0x00000000, 0x00000001,
@ -67,8 +66,7 @@ static const uint32_t cpVertexShaderRegs[] = {
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x00000000, 0x0000000e, 0x00000010
};
0x000000ff, 0x00000000, 0x0000000e, 0x00000010};
static const uint32_t cpPixelShaderProgram[] = {
0x20000000, 0x00000ca0, 0x00000000, 0x88062094,
@ -89,8 +87,7 @@ static const uint32_t cpPixelShaderProgram[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00002000, 0x90000000, 0x0004a000, 0x90000020,
0x00082001, 0x90000040, 0x000ca081, 0x90000060,
0xbb7dd898, 0x9746c59c, 0xc69b00e7, 0x03c36218
};
0xbb7dd898, 0x9746c59c, 0xc69b00e7, 0x03c36218};
static const uint32_t cpPixelShaderRegs[] = {
0x00000001, 0x00000002, 0x14000001, 0x00000000,
0x00000001, 0x00000100, 0x00000000, 0x00000000,
@ -102,45 +99,38 @@ static const uint32_t cpPixelShaderRegs[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000f, 0x00000001, 0x00000010,
0x00000000
};
0x00000000};
ColorShader *ColorShader::shaderInstance = NULL;
ColorShader::ColorShader()
: vertexShader(cuAttributeCount) {
: vertexShader(cuAttributeCount) {
//! create pixel shader
pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs));
colorIntensityLocation = 0;
pixelShader.addUniformVar((GX2UniformVar) {
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar){
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1});
//! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
angleLocation = 0;
angleLocation = 0;
offsetLocation = 4;
scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar) {
"unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1
});
scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar){
"unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1});
colorLocation = 1;
colorLocation = 1;
positionLocation = 0;
vertexShader.addAttribVar((GX2AttribVar) {
"attr_color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation
});
vertexShader.addAttribVar((GX2AttribVar){
"attr_color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation});
//! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
@ -153,7 +143,7 @@ ColorShader::ColorShader()
positionVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuPositionVtxsSize);
if (positionVtxs) {
//! position vertex structure
int32_t i = 0;
int32_t i = 0;
positionVtxs[i++] = -1.0f;
positionVtxs[i++] = -1.0f;
positionVtxs[i++] = 0.0f;

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/video/shaders/FXAAShader.h>
#include <malloc.h>
#include <string.h>
#include <gui/video/shaders/FXAAShader.h>
static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00008009, 0x20000000, 0x000004a0,
@ -36,8 +36,7 @@ static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xfd001f80, 0x900c2060, 0x0000803f, 0x00000000,
0xc1a229f5, 0xd0eddc33, 0x426618fd, 0x8509cfe7
};
0xc1a229f5, 0xd0eddc33, 0x426618fd, 0x8509cfe7};
static const uint32_t cpVertexShaderRegs[] = {
0x00000102, 0x00000000, 0x00000000, 0x00000001,
@ -52,8 +51,7 @@ static const uint32_t cpVertexShaderRegs[] = {
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x00000000, 0x0000000e, 0x00000010
};
0x000000ff, 0x00000000, 0x0000000e, 0x00000010};
static const uint32_t cpPixelShaderProgram[] = {
0x20000000, 0x00003ca0, 0xa0000000, 0x000c8080,
@ -145,8 +143,7 @@ static const uint32_t cpPixelShaderProgram[] = {
0x10000400, 0x04101df0, 0x00008010, 0xecdfea0d,
0x10000500, 0x05101df0, 0x00000011, 0xecdfea0d,
0x10000100, 0x01101df0, 0x00008010, 0xecdfea0d,
0xfe2e963a, 0x0269a9a3, 0x38f88096, 0x400cf48b
};
0xfe2e963a, 0x0269a9a3, 0x38f88096, 0x400cf48b};
static const uint32_t cpPixelShaderRegs[] = {
0x00000007, 0x00000002, 0x04000101, 0x00000000,
0x00000001, 0x00000100, 0x00000000, 0x00000000,
@ -158,37 +155,32 @@ static const uint32_t cpPixelShaderRegs[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000f, 0x00000001, 0x00000010,
0x00000000
};
0x00000000};
FXAAShader *FXAAShader::shaderInstance = NULL;
FXAAShader::FXAAShader()
: vertexShader(cuAttributeCount) {
: vertexShader(cuAttributeCount) {
//! create pixel shader
pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs));
resolutionLocation = 0;
pixelShader.addUniformVar((GX2UniformVar) {
"unf_resolution", GX2_SHADER_VAR_TYPE_FLOAT2, 1, resolutionLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar){
"unf_resolution", GX2_SHADER_VAR_TYPE_FLOAT2, 1, resolutionLocation, -1});
samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar) {
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation
});
pixelShader.addSamplerVar((GX2SamplerVar){
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation});
//! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
positionLocation = 0;
texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar) {
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation
});
vertexShader.addAttribVar((GX2AttribVar){
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation});
//! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
@ -198,11 +190,11 @@ FXAAShader::FXAAShader()
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
//! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize);
//! position vertex structure and texture coordinate vertex structure
int32_t i = 0;
int32_t i = 0;
posVtxs[i++] = -1.0f;
posVtxs[i++] = -1.0f;
posVtxs[i++] = 0.0f;
@ -217,7 +209,7 @@ FXAAShader::FXAAShader()
posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0;
i = 0;
texCoords[i++] = 0.0f;
texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f;

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/video/shaders/Shader3D.h>
#include <malloc.h>
#include <string.h>
#include <gui/video/shaders/Shader3D.h>
static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00008009, 0x20000000, 0x0000e4a1,
@ -108,8 +108,7 @@ static const uint32_t cpVertexShaderProgram[] = {
0x07c09f80, 0x7e048200, 0x07e00f00, 0xfe008220,
0x07cc1f01, 0x7e086a4f, 0x07c09f81, 0x7f0c8240,
0x07c08f80, 0xfe088260, 0x2c34800d, 0xe3b4f15e,
0x7642ed30, 0x7408600d
};
0x7642ed30, 0x7408600d};
static const uint32_t cpVertexShaderRegs[] = {
0x00000108, 0x00000000, 0x00000002, 0x00000001,
@ -124,8 +123,7 @@ static const uint32_t cpVertexShaderRegs[] = {
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x00000000, 0x0000000e, 0x00000010
};
0x000000ff, 0x00000000, 0x0000000e, 0x00000010};
static const uint32_t cPixelShaderProgram[] = {
0x20000000, 0x000008a4, 0x03000000, 0x01004085,
@ -169,8 +167,7 @@ static const uint32_t cPixelShaderProgram[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x10000100, 0x01100df0, 0x00008010, 0xecdfea0d,
0x99720984, 0x041cab0d, 0xa28a9ccd, 0x95d199a5
};
0x99720984, 0x041cab0d, 0xa28a9ccd, 0x95d199a5};
static const uint32_t cPixelShaderRegs[] = {
0x00000102, 0x00000002, 0x14000002, 0x00000000,
0x00000002, 0x00000100, 0x00000101, 0x00000000,
@ -182,57 +179,47 @@ static const uint32_t cPixelShaderRegs[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000f, 0x00000001, 0x00000010,
0x00000000
};
0x00000000};
Shader3D *Shader3D::shaderInstance = NULL;
Shader3D::Shader3D()
: vertexShader(cuAttributeCount) {
: vertexShader(cuAttributeCount) {
//! create pixel shader
pixelShader.setProgram(cPixelShaderProgram, sizeof(cPixelShaderProgram), cPixelShaderRegs, sizeof(cPixelShaderRegs));
colorIntensityLocation = 0;
fadeDistanceLocation = 4;
fadeOutLocation = 8;
pixelShader.addUniformVar((GX2UniformVar) {
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_fade_distance", GX2_SHADER_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1
});
fadeDistanceLocation = 4;
fadeOutLocation = 8;
pixelShader.addUniformVar((GX2UniformVar){
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_fade_distance", GX2_SHADER_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1});
samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar) {
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation
});
pixelShader.addSamplerVar((GX2SamplerVar){
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation});
//! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
modelMatrixLocation = 0;
modelMatrixLocation = 0;
projectionMatrixLocation = 16;
viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar) {
"modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1
});
viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar){
"modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1});
positionLocation = 0;
texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar) {
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, positionLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation
});
vertexShader.addAttribVar((GX2AttribVar){
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, positionLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation});
//! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
@ -243,11 +230,11 @@ Shader3D::Shader3D()
//! initialize default quad texture vertexes as those are very commonly used
//! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize);
//! position vertex structure and texture coordinate vertex structure
int32_t i = 0;
int32_t i = 0;
posVtxs[i++] = -1.0f;
posVtxs[i++] = -1.0f;
posVtxs[i++] = 0.0f;
@ -262,7 +249,7 @@ Shader3D::Shader3D()
posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0;
i = 0;
texCoords[i++] = 0.0f;
texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f;

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/video/shaders/ShaderFractalColor.h>
#include <malloc.h>
#include <string.h>
#include <gui/video/shaders/ShaderFractalColor.h>
static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00008009, 0x20000000, 0x0000eca1,
@ -106,8 +106,7 @@ static const uint32_t cpVertexShaderProgram[] = {
0x02c41f01, 0x06086a4f, 0x02c49f01, 0x060c6a6f,
0x02e00f80, 0xfe000220, 0x02c08f00, 0xfe040200,
0x02e08f01, 0xfe0c0240, 0x02c01f80, 0xfe080260,
0x8aa480ad, 0x2bfc5ca6, 0xb5e05b5b, 0xd48dc71c
};
0x8aa480ad, 0x2bfc5ca6, 0xb5e05b5b, 0xd48dc71c};
static const uint32_t cpVertexShaderRegs[] = {
0x00000108, 0x00000000, 0x00000004, 0x00000001,
@ -122,8 +121,7 @@ static const uint32_t cpVertexShaderRegs[] = {
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x00000000, 0x0000000e, 0x00000010
};
0x000000ff, 0x00000000, 0x0000000e, 0x00000010};
static const uint32_t cpPixelShaderProgram[] = {
0x20000000, 0x000008a4, 0x04000000, 0x01004085,
@ -262,8 +260,7 @@ static const uint32_t cpPixelShaderProgram[] = {
0x01c49f80, 0x90000020, 0x0000803f, 0x00000000,
0x7fcc9f80, 0xf880630f, 0xfe20a081, 0x80000000,
0x01cc1f80, 0x90000060, 0xc21e82a7, 0x62ccc547,
0x1708607c, 0x73ea57a6
};
0x1708607c, 0x73ea57a6};
static const uint32_t cpPixelShaderRegs[] = {
0x00000106, 0x00000002, 0x14000003, 0x00000000,
0x00000003, 0x00000100, 0x00000101, 0x00000102,
@ -275,60 +272,49 @@ static const uint32_t cpPixelShaderRegs[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000f, 0x00000001, 0x00000010,
0x00000000
};
0x00000000};
ShaderFractalColor *ShaderFractalColor::shaderInstance = NULL;
ShaderFractalColor::ShaderFractalColor()
: vertexShader(cuAttributeCount) {
: vertexShader(cuAttributeCount) {
//! create pixel shader
pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs));
blurLocation = 0;
blurLocation = 0;
colorIntensityLocation = 4;
fadeOutLocation = 8;
fractalLocation = 12;
pixelShader.addUniformVar((GX2UniformVar) {
"unf_blur_border", GX2_SHADER_VAR_TYPE_FLOAT, 1, blurLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_fract_alpha", GX2_SHADER_VAR_TYPE_INT, 1, fractalLocation, -1
});
fadeOutLocation = 8;
fractalLocation = 12;
pixelShader.addUniformVar((GX2UniformVar){
"unf_blur_border", GX2_SHADER_VAR_TYPE_FLOAT, 1, blurLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_fract_alpha", GX2_SHADER_VAR_TYPE_INT, 1, fractalLocation, -1});
//! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
modelMatrixLocation = 0;
modelMatrixLocation = 0;
projectionMatrixLocation = 16;
viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar) {
"modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1
});
viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar){
"modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1});
positionLocation = 0;
colorLocation = 1;
colorLocation = 1;
texCoordLocation = 2;
vertexShader.addAttribVar((GX2AttribVar) {
"attr_colors", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation
});
vertexShader.addAttribVar((GX2AttribVar){
"attr_colors", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation});
//! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
@ -340,12 +326,12 @@ ShaderFractalColor::ShaderFractalColor()
//! initialize default quad texture vertexes as those are very commonly used
//! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize);
colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciColorVtxsSize);
//! position vertex structure and texture coordinate vertex structure
int32_t i = 0;
int32_t i = 0;
posVtxs[i++] = -1.0f;
posVtxs[i++] = -1.0f;
posVtxs[i++] = 0.0f;
@ -360,7 +346,7 @@ ShaderFractalColor::ShaderFractalColor()
posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0;
i = 0;
texCoords[i++] = 0.0f;
texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f;

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <gui/video/shaders/Texture2DShader.h>
#include <malloc.h>
#include <string.h>
#include <gui/video/shaders/Texture2DShader.h>
static const uint32_t cpVertexShaderProgram[] = {
0x00000000, 0x00008009, 0x20000000, 0x000080a0,
@ -52,8 +52,7 @@ static const uint32_t cpVertexShaderProgram[] = {
0x02c11f80, 0x80000040, 0x01e08f00, 0xfe04624f,
0x01c01f81, 0x7f08626f, 0xfe2c2000, 0x10004000,
0xfe28a080, 0x10004020, 0xeb825790, 0xb6f711be,
0x7c0e2df2, 0x81173cfa
};
0x7c0e2df2, 0x81173cfa};
static const uint32_t cpVertexShaderRegs[] = {
0x00000103, 0x00000000, 0x00000000, 0x00000001,
@ -68,8 +67,7 @@ static const uint32_t cpVertexShaderRegs[] = {
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x00000000, 0x0000000e, 0x00000010
};
0x000000ff, 0x00000000, 0x0000000e, 0x00000010};
static const uint32_t cPixelShaderProgram[] = {
0x20000000, 0x00000ca4, 0x0b000000, 0x00000085,
@ -176,8 +174,7 @@ static const uint32_t cPixelShaderProgram[] = {
0x10000400, 0x04100df0, 0x00008010, 0xecdfea0d,
0x10000300, 0x06100df0, 0x00008010, 0xecdfea0d,
0x10000000, 0x00100df0, 0x00008010, 0xecdfea0d,
0xc8581837, 0x22740275, 0x281eddcc, 0xfa8b9b65
};
0xc8581837, 0x22740275, 0x281eddcc, 0xfa8b9b65};
static const uint32_t cPixelShaderRegs[] = {
0x00000109, 0x00000002, 0x14000001, 0x00000000,
0x00000001, 0x00000100, 0x00000000, 0x00000000,
@ -189,54 +186,45 @@ static const uint32_t cPixelShaderRegs[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000f, 0x00000001, 0x00000010,
0x00000000
};
0x00000000};
Texture2DShader *Texture2DShader::shaderInstance = NULL;
Texture2DShader::Texture2DShader()
: vertexShader(cuAttributeCount) {
: vertexShader(cuAttributeCount) {
//! create pixel shader
pixelShader.setProgram(cPixelShaderProgram, sizeof(cPixelShaderProgram), cPixelShaderRegs, sizeof(cPixelShaderRegs));
blurLocation = 0;
blurLocation = 0;
colorIntensityLocation = 4;
pixelShader.addUniformVar((GX2UniformVar) {
"unf_blur_texture_direction", GX2_SHADER_VAR_TYPE_FLOAT3, 1, blurLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar) {
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1
});
pixelShader.addUniformVar((GX2UniformVar){
"unf_blur_texture_direction", GX2_SHADER_VAR_TYPE_FLOAT3, 1, blurLocation, -1});
pixelShader.addUniformVar((GX2UniformVar){
"unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1});
samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar) {
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation
});
pixelShader.addSamplerVar((GX2SamplerVar){
"sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation});
//! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
angleLocation = 0;
angleLocation = 0;
offsetLocation = 4;
scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar) {
"unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1
});
vertexShader.addUniformVar((GX2UniformVar) {
"unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1
});
scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar){
"unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1});
vertexShader.addUniformVar((GX2UniformVar){
"unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1});
positionLocation = 0;
texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar) {
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation
});
vertexShader.addAttribVar((GX2AttribVar) {
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation
});
vertexShader.addAttribVar((GX2AttribVar){
"attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation});
vertexShader.addAttribVar((GX2AttribVar){
"attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation});
//! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
@ -246,12 +234,12 @@ Texture2DShader::Texture2DShader()
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
//! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize);
texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize);
//! defaults for normal square
//! position vertex structure and texture coordinate vertex structure
int32_t i = 0;
int32_t i = 0;
posVtxs[i++] = -1.0f;
posVtxs[i++] = -1.0f;
posVtxs[i++] = 0.0f;
@ -266,7 +254,7 @@ Texture2DShader::Texture2DShader()
posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0;
i = 0;
texCoords[i++] = 0.0f;
texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f;