Code: Select all
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -O2 -fomit-frame-pointer -ml -m4-single-only -ffunction-sections -fdata-sections -I/opt/toolchains/dc/kos/include -I/opt/toolchains/dc/kos/kernel/arch/dreamcast/include -I/opt/toolchains/dc/kos/addons/include -I/opt/toolchains/dc/kos/../kos-ports/include -I/opt/toolchains/dc/kos/include -I/opt/toolchains/dc/kos/kernel/arch/dreamcast/include -I/opt/toolchains/dc/kos/addons/include -I/opt/toolchains/dc/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/opt/toolchains/dc/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/opt/toolchains/dc/kos/lib/dreamcast -L/opt/toolchains/dc/kos/addons/lib/dreamcast -L/opt/toolchains/dc/kos/../kos-ports/lib -o Raycaster.elf \
raycast.o main.o romdisk.o -lm -lkosutils -lGL -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
/opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/9.3.0/../../../../sh-elf/bin/ld: /opt/toolchains/dc/kos/../kos-ports/lib/libGL.a(gl-api.o): in function `_glKosVertex3fpv':
/opt/toolchains/dc/kos-ports/libGL/build/libGL-2.0.0/gl-api.c:623: undefined reference to `__glKosVertexBufPointer'
...More errors similar to this...
Code: Select all
#include <kos.h>
// kosext2fs
#include <ext2/fs_ext2.h>
// kosutils
#include <kos/bspline.h>
#include <kos/img.h>
#include <kos/md5.h>
#include <kos/netcfg.h>
#include <kos/pcx.h>
#include <kos/vector.h>
// libGL
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
#include <GL/glut.h>
// math
#include <math.h>
// ppp
#include <ppp/ppp.h>
// raycasting methods
#include "raycast.h"
#ifdef DEBUG
#include <arch/gdb.h>
#endif
#define PACK_PIXEL(r, g, b) ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
/* These macros tell KOS how to initialize itself. All of this initialization
happens before main() gets called, and the shutdown happens afterwards. So
you need to set any flags you want here. Here are some possibilities:
INIT_NONE -- don't do any auto init
INIT_IRQ -- Enable IRQs
INIT_THD_PREEMPT -- Enable pre-emptive threading
INIT_NET -- Enable networking (doesn't imply lwIP!)
INIT_MALLOCSTATS -- Enable a call to malloc_stats() right before shutdown
You can OR any or all of those together. If you want to start out with
the current KOS defaults, use INIT_DEFAULT (or leave it out entirely). */
KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
/* Declaration of the romdisk
You can access the files inside it by using the "/rd" mounting point. */
extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
/* Your program's main entry point */
int main(int argc, char *argv[]) {
#ifdef DEBUG
/* This is needed for the Debug target.
Please don't remove this part of code if you want to use the Code::Blocks debugger.
Also, you'll need to configure Dreamcast Tool (dc-tool) from the DreamSDK Manager. */
gdb_init();
printf("Connection established to %s!", PROJECT_NAME);
#endif
/* Your program start here... */
printf("\nHello world from %s!\n\n", PROJECT_NAME);
glKosInit();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glOrtho(0.0, 10.0, 0.0, 10.0, -1.0, 100.0); // setup a 10x10x2 viewing world
glClearColor(0.29f, 0.46f, 0.84f, 1.0f);
Floor_t floor = {
.r = 1.0f,
.g = 0.0f,
.b = 0.0f
};
while(1) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
draw_floor(&floor);
glutSwapBuffers();
}
/* Bye... */
return 0;
}
Code: Select all
// libGL
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
#include "raycast.h"
void draw_floor(Floor_t *floor) {
glLoadIdentity();
glOrtho(-5.0, 5.0, -5.0, 5.0, 0.0, 1.0);
glColor3f(floor->r, floor->g, floor->b);
glTranslatef(0.0f, 0.0f, 0.5f);
glBegin(GL_QUADS);
glVertex3f(-3.5f, 0.0f, 0.0f);
glVertex3f(3.5f, 0.0f, 0.0f);
glVertex3f(3.5f, -2.0f, 0.0f);
glVertex3f(-3.5f, -2.0f, 0.0f);
glEnd();
}
Code: Select all
#
# Basic KallistiOS skeleton / test program
# Copyright (C)2001-2004 Dan Potter
#
# Put the filename of the output binary here
TARGET = Raycaster.elf
# List all of your C files here, but change the extension to ".o"
# Include "romdisk.o" if you want a rom disk.
OBJS = raycast.o main.o
# If you define this, the Makefile.rules will create a romdisk.o for you
# from the named dir.
KOS_ROMDISK_DIR = romdisk
# The rm-elf step is to remove the target before building, to force the
# re-creation of the rom disk.
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean:
-rm -f $(TARGET) $(OBJS) romdisk.*
rm-elf:
-rm -f $(TARGET) romdisk.*
$(TARGET): $(OBJS) romdisk.o
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) romdisk.o $(OBJEXTRA) -lm -lkosutils -lGL $(KOS_LIBS)
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img
$(KOS_STRIP) $(TARGET)