This commit is contained in:
IoIxD 2024-08-29 23:05:43 -07:00
commit 2991d95bbb
4 changed files with 1129 additions and 523 deletions

View file

@ -0,0 +1,119 @@
/*******************************************************************************************
*
* raylib [core] example - Ascii rendering
*
* Example originally created with raylib 5.5, last time updated with raylib 5.5
*
* Example contributed by Gavin Parker (@IoIxD) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2023 Gavin Parker (@IoIxD)
*
********************************************************************************************/
#include "raylib.h"
#include "rmod.h"
#include "GLFW/glfw3.h" // Windows/Context and inputs management
#include <stdio.h> // Required for: printf()
#include "rlgl.h"
#include "raymath.h"
const int screenWidth = 800;
const int screenHeight = 450;
GLFWwindow *window;
int CustomInitPlatform(void) {
if (!glfwInit())
{
printf("GLFW3: Can not initialize GLFW\n");
return 1;
}
else printf("GLFW3: GLFW initialized successfully\n");
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_DEPTH_BITS, 16);
// WARNING: OpenGL 3.3 Core profile only
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#if defined(__APPLE__)
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
#endif
window = glfwCreateWindow(screenWidth, screenHeight, "rlgl standalone", NULL, NULL);
if (!window)
{
glfwTerminate();
return 2;
}
else printf("GLFW3: Window created successfully\n");
//glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwSetWindowPos(window, 200, 200);
glfwMakeContextCurrent(window);
glfwSwapInterval(0);
// Load OpenGL 3.3 supported extensions
rlLoadExtensions(glfwGetProcAddress);
//--------------------------------------------------------
// Initialize OpenGL context (states and resources)
rlglInit(screenWidth, screenHeight);
// Initialize viewport and internal projection/modelview matrices
rlViewport(0, 0, screenWidth, screenHeight);
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
rlLoadIdentity(); // Reset current matrix (PROJECTION)
rlOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); // Orthographic projection with top-left corner at (0,0)
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
return 0;
}
void CustomClosePlatform(void) {
glfwDestroyWindow(window); // Close window
glfwTerminate(); // Free GLFW3 resources
}
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
union OverridableFunctionPointer funcs;
CustomInitPlatform();
OverrideInternalFunction("InitPlatform",&funcs);
OverrideInternalFunction("ClosePlatform",&funcs);
RenderTexture2D fb = LoadRenderTexture(80,24);
InitWindow(1,1,"r");
Color col;
//--------------------------------------------------------------------------------------
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(WHITE);
BeginTextureMode(fb);
ClearBackground(RED);
EndTextureMode();
EndDrawing();
glfwSwapBuffers(window);
glfwPollEvents();
}
CustomClosePlatform();
return 0;
}

View file

@ -333,4 +333,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

View file

@ -47,25 +47,25 @@ int main(void)
ClearBackground(RAYWHITE);
for (int i = 0, y = 5; i < 4; i++) // MAX_GAMEPADS = 4
for (int i = 0, y = 10; i < 4; i++) // MAX_GAMEPADS = 4
{
if (IsGamepadAvailable(i))
{
DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 10, BLACK);
y += 11;
DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 10, BLACK);
y += 11;
DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 20, BLACK);
y += 30;
DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 20, BLACK);
y += 30;
for (int axis = 0; axis < GetGamepadAxisCount(i); axis++)
{
DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 10, BLACK);
y += 11;
DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 20, BLACK);
y += 30;
}
for (int button = 0; button < 32; button++)
{
DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 10, BLACK);
y += 11;
DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 20, BLACK);
y += 30;
}
}
}
@ -80,4 +80,4 @@ int main(void)
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
}
}

View file

@ -100,7 +100,7 @@ int main(void)
DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop