Some reviews for RPI
This commit is contained in:
parent
e563ebe240
commit
a5bfd7db22
@ -18,6 +18,48 @@
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLSL_VERSION 330
|
||||
#define DEFAULT_VERTEX_SHADER "resources/shaders/glsl330/base.vs"
|
||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||
#define GLSL_VERSION 100
|
||||
#define DEFAULT_VERTEX_SHADER "resources/shaders/glsl100/base.vs"
|
||||
#endif
|
||||
|
||||
#define MAX_POSTPRO_SHADERS 12
|
||||
|
||||
typedef enum {
|
||||
FX_GRAYSCALE = 0,
|
||||
FX_POSTERIZATION,
|
||||
FX_DREAM_VISION,
|
||||
FX_PIXELIZER,
|
||||
FX_CROSS_HATCHING,
|
||||
FX_CROSS_STITCHING,
|
||||
FX_PREDATOR_VIEW,
|
||||
FX_SCANLINES,
|
||||
FX_FISHEYE,
|
||||
FX_SOBEL,
|
||||
FX_BLOOM,
|
||||
FX_BLUR,
|
||||
//FX_FXAA
|
||||
} PostproShader;
|
||||
|
||||
static const char *postproShaderText[] = {
|
||||
"GRAYSCALE",
|
||||
"POSTERIZATION",
|
||||
"DREAM_VISION",
|
||||
"PIXELIZER",
|
||||
"CROSS_HATCHING",
|
||||
"CROSS_STITCHING",
|
||||
"PREDATOR_VIEW",
|
||||
"SCANLINES",
|
||||
"FISHEYE",
|
||||
"SOBEL",
|
||||
"BLOOM",
|
||||
"BLUR",
|
||||
//"FXAA"
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
@ -38,8 +80,25 @@ int main()
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/bloom.fs"); // Load postpro shader
|
||||
// Load all postpro shaders
|
||||
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
|
||||
// NOTE 2: We load the correct shader depending on GLSL version
|
||||
Shader shaders[MAX_POSTPRO_SHADERS];
|
||||
|
||||
shaders[FX_GRAYSCALE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
|
||||
shaders[FX_POSTERIZATION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION));
|
||||
shaders[FX_DREAM_VISION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION));
|
||||
shaders[FX_PIXELIZER] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION));
|
||||
shaders[FX_CROSS_HATCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION));
|
||||
shaders[FX_CROSS_STITCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION));
|
||||
shaders[FX_PREDATOR_VIEW] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION));
|
||||
shaders[FX_SCANLINES] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION));
|
||||
shaders[FX_FISHEYE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION));
|
||||
shaders[FX_SOBEL] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION));
|
||||
shaders[FX_BLOOM] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION));
|
||||
shaders[FX_BLUR] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION));
|
||||
|
||||
int currentShader = FX_GRAYSCALE;
|
||||
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
@ -56,6 +115,12 @@ int main()
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera); // Update camera
|
||||
|
||||
if (IsKeyPressed(KEY_RIGHT)) currentShader++;
|
||||
else if (IsKeyPressed(KEY_LEFT)) currentShader--;
|
||||
|
||||
if (currentShader >= MAX_POSTPRO_SHADERS) currentShader = 0;
|
||||
else if (currentShader < 0) currentShader = MAX_POSTPRO_SHADERS - 1;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@ -74,20 +139,25 @@ int main()
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED);
|
||||
|
||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
BeginShaderMode(shader);
|
||||
// Render previously generated texture using selected postpro shader
|
||||
BeginShaderMode(shaders[currentShader]);
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
||||
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
||||
DrawText("< >", 540, 10, 30, DARKBLUE);
|
||||
|
||||
DrawFPS(700, 15);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -95,7 +165,10 @@ int main()
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
|
||||
// Unload all postpro shaders
|
||||
for (int i = 0; i < MAX_POSTPRO_SHADERS; i++) UnloadShader(shaders[i]);
|
||||
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 189 KiB |
@ -195,6 +195,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
else
|
||||
LIBS += -lopenal32dll
|
||||
endif
|
||||
PHYSAC_LIBS = -static -lpthread
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@ -524,23 +525,23 @@ audio/audio_raw_stream: audio/audio_raw_stream.c
|
||||
|
||||
# compile [physac] example - physics demo
|
||||
physac/physics_demo: physac/physics_demo.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) $(PHYSAC_LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [physac] example - physics friction
|
||||
physac/physics_friction: physac/physics_friction.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) $(PHYSAC_LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [physac] example - physics movement
|
||||
physac/physics_movement: physac/physics_movement.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) $(PHYSAC_LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [physac] example - physics restitution
|
||||
physac/physics_restitution: physac/physics_restitution.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) $(PHYSAC_LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [physac] example - physics shatter
|
||||
physac/physics_shatter: physac/physics_shatter.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) $(PHYSAC_LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
external/native_app_glue.o : native_app_glue.c native_app_glue.h
|
||||
|
@ -89,7 +89,7 @@ int main()
|
||||
cursorColor = PURPLE;
|
||||
hitObjectName = "Triangle";
|
||||
|
||||
bary = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc);
|
||||
bary = VectorBarycenter(nearestHit.position, ta, tb, tc);
|
||||
hitTriangle = true;
|
||||
}
|
||||
else hitTriangle = false;
|
||||
@ -136,15 +136,15 @@ int main()
|
||||
// If we hit something, draw the cursor at the hit point
|
||||
if (nearestHit.hit)
|
||||
{
|
||||
DrawCube(nearestHit.hitPosition, 0.3, 0.3, 0.3, cursorColor);
|
||||
DrawCubeWires(nearestHit.hitPosition, 0.3, 0.3, 0.3, RED);
|
||||
DrawCube(nearestHit.position, 0.3, 0.3, 0.3, cursorColor);
|
||||
DrawCubeWires(nearestHit.position, 0.3, 0.3, 0.3, RED);
|
||||
|
||||
Vector3 normalEnd;
|
||||
normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x;
|
||||
normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y;
|
||||
normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z;
|
||||
normalEnd.x = nearestHit.position.x + nearestHit.normal.x;
|
||||
normalEnd.y = nearestHit.position.y + nearestHit.normal.y;
|
||||
normalEnd.z = nearestHit.position.z + nearestHit.normal.z;
|
||||
|
||||
DrawLine3D(nearestHit.hitPosition, normalEnd, RED);
|
||||
DrawLine3D(nearestHit.position, normalEnd, RED);
|
||||
}
|
||||
|
||||
DrawRay(ray, MAROON);
|
||||
@ -163,14 +163,14 @@ int main()
|
||||
DrawText(FormatText("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK);
|
||||
|
||||
DrawText(FormatText("Hit Pos: %3.2f %3.2f %3.2f",
|
||||
nearestHit.hitPosition.x,
|
||||
nearestHit.hitPosition.y,
|
||||
nearestHit.hitPosition.z), 10, ypos + 15, 10, BLACK);
|
||||
nearestHit.position.x,
|
||||
nearestHit.position.y,
|
||||
nearestHit.position.z), 10, ypos + 15, 10, BLACK);
|
||||
|
||||
DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f",
|
||||
nearestHit.hitNormal.x,
|
||||
nearestHit.hitNormal.y,
|
||||
nearestHit.hitNormal.z), 10, ypos + 30, 10, BLACK);
|
||||
nearestHit.normal.x,
|
||||
nearestHit.normal.y,
|
||||
nearestHit.normal.z), 10, ypos + 30, 10, BLACK);
|
||||
|
||||
if (hitTriangle) DrawText(FormatText("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 189 KiB |
@ -38,8 +38,11 @@ int main()
|
||||
SetTextureFilter(font.texture, FILTER_POINT);
|
||||
int currentFontFilter = 0; // FILTER_POINT
|
||||
|
||||
// NOTE: Drag and drop support only available for desktop platforms: Windows, Linux, OSX
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
int count = 0;
|
||||
char **droppedFiles;
|
||||
#endif
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
@ -74,6 +77,7 @@ int main()
|
||||
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
|
||||
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
// Load a dropped TTF file dynamically (at current fontSize)
|
||||
if (IsFileDropped())
|
||||
{
|
||||
@ -86,6 +90,7 @@ int main()
|
||||
ClearDroppedFiles();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@ -119,9 +124,10 @@ int main()
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSpriteFont(font); // SpriteFont unloading
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
#endif
|
||||
UnloadSpriteFont(font); // SpriteFont unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -246,12 +246,14 @@ PHYSACDEF void ClosePhysics(void);
|
||||
#include <stdlib.h> // Required for: malloc(), free(), srand(), rand()
|
||||
#include <math.h> // Required for: cosf(), sinf(), fabs(), sqrtf()
|
||||
|
||||
#include "raymath.h" // Required for: Vector2Add(), Vector2Subtract()
|
||||
|
||||
#if defined(_WIN32)
|
||||
// Functions required to query time on Windows
|
||||
int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
|
||||
int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
|
||||
#elif defined(__linux__) || defined(PLATFORM_WEB)
|
||||
#define _DEFAULT_SOURCE // Enables BSD function definitions and C99 POSIX compliance
|
||||
//#define _DEFAULT_SOURCE // Enables BSD function definitions and C99 POSIX compliance
|
||||
#include <sys/time.h> // Required for: timespec
|
||||
#include <time.h> // Required for: clock_gettime()
|
||||
#include <stdint.h>
|
||||
|
Loading…
Reference in New Issue
Block a user