2016-04-23 12:29:19 +03:00
|
|
|
/*******************************************************************************************
|
|
|
|
*
|
|
|
|
* raylib [rlgl] example - Using rlgl module as standalone module
|
|
|
|
*
|
|
|
|
* NOTE: This example requires OpenGL 3.3 or ES2 versions for shaders support,
|
|
|
|
* OpenGL 1.1 does not support shaders but it can also be used.
|
|
|
|
*
|
|
|
|
* Compile rlgl module using:
|
|
|
|
* gcc -c rlgl.c -Wall -std=c99 -DRLGL_STANDALONE -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33
|
|
|
|
*
|
|
|
|
* Compile example using:
|
2016-05-31 21:08:36 +03:00
|
|
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) rlgl.o -lglfw3 -lopengl32 -lgdi32 -std=c99
|
2016-04-23 12:29:19 +03:00
|
|
|
*
|
|
|
|
* This example has been created using raylib 1.5 (www.raylib.com)
|
|
|
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
|
|
|
*
|
|
|
|
********************************************************************************************/
|
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
#include "glad.h" // Extensions loading library
|
|
|
|
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
#define RLGL_STANDALONE
|
2016-06-08 00:44:53 +03:00
|
|
|
#include "rlgl.h" // rlgl library: OpenGL 1.1 immediate-mode style coding
|
2016-04-23 12:29:19 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
|
|
|
|
#define RED (Color){ 230, 41, 55, 255 } // Red
|
|
|
|
#define MAROON (Color){ 190, 33, 55, 255 } // Maroon
|
|
|
|
#define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
|
|
|
|
#define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Module specific Functions Declaration
|
|
|
|
//----------------------------------------------------------------------------------
|
2016-05-31 21:08:36 +03:00
|
|
|
static void ErrorCallback(int error, const char* description);
|
|
|
|
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
2016-04-23 12:29:19 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
// Drawing functions (uses rlgl functionality)
|
|
|
|
static void DrawGrid(int slices, float spacing);
|
|
|
|
static void DrawCube(Vector3 position, float width, float height, float length, Color color);
|
|
|
|
static void DrawCubeWires(Vector3 position, float width, float height, float length, Color color);
|
|
|
|
static void DrawRectangleV(Vector2 position, Vector2 size, Color color);
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Main Entry point
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
int main(void)
|
|
|
|
{
|
2016-05-31 21:08:36 +03:00
|
|
|
// Initialization
|
|
|
|
//--------------------------------------------------------------------------------------
|
2016-04-23 12:29:19 +03:00
|
|
|
const int screenWidth = 800;
|
|
|
|
const int screenHeight = 450;
|
|
|
|
|
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
// GLFW3 Initialization + OpenGL 3.3 Context + Extensions
|
|
|
|
//--------------------------------------------------------
|
2016-04-23 12:29:19 +03:00
|
|
|
glfwSetErrorCallback(ErrorCallback);
|
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
if (!glfwInit())
|
|
|
|
{
|
2016-06-08 00:44:53 +03:00
|
|
|
TraceLog(WARNING, "GLFW3: Can not initialize GLFW");
|
|
|
|
return 1;
|
2016-05-31 21:08:36 +03:00
|
|
|
}
|
2016-06-08 00:44:53 +03:00
|
|
|
else TraceLog(INFO, "GLFW3: GLFW initialized successfully");
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
glfwWindowHint(GLFW_SAMPLES, 4);
|
2016-05-31 21:08:36 +03:00
|
|
|
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
2016-04-23 12:29:19 +03:00
|
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
|
|
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
2016-05-31 21:08:36 +03:00
|
|
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
2016-04-23 12:29:19 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "rlgl standalone", NULL, NULL);
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
glfwTerminate();
|
2016-06-08 00:44:53 +03:00
|
|
|
return 2;
|
2016-04-23 12:29:19 +03:00
|
|
|
}
|
2016-06-08 00:44:53 +03:00
|
|
|
else TraceLog(INFO, "GLFW3: Window created successfully");
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
glfwSetKeyCallback(window, KeyCallback);
|
|
|
|
|
|
|
|
glfwMakeContextCurrent(window);
|
|
|
|
glfwSwapInterval(1);
|
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
// Load OpenGL 3.3 extensions
|
2016-04-23 12:29:19 +03:00
|
|
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
|
|
|
{
|
2016-06-08 00:44:53 +03:00
|
|
|
TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
|
|
|
|
return 3;
|
2016-04-23 12:29:19 +03:00
|
|
|
}
|
2016-06-08 00:44:53 +03:00
|
|
|
else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully");
|
2016-05-31 21:08:36 +03:00
|
|
|
//--------------------------------------------------------
|
2016-04-23 12:29:19 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
// Initialize rlgl internal buffers and OpenGL state
|
2016-04-23 12:29:19 +03:00
|
|
|
rlglInit();
|
|
|
|
|
2016-06-26 00:29:03 +03:00
|
|
|
// 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)
|
|
|
|
|
|
|
|
rlClearColor(245, 245, 245, 255); // Define clear color
|
|
|
|
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
|
|
|
|
|
|
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; // Cube default position (center)
|
2016-04-23 12:29:19 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
Camera camera;
|
|
|
|
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
|
|
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
|
|
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
|
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Main game loop
|
|
|
|
while (!glfwWindowShouldClose(window))
|
2016-04-23 12:29:19 +03:00
|
|
|
{
|
2016-05-31 21:08:36 +03:00
|
|
|
// Update
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// ...
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Draw
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
rlClearScreenBuffers(); // Clear current framebuffer
|
2016-06-08 00:44:53 +03:00
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
// Calculate projection matrix (from perspective) and view matrix from camera look at
|
|
|
|
Matrix matProj = MatrixPerspective(camera.fovy, (double)screenWidth/(double)screenHeight, 0.01, 1000.0);
|
|
|
|
MatrixTranspose(&matProj);
|
|
|
|
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
2016-06-08 00:44:53 +03:00
|
|
|
|
|
|
|
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
|
|
|
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
2016-05-31 21:08:36 +03:00
|
|
|
|
|
|
|
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
|
|
|
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, RAYWHITE);
|
|
|
|
DrawGrid(10, 1.0f);
|
|
|
|
|
|
|
|
// NOTE: Internal buffers drawing (3D data)
|
2016-06-08 00:44:53 +03:00
|
|
|
rlglDraw();
|
2016-05-31 21:08:36 +03:00
|
|
|
|
2016-06-08 00:44:53 +03:00
|
|
|
// Draw '2D' elements in the scene (GUI)
|
|
|
|
#define RLGL_CREATE_MATRIX_MANUALLY
|
|
|
|
#if defined(RLGL_CREATE_MATRIX_MANUALLY)
|
|
|
|
|
2016-05-31 21:08:36 +03:00
|
|
|
matProj = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0);
|
|
|
|
MatrixTranspose(&matProj);
|
|
|
|
matView = MatrixIdentity();
|
|
|
|
|
2016-06-08 00:44:53 +03:00
|
|
|
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
|
|
|
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
|
|
|
|
|
|
|
#else // Let rlgl generate and multiply matrix internally
|
|
|
|
|
|
|
|
rlMatrixMode(RL_PROJECTION); // Enable internal projection matrix
|
|
|
|
rlLoadIdentity(); // Reset internal projection matrix
|
|
|
|
rlOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0); // Recalculate internal projection matrix
|
|
|
|
rlMatrixMode(RL_MODELVIEW); // Enable internal modelview matrix
|
|
|
|
rlLoadIdentity(); // Reset internal modelview matrix
|
|
|
|
#endif
|
|
|
|
DrawRectangleV((Vector2){ 10.0f, 10.0f }, (Vector2){ 600.0f, 20.0f }, DARKGRAY);
|
2016-05-31 21:08:36 +03:00
|
|
|
|
|
|
|
// NOTE: Internal buffers drawing (2D data)
|
2016-06-08 00:44:53 +03:00
|
|
|
rlglDraw();
|
2016-05-31 21:08:36 +03:00
|
|
|
|
2016-04-23 12:29:19 +03:00
|
|
|
glfwSwapBuffers(window);
|
|
|
|
glfwPollEvents();
|
2016-05-31 21:08:36 +03:00
|
|
|
//----------------------------------------------------------------------------------
|
2016-04-23 12:29:19 +03:00
|
|
|
}
|
2016-05-31 21:08:36 +03:00
|
|
|
|
|
|
|
// De-Initialization
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
rlglClose(); // Unload rlgl internal buffers and default shader/texture
|
2016-04-23 12:29:19 +03:00
|
|
|
|
|
|
|
glfwDestroyWindow(window);
|
|
|
|
glfwTerminate();
|
2016-05-31 21:08:36 +03:00
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
2016-04-23 12:29:19 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Module specific Functions Definitions
|
|
|
|
//----------------------------------------------------------------------------------
|
2016-05-31 21:08:36 +03:00
|
|
|
|
|
|
|
// GLFW3: Error callback
|
|
|
|
static void ErrorCallback(int error, const char* description)
|
|
|
|
{
|
2016-06-08 00:44:53 +03:00
|
|
|
TraceLog(ERROR, description);
|
2016-05-31 21:08:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// GLFW3: Keyboard callback
|
|
|
|
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
|
|
|
{
|
|
|
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
|
|
|
{
|
|
|
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
|
|
|
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
2016-04-23 12:29:19 +03:00
|
|
|
{
|
|
|
|
rlBegin(RL_TRIANGLES);
|
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
rlVertex2i(position.x, position.y);
|
|
|
|
rlVertex2i(position.x, position.y + size.y);
|
|
|
|
rlVertex2i(position.x + size.x, position.y + size.y);
|
|
|
|
|
|
|
|
rlVertex2i(position.x, position.y);
|
|
|
|
rlVertex2i(position.x + size.x, position.y + size.y);
|
|
|
|
rlVertex2i(position.x + size.x, position.y);
|
|
|
|
rlEnd();
|
2016-05-31 21:08:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw a grid centered at (0, 0, 0)
|
|
|
|
static void DrawGrid(int slices, float spacing)
|
|
|
|
{
|
|
|
|
int halfSlices = slices / 2;
|
|
|
|
|
|
|
|
rlBegin(RL_LINES);
|
|
|
|
for(int i = -halfSlices; i <= halfSlices; i++)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
rlColor3f(0.5f, 0.5f, 0.5f);
|
|
|
|
rlColor3f(0.5f, 0.5f, 0.5f);
|
|
|
|
rlColor3f(0.5f, 0.5f, 0.5f);
|
|
|
|
rlColor3f(0.5f, 0.5f, 0.5f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rlColor3f(0.75f, 0.75f, 0.75f);
|
|
|
|
rlColor3f(0.75f, 0.75f, 0.75f);
|
|
|
|
rlColor3f(0.75f, 0.75f, 0.75f);
|
|
|
|
rlColor3f(0.75f, 0.75f, 0.75f);
|
|
|
|
}
|
|
|
|
|
|
|
|
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
|
|
|
|
rlVertex3f((float)i*spacing, 0.0f, (float)halfSlices*spacing);
|
|
|
|
|
|
|
|
rlVertex3f((float)-halfSlices*spacing, 0.0f, (float)i*spacing);
|
|
|
|
rlVertex3f((float)halfSlices*spacing, 0.0f, (float)i*spacing);
|
|
|
|
}
|
|
|
|
rlEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw cube
|
|
|
|
// NOTE: Cube position is the center position
|
|
|
|
void DrawCube(Vector3 position, float width, float height, float length, Color color)
|
|
|
|
{
|
|
|
|
float x = 0.0f;
|
|
|
|
float y = 0.0f;
|
|
|
|
float z = 0.0f;
|
|
|
|
|
|
|
|
rlPushMatrix();
|
|
|
|
|
|
|
|
// NOTE: Be careful! Function order matters (rotate -> scale -> translate)
|
|
|
|
rlTranslatef(position.x, position.y, position.z);
|
|
|
|
//rlScalef(2.0f, 2.0f, 2.0f);
|
|
|
|
//rlRotatef(45, 0, 1, 0);
|
|
|
|
|
|
|
|
rlBegin(RL_TRIANGLES);
|
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
// Front Face -----------------------------------------------------
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
|
|
|
|
// Back Face ------------------------------------------------------
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
|
|
|
|
// Top Face -------------------------------------------------------
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
|
|
|
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
|
|
|
|
|
|
|
// Bottom Face ----------------------------------------------------
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
|
|
|
|
|
|
|
// Right face -----------------------------------------------------
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
|
|
|
|
// Left Face ------------------------------------------------------
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlEnd();
|
|
|
|
rlPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw cube wires
|
|
|
|
void DrawCubeWires(Vector3 position, float width, float height, float length, Color color)
|
|
|
|
{
|
|
|
|
float x = 0.0f;
|
|
|
|
float y = 0.0f;
|
|
|
|
float z = 0.0f;
|
|
|
|
|
|
|
|
rlPushMatrix();
|
|
|
|
|
|
|
|
rlTranslatef(position.x, position.y, position.z);
|
|
|
|
//rlRotatef(45, 0, 1, 0);
|
|
|
|
|
|
|
|
rlBegin(RL_LINES);
|
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
|
|
|
|
|
|
|
// Front Face -----------------------------------------------------
|
|
|
|
// Bottom Line
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
|
|
|
|
// Left Line
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
|
|
|
|
|
|
|
// Top Line
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
|
|
|
|
// Right Line
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
|
|
|
|
|
|
|
// Back Face ------------------------------------------------------
|
|
|
|
// Bottom Line
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
|
|
|
|
// Left Line
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
|
|
|
|
// Top Line
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
|
|
|
|
// Right Line
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
|
|
|
|
|
|
|
// Top Face -------------------------------------------------------
|
|
|
|
// Left Line
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front
|
|
|
|
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
|
|
|
|
|
|
|
|
// Right Line
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front
|
|
|
|
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
|
|
|
|
|
|
|
|
// Bottom Face ---------------------------------------------------
|
|
|
|
// Left Line
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front
|
|
|
|
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
|
|
|
|
|
|
|
|
// Right Line
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front
|
|
|
|
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
|
|
|
|
rlEnd();
|
|
|
|
rlPopMatrix();
|
|
|
|
}
|