Compare commits
	
		
			No commits in common. "a2068517ec8c55fed7123c6fa2ba648d438bdeed" and "ea34f7635bcf97899bd5a6137c46e26be91fd0ba" have entirely different histories.
		
	
	
		
			a2068517ec
			...
			ea34f7635b
		
	
		
					 6 changed files with 7 additions and 160 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,3 +1 @@
 | 
				
			||||||
/build
 | 
					/build
 | 
				
			||||||
*.a
 | 
					 | 
				
			||||||
*.o
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1 +0,0 @@
 | 
				
			||||||
int add(int a, int b) { return a + b; }
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,6 +0,0 @@
 | 
				
			||||||
#ifndef ADD_H
 | 
					 | 
				
			||||||
#define ADD_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int add(int a, int b);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // ADD_H
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,34 +0,0 @@
 | 
				
			||||||
# Makefile for the add library
 | 
					 | 
				
			||||||
# Builds a static library from the add.c file
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Library name
 | 
					 | 
				
			||||||
LIB = libadd.a
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Compiler
 | 
					 | 
				
			||||||
CC = gcc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Compiler flags
 | 
					 | 
				
			||||||
CFLAGS = -Wall -Werror -Wextra -pedantic
 | 
					 | 
				
			||||||
CFLAGS += -std=c99 -O3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Source file
 | 
					 | 
				
			||||||
SRC = add.c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Object file
 | 
					 | 
				
			||||||
OBJ = $(SRC:.c=.o)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build the library
 | 
					 | 
				
			||||||
$(LIB): $(OBJ)
 | 
					 | 
				
			||||||
	ar rcs $(LIB) $(OBJ)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build the object file
 | 
					 | 
				
			||||||
$(OBJ): $(SRC)
 | 
					 | 
				
			||||||
	$(CC) $(CFLAGS) -c $(SRC)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
format:
 | 
					 | 
				
			||||||
	clang-format -i *.c include/*.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Clean the object files
 | 
					 | 
				
			||||||
clean:
 | 
					 | 
				
			||||||
	rm -f $(OBJ)
 | 
					 | 
				
			||||||
	rm -f $(LIB)
 | 
					 | 
				
			||||||
							
								
								
									
										13
									
								
								makefile
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								makefile
									
										
									
									
									
								
							| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
#dd Compiler and assembler
 | 
					# Compiler and assembler
 | 
				
			||||||
CC = 		gcc
 | 
					CC = 		gcc
 | 
				
			||||||
AS = 		as
 | 
					AS = 		as
 | 
				
			||||||
LD = 		ld
 | 
					LD = 		ld
 | 
				
			||||||
| 
						 | 
					@ -20,11 +20,6 @@ CFLAGS += -Wno-unused-local-typedefs
 | 
				
			||||||
CFLAGS += -Wno-unused-const-variable
 | 
					CFLAGS += -Wno-unused-const-variable
 | 
				
			||||||
CFLAGS += -Wno-unused-macros
 | 
					CFLAGS += -Wno-unused-macros
 | 
				
			||||||
CFLAGS += -O3
 | 
					CFLAGS += -O3
 | 
				
			||||||
CFLAGS += -Ilibadd/include
 | 
					 | 
				
			||||||
CFLAGS += -lm
 | 
					 | 
				
			||||||
CFLAGS += -lglfw
 | 
					 | 
				
			||||||
CFLAGS += -lGL
 | 
					 | 
				
			||||||
CFLAGS += -lGLU
 | 
					 | 
				
			||||||
CFLAGS += -g
 | 
					CFLAGS += -g
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GITHASH = $(shell git rev-parse --short HEAD)
 | 
					GITHASH = $(shell git rev-parse --short HEAD)
 | 
				
			||||||
| 
						 | 
					@ -41,9 +36,6 @@ OBJS := $(patsubst src/%.c,build/%.o,$(SRCS))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: $(TARGET)
 | 
					all: $(TARGET)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libadd/libadd.a:
 | 
					 | 
				
			||||||
	$(MAKE) -C libadd
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# For convenience
 | 
					# For convenience
 | 
				
			||||||
run: $(TARGET)
 | 
					run: $(TARGET)
 | 
				
			||||||
	@./$(TARGET)
 | 
						@./$(TARGET)
 | 
				
			||||||
| 
						 | 
					@ -53,7 +45,7 @@ mkbuilddir:
 | 
				
			||||||
	@mkdir -p build
 | 
						@mkdir -p build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Link the object files into the target binary
 | 
					# Link the object files into the target binary
 | 
				
			||||||
$(TARGET): $(OBJS) libadd/libadd.a
 | 
					$(TARGET): $(OBJS)
 | 
				
			||||||
	@$(CC) $(CFLAGS) -o $@ $^
 | 
						@$(CC) $(CFLAGS) -o $@ $^
 | 
				
			||||||
	@echo -e "LD \t$^"
 | 
						@echo -e "LD \t$^"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,7 +67,6 @@ clean:
 | 
				
			||||||
	rm -r build
 | 
						rm -r build
 | 
				
			||||||
	rm -f build/*.o
 | 
						rm -f build/*.o
 | 
				
			||||||
	rm -f $(TARGET)*
 | 
						rm -f $(TARGET)*
 | 
				
			||||||
	$(MAKE) -C libadd clean --no-print-directory
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create a signed release
 | 
					# Create a signed release
 | 
				
			||||||
tar: $(TARGET_TAR)
 | 
					tar: $(TARGET_TAR)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										105
									
								
								src/main.c
									
										
									
									
									
								
							
							
						
						
									
										105
									
								
								src/main.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,107 +1,6 @@
 | 
				
			||||||
#define GLFW_INCLUDE_NONE
 | 
					 | 
				
			||||||
#include <GLFW/glfw3.h>
 | 
					 | 
				
			||||||
#include <GL/gl.h>
 | 
					 | 
				
			||||||
#include <GL/glu.h>
 | 
					 | 
				
			||||||
#include <math.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define WIDTH 800
 | 
					int main(int argc, const char **argv) {
 | 
				
			||||||
#define HEIGHT 600
 | 
					  printf("Hello, World!\n");
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Function to draw the cube
 | 
					 | 
				
			||||||
void drawCube() {
 | 
					 | 
				
			||||||
    glBegin(GL_QUADS);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Front face
 | 
					 | 
				
			||||||
    glColor3f(1.0f, 0.0f, 0.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Back face
 | 
					 | 
				
			||||||
    glColor3f(0.0f, 1.0f, 0.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Top face
 | 
					 | 
				
			||||||
    glColor3f(0.0f, 0.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Bottom face
 | 
					 | 
				
			||||||
    glColor3f(1.0f, 1.0f, 0.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Right face
 | 
					 | 
				
			||||||
    glColor3f(1.0f, 0.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Left face
 | 
					 | 
				
			||||||
    glColor3f(0.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, -1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, -1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, 1.0f);
 | 
					 | 
				
			||||||
    glVertex3f(-1.0f, 1.0f, -1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    glEnd();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main() {
 | 
					 | 
				
			||||||
    // Initialize GLFW
 | 
					 | 
				
			||||||
    if (!glfwInit()) {
 | 
					 | 
				
			||||||
        fprintf(stderr, "Failed to initialize GLFW\n");
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Create a windowed mode window and its OpenGL context
 | 
					 | 
				
			||||||
    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Rotating Cube", NULL, NULL);
 | 
					 | 
				
			||||||
    if (!window) {
 | 
					 | 
				
			||||||
        glfwTerminate();
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Make the window's context current
 | 
					 | 
				
			||||||
    glfwMakeContextCurrent(window);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Loop until the user closes the window
 | 
					 | 
				
			||||||
    while (!glfwWindowShouldClose(window)) {
 | 
					 | 
				
			||||||
        // Clear the framebuffer
 | 
					 | 
				
			||||||
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        // Set up the view
 | 
					 | 
				
			||||||
        glMatrixMode(GL_PROJECTION);
 | 
					 | 
				
			||||||
        glLoadIdentity();
 | 
					 | 
				
			||||||
        gluPerspective(45.0f, (float)WIDTH / (float)HEIGHT, 0.1f, 100.0f);
 | 
					 | 
				
			||||||
        glMatrixMode(GL_MODELVIEW);
 | 
					 | 
				
			||||||
        glLoadIdentity();
 | 
					 | 
				
			||||||
        gluLookAt(3, 3, 3, 0, 0, 0, 0, 1, 0); // Eye position, look at position, up direction
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Rotate the cube
 | 
					 | 
				
			||||||
        static double angle = 0;
 | 
					 | 
				
			||||||
        glRotated(angle, 0, 1, 1); // Rotate around x, y, and z axes
 | 
					 | 
				
			||||||
        angle += 0.5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Draw the cube
 | 
					 | 
				
			||||||
        drawCube();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Swap front and back buffers
 | 
					 | 
				
			||||||
        glfwSwapBuffers(window);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Poll for and process events
 | 
					 | 
				
			||||||
        glfwPollEvents();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    glfwTerminate();
 | 
					 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue