[CHG] GRRLIB_ClampVar8 was removed from GRRLIB

This commit is contained in:
Crayon2000 2010-10-27 19:55:53 +00:00
parent 4ad02a1916
commit 6d65703f74
11 changed files with 27 additions and 67 deletions

View file

@ -144,10 +144,10 @@ int GRRLIB_Init (void) {
guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -100.0F); guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -100.0F);
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
guOrtho(perspective, 0, rmode->efbHeight, 0, rmode->fbWidth, 0, 1000.0f); guOrtho(perspective, 0.0f, rmode->efbHeight, 0.0f, rmode->fbWidth, 0.0f, 1000.0f);
GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC);
GX_SetViewport(0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1); GX_SetViewport(0.0f, 0.0f, rmode->fbWidth, rmode->efbHeight, 0.0f, 1.0f);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_TRUE); GX_SetAlphaUpdate(GX_TRUE);
GX_SetAlphaCompare(GX_GREATER, 0, GX_AOP_AND, GX_ALWAYS, 0); GX_SetAlphaCompare(GX_GREATER, 0, GX_AOP_AND, GX_ALWAYS, 0);

View file

@ -37,7 +37,7 @@ THE SOFTWARE.
/** /**
* Version information for GRRLIB. * Version information for GRRLIB.
*/ */
#define GRRLIB_VER_STRING "4.3.1" #define GRRLIB_VER_STRING "4.3.2 alpha"
//============================================================================== //==============================================================================
// Includes // Includes

View file

@ -41,10 +41,6 @@ THE SOFTWARE.
// Prototypes for inlined functions // Prototypes for inlined functions
//============================================================================== //==============================================================================
//------------------------------------------------------------------------------
// GRRLIB_cExtn.h - C extensions (helper functions)
INLINE u8 GRRLIB_ClampVar8 (f32 Value);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GRRLIB_clipping.h - Clipping control // GRRLIB_clipping.h - Clipping control
INLINE void GRRLIB_ClipReset (void); INLINE void GRRLIB_ClipReset (void);
@ -89,7 +85,7 @@ INLINE void GRRLIB_Line (const f32 x1, const f32 y1,
const f32 x2, const f32 y2, const u32 color); const f32 x2, const f32 y2, const u32 color);
INLINE void GRRLIB_Rectangle (const f32 x, const f32 y, INLINE void GRRLIB_Rectangle (const f32 x, const f32 y,
const f32 width, const f32 height, const f32 width, const f32 height,
const u32 color, const u8 filled); const u32 color, const bool filled);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GRRLIB_handle.h - Texture handle manipulation // GRRLIB_handle.h - Texture handle manipulation
@ -124,7 +120,6 @@ INLINE void GRRLIB_FreeTexture (GRRLIB_texImg *tex);
//============================================================================== //==============================================================================
// Definitions of inlined functions // Definitions of inlined functions
//============================================================================== //==============================================================================
#include <grrlib/GRRLIB_cExtn.h> // C extensions (helper functions)
#include <grrlib/GRRLIB_clipping.h> // Clipping control #include <grrlib/GRRLIB_clipping.h> // Clipping control
#include <grrlib/GRRLIB_collision.h> // Collision detection #include <grrlib/GRRLIB_collision.h> // Collision detection
#include <grrlib/GRRLIB_fbComplex.h> // Render to framebuffer: Complex primitives #include <grrlib/GRRLIB_fbComplex.h> // Render to framebuffer: Complex primitives

View file

@ -1,43 +0,0 @@
/*------------------------------------------------------------------------------
Copyright (c) 2010 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
------------------------------------------------------------------------------*/
/*
* @file GRRLIB_cExtn.h
* Inline functions to offer additional C primitives.
*/
#include <math.h>
/**
* A helper function for the YCbCr -> RGB conversion.
* Clamps the given value into a range of 0 - 255 and thus preventing an overflow.
* @param Value The value to clamp. Using float to increase the precision. This makes a full spectrum (0 - 255) possible.
* @return Returns a clean, clamped unsigned char.
*/
INLINE
u8 GRRLIB_ClampVar8 (f32 Value) {
Value = roundf(Value);
if (Value < 0) Value = 0;
else if (Value > 255) Value = 255;
return (u8)Value;
}

View file

@ -31,7 +31,7 @@ THE SOFTWARE.
*/ */
INLINE INLINE
void GRRLIB_FillScreen (const u32 color) { void GRRLIB_FillScreen (const u32 color) {
GRRLIB_Rectangle(-40, -40, rmode->fbWidth +80, rmode->xfbHeight +80, color, 1); GRRLIB_Rectangle(-40.0f, -40.0f, rmode->fbWidth + 80.0f, rmode->xfbHeight + 80.0f, color, true);
} }
/** /**
@ -44,7 +44,7 @@ void GRRLIB_FillScreen (const u32 color) {
INLINE INLINE
void GRRLIB_Plot (const f32 x, const f32 y, const u32 color) { void GRRLIB_Plot (const f32 x, const f32 y, const u32 color) {
GX_Begin(GX_POINTS, GX_VTXFMT0, 1); GX_Begin(GX_POINTS, GX_VTXFMT0, 1);
GX_Position3f32(x, y, 0); GX_Position3f32(x, y, 0.0f);
GX_Color1u32(color); GX_Color1u32(color);
GX_End(); GX_End();
} }
@ -62,9 +62,9 @@ INLINE
void GRRLIB_Line (const f32 x1, const f32 y1, void GRRLIB_Line (const f32 x1, const f32 y1,
const f32 x2, const f32 y2, const u32 color) { const f32 x2, const f32 y2, const u32 color) {
GX_Begin(GX_LINES, GX_VTXFMT0, 2); GX_Begin(GX_LINES, GX_VTXFMT0, 2);
GX_Position3f32(x1, y1, 0); GX_Position3f32(x1, y1, 0.0f);
GX_Color1u32(color); GX_Color1u32(color);
GX_Position3f32(x2, y2, 0); GX_Position3f32(x2, y2, 0.0f);
GX_Color1u32(color); GX_Color1u32(color);
GX_End(); GX_End();
} }
@ -81,7 +81,7 @@ void GRRLIB_Line (const f32 x1, const f32 y1,
INLINE INLINE
void GRRLIB_Rectangle (const f32 x, const f32 y, void GRRLIB_Rectangle (const f32 x, const f32 y,
const f32 width, const f32 height, const f32 width, const f32 height,
const u32 color, const u8 filled) { const u32 color, const bool filled) {
f32 x2 = x + width; f32 x2 = x + width;
f32 y2 = y + height; f32 y2 = y + height;

View file

@ -11,8 +11,6 @@
#include "gfx/Letter_Gothic_Std_14_Bold.h" #include "gfx/Letter_Gothic_Std_14_Bold.h"
extern Mtx _GRR_view;
int main() { int main() {
float l1=0, l2=0; float l1=0, l2=0;
float a=0; float a=0;

View file

@ -11,8 +11,6 @@
#include "gfx/Rockwell_Condensed_12_Bold.h" #include "gfx/Rockwell_Condensed_12_Bold.h"
extern Mtx _GRR_view;
int main() { int main() {
float a = 0; float a = 0;

View file

@ -10,8 +10,6 @@
#include "gfx/font9x12.h" #include "gfx/font9x12.h"
extern Mtx _GRR_view;
int main() { int main() {
f32 rot = 0.0f; f32 rot = 0.0f;

View file

@ -5,12 +5,11 @@
#include <grrlib.h> #include <grrlib.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "Snap_ITC_12.h" #include "Snap_ITC_12.h"
extern Mtx _GRR_view;
int main(int argc, char **argv) { int main(int argc, char **argv) {
f32 lightx=0.0f; f32 lightx=0.0f;

View file

@ -54,6 +54,7 @@ static void createEffect( u8 id, int _x, int _y );
static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha, u8 _red, u8 _green, u8 _blue ); static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha, u8 _red, u8 _green, u8 _blue );
static bool updateParticle( Particle *part ); static bool updateParticle( Particle *part );
static u8 CalculateFrameRate(); static u8 CalculateFrameRate();
static u8 ClampVar8 (f32 Value);
// Initialize general variables // Initialize general variables
extern GXRModeObj *rmode; extern GXRModeObj *rmode;
@ -131,7 +132,7 @@ int main() {
// Update and draw all particles // Update and draw all particles
for (vector<Particle *>::iterator PartIter = ParticleList.begin(); PartIter != ParticleList.end();) { for (vector<Particle *>::iterator PartIter = ParticleList.begin(); PartIter != ParticleList.end();) {
if (updateParticle((*PartIter)) == true) { if (updateParticle((*PartIter)) == true) {
GRRLIB_DrawImg( (*PartIter)->x, (*PartIter)->y, (*PartIter)->tex, (*PartIter)->rot, (*PartIter)->scale, (*PartIter)->scale, RGBA( (*PartIter)->red, (*PartIter)->green, (*PartIter)->blue, GRRLIB_ClampVar8((*PartIter)->alpha*255) ) ); GRRLIB_DrawImg( (*PartIter)->x, (*PartIter)->y, (*PartIter)->tex, (*PartIter)->rot, (*PartIter)->scale, (*PartIter)->scale, RGBA( (*PartIter)->red, (*PartIter)->green, (*PartIter)->blue, ClampVar8((*PartIter)->alpha*255) ) );
} else { } else {
free( (*PartIter) ); free( (*PartIter) );
ParticleList.erase(PartIter); ParticleList.erase(PartIter);
@ -285,3 +286,17 @@ static u8 CalculateFrameRate() {
} }
return FPS; return FPS;
} }
/**
* A helper function for the YCbCr -> RGB conversion.
* Clamps the given value into a range of 0 - 255 and thus preventing an overflow.
* @param Value The value to clamp. Using float to increase the precision. This makes a full spectrum (0 - 255) possible.
* @return Returns a clean, clamped unsigned char.
*/
static u8 ClampVar8 (f32 Value) {
Value = roundf(Value);
if (Value < 0) Value = 0;
else if (Value > 255) Value = 255;
return (u8)Value;
}

View file

@ -31,7 +31,7 @@ PROJECT_NAME = GRRLIB
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 4.3.1 PROJECT_NUMBER = "4.3.2 alpha"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.