From 1997801f88c7581849cc52f2b71b3257165fd95b Mon Sep 17 00:00:00 2001 From: PedroEdiaz Date: Fri, 4 Oct 2024 00:37:52 -0600 Subject: [PATCH] Merge: doc -> main --- Makefile | 14 +++++++------- README.md | 38 ++++++++++++-------------------------- src/context.c | 3 +-- src/input.c | 3 +-- src/main.c | 9 ++++++--- src/matrix.c | 1 - src/mesh.c | 5 ++--- src/shader.c | 7 ++----- src/texture.c | 2 +- src/window.c | 2 +- 10 files changed, 33 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 56e34b0..3ea3d4b 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,13 @@ OBJ = \ src/shader.o \ src/input.o \ src/mesh.o \ + src/alan.o \ src/main.o CFLAGS = \ -I./ext/cglm/include \ -I./ext/glfw/include \ - -Wall -Wno-unused-function -std=c99 \ - -D_XOPEN_SOURCE + -Wall -Wno-unused-function -std=c99 \ help: @echo "Para compilar el proyecto a tu sistema operativo" @@ -30,19 +30,19 @@ help: # WINDOWS windows: $(OBJ) glfw.dll - $(CC) -L. -lGL -lglfw -o $(BIN).exe $(OBJ) + $(CC) $(CFLAGS) $(OBJ) -o $(BIN) -L. -lglfw -lopengl32 -lglew32 glfw.dll: - $(CC) -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o $@ + $(CC) -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o $@ -lgdi32 # LINUX linux-x11: $(OBJ) $(MAKE) BKN=_GLFW_X11 libglfw.so - $(CC) -L. -lGL -lglfw -o $(BIN) $(OBJ) + $(CC) -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw linux-wayland: $(OBJ) $(MAKE) BKN=_GLFW_WAYLAND libglfw.so - $(CC) -L. -lGL -lglfw -o $(BIN) $(OBJ) + $(CC) -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw run-linux: LD_LIBRARY_PATH=. ./$(BIN) @@ -50,7 +50,7 @@ run-linux: # COCOA cocoa: $(OBJ) $(MAKE) BKN=_GLFW_COCOA libglfw.so - $(CC) -framework OpenGL -L. lglfw -o $(BIN) $(OBJ) + $(CC) -framework OpenGL -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw libglfw.so: $(CC) -fPIC -shared -D$(BKN) -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o $@ diff --git a/README.md b/README.md index 8564ef8..3d19d24 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ manigraph es un graficador interactiva de variedades que lee archivos binarios, una variedad multidimensional y grafica esta variedad en una proyección tridimensional. # Dependencias -Para poder compilar el proyecto hace falta los siguientes pro. +Para poder compilar el proyecto hace falta lo siguiente. ## Programas - `cc`: Cualquier compilador de C. - `git`: Gestor de dependencias. (Opcional) @@ -14,6 +14,7 @@ Para poder compilar el proyecto hace falta los siguientes pro. ## Librerías - `openGL`: A cross-platform API for rendering 2D and 3D graphics. (no incluida) +- `glew`: The OpenGL Extension Wrangler Library (no incluida) - `glfw`: A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input. - `cglm`: Highly Optimized 2D / 3D Graphics Math (glm) for C. ### Linux @@ -21,28 +22,18 @@ Para compilar `glfw` en linux hacen falta las siguientes librerías según el ca - `x11`: libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel - `wayland`: libwayland-dev libxkbcommon-dev wayland-protocols -# Codigo fuente -Para adquirir el código fuente de manigraph se puede usar git o descargar manualmente los -archivos zip. - -## git via https -Usando git se necesitan ejecutar los siguientes comándos en la terminal. +# Descargas +- [git](https://git-scm.com/downloads/win) +- [MinGW](https://github.com/niXman/mingw-builds-binaries/releases) +- [glew](https://glew.sourceforge.net/) +# Clonar el código fuente ``` git clone https://gitea.adles.top/software/manigraph.git cd manigraph git submodule update --init --recursive ``` -## zip files -Alternativamente se puede descargar el código fuente en formato zip usando las siguientes -direcciones y acomodando manualmente las carpetas de `glfw` y `cglm` en `ext/`. - -- [manigraph](https://gitea.adles.top/software/manigraph/archive/main.zip) -- [glfw](https://github.com/glfw/glfw/archive/refs/heads/master.zip) -- [cglm](https://github.com/recp/cglm/archive/refs/heads/master.zip) - - # Compilación Para compilar manualmente el proyecto se puede usar `make` o ejecutar los comandos manualmente en el código fuente de `manigraph`. @@ -66,7 +57,7 @@ explicando el tema: [Compiling GLFW](https://www.glfw.org/docs/3.3/compile.html) #### Windows ``` -cc -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o glfw.dll +cc -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o glfw.dll -lgdi32 ``` #### Linux @@ -83,24 +74,19 @@ cc -fPIC -shared -D_GLFW_COCOA -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o libglfw.s ### Manigraph #### Windows ``` -cc -L. -lglfw -lGL -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph.exe +cc -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph -L. -lglfw -lopengl32 -lglew32 ``` #### Linux ``` -cc -L. -lglfw -lGL -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph +cc -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph -L. -lglfw -lGL -lGLEW ``` #### Mac ``` -cc -L. -lglfw -framework GL -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph +cc -framework GL -I ext/cglm/include/ -I ext/glfw/include/ src/*.c -o manigraph -L. -lglfw -lGLEW ``` # Ejecutar -En linux se puede ejecutar el programa sin instalar la llibreria de glfw usando: -## make -``` -make run-linux -``` -## manual +En linux se puede ejecutar el programa sin instalar la libreria de glfw usando: ``` LD_LIBRARY_PATH=. ./manigraph ``` diff --git a/src/context.c b/src/context.c index f8eaec2..40b19cb 100644 --- a/src/context.c +++ b/src/context.c @@ -1,6 +1,5 @@ -#define GL_GLEXT_PROTOTYPES -#include #include "main.h" +#include void set_clean_color_context( unsigned char r, unsigned char g, unsigned char b ) { diff --git a/src/input.c b/src/input.c index 97d45d2..7978444 100644 --- a/src/input.c +++ b/src/input.c @@ -1,7 +1,6 @@ -#include #include "main.h" -#define inline #include +#include #define ANGLE ((float)0x02/0xff*2*GLM_PI) diff --git a/src/main.c b/src/main.c index 388d828..554f207 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,9 @@ -#include - #include "main.h" #include "data/cube.h" #include "data/axis.h" #include "data/shaders.h" +#include +//#include #define WIDTH 512 #define HEIGHT 512 @@ -31,6 +31,8 @@ int main( void ) use_window( window ); set_clean_color_context( 0x2E, 0x07, 0x3F ); + glewInit(); + if( !( shader = create_shader() ) ) goto error_shader; @@ -57,13 +59,14 @@ int main( void ) load_rot_matrix( shader, q ); clean_context(); - +#ifndef DEBUG load_mdl_matrix( shader, 0, 0 ); draw_mesh( m_axis ); load_mdl_matrix( shader, 1, 1 ); draw_mesh( m_axis ); load_mdl_matrix( shader, 2, 2 ); draw_mesh( m_axis ); +#endif load_mdl_matrix( shader, 0, 3 ); draw_mesh( m_cube ); } diff --git a/src/matrix.c b/src/matrix.c index ee69598..eda0e0c 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -1,5 +1,4 @@ #include "main.h" -#define inline #include #include #include diff --git a/src/mesh.c b/src/mesh.c index 90b2258..4bfb8d1 100755 --- a/src/mesh.c +++ b/src/mesh.c @@ -1,7 +1,6 @@ -#define GL_GLEXT_PROTOTYPES -#include -#include #include "main.h" +#include +#include struct obj { diff --git a/src/shader.c b/src/shader.c index 7b3f7ee..d4dbc71 100644 --- a/src/shader.c +++ b/src/shader.c @@ -1,13 +1,10 @@ -#define GL_GLEXT_PROTOTYPES -#include #include "main.h" +#include #ifdef DEBUG #include #endif -#define NULL ((void*)0) - void destroy_shader( unsigned int shader ) { return glDeleteProgram( shader ); @@ -38,7 +35,7 @@ unsigned char gload_program( unsigned int program, const char * src, return 0; shader = glCreateShader(type[i]); - glShaderSource( shader, 1, (const GLchar **)&src, NULL); + glShaderSource( shader, 1, (const GLchar **)&src, ((void*)0 )); glCompileShader(shader); glGetShaderiv( shader, GL_COMPILE_STATUS, &status ); diff --git a/src/texture.c b/src/texture.c index 8bd6e46..e32d006 100644 --- a/src/texture.c +++ b/src/texture.c @@ -1,5 +1,5 @@ #include "main.h" -#include +#include #define TYPE GL_TEXTURE_2D_ARRAY diff --git a/src/window.c b/src/window.c index df919ff..d9febdc 100644 --- a/src/window.c +++ b/src/window.c @@ -1,5 +1,5 @@ -#include #include "main.h" +#include void __window_callback( GLFWwindow * window, int w, int h ) {