シューティングゲーム

#include "display.h"

void displayMain(){
	glClear(GL_COLOR_BUFFER_BIT);

	float test1 = 1.0f;
	int test2 = 23;

	// font test
	fontBegin();
	fontSetPosition(0.0, 100.0);
	fontSetSize(FONT_DEFAULT_SIZE * 0.25);
	fontSetWeight(1.0);
	fontSetColor(0, 0, 255);
	fontDraw("float:%f, int:%d", test1, test2);
	fontEnd();

	glutSwapBuffers();
}
#ifndef __HEADER_FONT
#define __HEADER_FONT

#define FONT_DEFAULT_SIZE (100.0f)

void fontBegin();
void fontEnd();

void fontSetPosition(float _x, float _y);
void fontSetSize(float _size);
void fontSetWeight(float _weight);
void fontSetColor(unsigined char _red, unsigned char _green, unsigned char _blue);
void fontDraw(const char *format, ...);

#endif
#include "font.h"

#include <GL/glut.h>
#include <stdio.h>
#include <stdarg.h> // 可変長引数の関数を実装

static float positionX;  // staticは静的記憶クラス
static float positionY;
static float size = FONT_DEFAULT_SIZE;
static float weight = 1.0;

void fontBegin(){
	glPushMatrix();
	glPushAttrib(GL_ALL_ATTRIB_BITS);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	GLint viewport[4];
	glGetIntegerv(GL_VIEWPORT, viewport);
	gluOrtho2D(0, viewport[2], viewport[3], 0); 

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

void fontEnd(){
	glPopMatrix();
	glPopAttrib();
}

void fontSetPosition(float _x, float _y){
	positionX = _x;
	positionY = _y;
}

void fontSetSize(float _size){
	size = _size;
}

void fontSetWeight(float _weight){
	weight = _weight;
}

void fontSetColor(unsigned char _red, unsigned char _green, unsigned char _blue){
	color[0] = red;
	color[1] = green;
	color[2] = blue;
}

void fontDraw(const char *format, ...){
	va_list argList;
	va_start(argList, format);
	char str[256];
	vsprintf(str, format, argList);
	va_end(argList);

	glLineWidth(weight);
	glColor3ub(color[0], color[1], color[2]);
	glPushMatrix();

	glTranslatef(positionX, positionY + size, 0.0);
	float s = size / FONT_DEFAULT_SIZE;
	glScalef(s, -s, s);
	for(char *p = str; *p != '\0'; p++)
		glutStrokeCharacter(CLUT_STROKE_ROMAN, *p);

	glPopMatrix();
}
main: main.c game.o display.o font.o
	gcc main.c game.o display.o font.o -o main -lglut -lGLU -lGL

game.o: game.c game.h define.h display.h
	gcc -c game.c -o game.o -lglut -lGLU -lGL 

display.o: display.c display.h
	gcc -c display.c -o display.o -lglut -lGLU -lGL

font.o: font.c font.h
	gcc -c font.c -o font.o -lglut -lGLU -lGL

clean:
	rm -rf main *.o

$ make
gcc -c display.c -o display.o -lglut -lGLU -lGL
display.c: In function ‘displayMain’:
display.c:4:2: warning: implicit declaration of function ‘glClear’ [-Wimplicit-function-declaration]
glClear(GL_COLOR_BUFFER_BIT);
^~~~~~~
display.c:4:10: error: ‘GL_COLOR_BUFFER_BIT’ undeclared (first use in this function)
glClear(GL_COLOR_BUFFER_BIT);
^~~~~~~~~~~~~~~~~~~
display.c:4:10: note: each undeclared identifier is reported only once for each function it appears in
display.c:10:2: warning: implicit declaration of function ‘fontBegin’ [-Wimplicit-function-declaration]
fontBegin();
^~~~~~~~~
display.c:11:2: warning: implicit declaration of function ‘fontSetPosition’ [-Wimplicit-function-declaration]
fontSetPosition(0.0, 100.0);
^~~~~~~~~~~~~~~
display.c:12:2: warning: implicit declaration of function ‘fontSetSize’ [-Wimplicit-function-declaration]
fontSetSize(FONT_DEFAULT_SIZE * 0.25);
^~~~~~~~~~~
display.c:12:14: error: ‘FONT_DEFAULT_SIZE’ undeclared (first use in this function)
fontSetSize(FONT_DEFAULT_SIZE * 0.25);
^~~~~~~~~~~~~~~~~
display.c:13:2: warning: implicit declaration of function ‘fontSetWeight’ [-Wimplicit-function-declaration]
fontSetWeight(1.0);
^~~~~~~~~~~~~
display.c:14:2: warning: implicit declaration of function ‘fontSetColor’ [-Wimplicit-function-declaration]
fontSetColor(0, 0, 255);
^~~~~~~~~~~~
display.c:15:2: warning: implicit declaration of function ‘fontDraw’ [-Wimplicit-function-declaration]
fontDraw(“float:%f, int:%d”, test1, test2);
^~~~~~~~
display.c:16:2: warning: implicit declaration of function ‘fontEnd’ [-Wimplicit-function-declaration]
fontEnd();
^~~~~~~
display.c:18:2: warning: implicit declaration of function ‘glutSwapBuffers’ [-Wimplicit-function-declaration]
glutSwapBuffers();
^~~~~~~~~~~~~~~
GNUmakefile:8: recipe for target ‘display.o’ failed
make: *** [display.o] Error 1

何故だーーーーーー