Start restructuring and switching to CMake

This commit is contained in:
Luke Benstead 2021-03-28 14:33:56 +01:00
parent 8ee28fdaac
commit ebccaedb93
10 changed files with 144 additions and 44 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
dc-build.sh
.buildconfig
GL/version.h
build/*

30
CMakeLists.txt Normal file
View File

@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.0)
project(GLdc)
set(
SOURCES
GL/clip.c
GL/draw.c
GL/error.c
GL/flush.c
GL/fog.c
GL/framebuffer.c
GL/glu.c
GL/immediate.c
GL/lighting.c
GL/matrix.c
GL/profiler.c
GL/state.c
GL/texture.c
GL/util.c
GL/yalloc/yalloc.c
)
if(PLATFORM_DREAMCAST)
set(SOURCES ${SOURCES} GL/platforms/sh4.c)
else()
set(SOURCES ${SOURCES} GL/platforms/x86.c)
endif()
add_library(GLdc ${SOURCES})

7
GL/platform.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#ifdef __DREAMCAST__
#include "platforms/sh4.h"
#else
#include "platforms/x86.h"
#endif

0
GL/platforms/sh4.c Normal file
View File

9
GL/platforms/sh4.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <dc/matrix.h>
#include <dc/pvr.h>
#include <dc/vec3f.h>
#include <dc/fmath.h>
#include <dc/matrix3d.h>
#include "sh4_math.h"

0
GL/platforms/x86.c Normal file
View File

4
GL/platforms/x86.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
#define MATH_Fast_Divide(n, d) (n / d)
#define MATH_fmac(a, b, c) (a * b + c)

View File

@ -2,16 +2,12 @@
#define PRIVATE_H
#include <stdint.h>
#include <dc/matrix.h>
#include <dc/pvr.h>
#include <dc/vec3f.h>
#include <dc/fmath.h>
#include <dc/matrix3d.h>
#include "platform.h"
#include "../include/gl.h"
#include "../containers/aligned_vector.h"
#include "../containers/named_array.h"
#include "sh4_math.h"
extern void* memcpy4 (void *dest, const void *src, size_t count);
@ -90,9 +86,99 @@ typedef float Matrix4x4[16];
#endif
typedef struct {
pvr_poly_hdr_t hdr;
uint32_t cmd;
uint32_t mode1;
uint32_t mode2;
uint32_t mode3;
uint32_t d1;
uint32_t d2;
uint32_t d3;
uint32_t d4;
} PVRHeader;
typedef struct {
int list_type; /**< \brief Primitive list
\see pvr_lists */
struct {
int alpha; /**< \brief Enable or disable alpha outside modifier
\see pvr_alpha_switch */
int shading; /**< \brief Shading type
\see pvr_shading_types */
int fog_type; /**< \brief Fog type outside modifier
\see pvr_fog_types */
int culling; /**< \brief Culling mode
\see pvr_cull_modes */
int color_clamp; /**< \brief Color clamp enable/disable outside modifier
\see pvr_colclamp_switch */
int clip_mode; /**< \brief Clipping mode
\see pvr_clip_modes */
int modifier_mode; /**< \brief Modifier mode */
int specular; /**< \brief Offset color enable/disable outside modifier
\see pvr_offset_switch */
int alpha2; /**< \brief Enable/disable alpha inside modifier
\see pvr_alpha_switch */
int fog_type2; /**< \brief Fog type inside modifier
\see pvr_fog_types */
int color_clamp2; /**< \brief Color clamp enable/disable inside modifier
\see pvr_colclamp_switch */
} gen; /**< \brief General parameters */
struct {
int src; /**< \brief Source blending mode outside modifier
\see pvr_blend_modes */
int dst; /**< \brief Dest blending mode outside modifier
\see pvr_blend_modes */
int src_enable; /**< \brief Source blending enable outside modifier
\see pvr_blend_switch */
int dst_enable; /**< \brief Dest blending enable outside modifier
\see pvr_blend_switch */
int src2; /**< \brief Source blending mode inside modifier
\see pvr_blend_modes */
int dst2; /**< \brief Dest blending mode inside modifier
\see pvr_blend_modes */
int src_enable2; /**< \brief Source blending mode inside modifier
\see pvr_blend_switch */
int dst_enable2; /**< \brief Dest blending mode inside modifier
\see pvr_blend_switch */
} blend; /**< \brief Blending parameters */
struct {
int color;
int uv;
int modifier;
} fmt;
struct {
int comparison;
int write;
} depth;
struct {
int enable;
int filter;
int mipmap;
int mipmap_bias;
int uv_flip;
int uv_clamp;
int alpha;
int env;
int width;
int height;
int format;
void* base;
} txr;
struct {
int enable;
int filter;
int mipmap;
int mipmap_bias;
int uv_flip;
int uv_clamp;
int alpha;
int env;
int width;
int height;
int format;
void* base;
} txr2;
} PVRState;
typedef struct {
unsigned int flags; /* Constant PVR_CMD_USERCLIP */
unsigned int d1, d2, d3; /* Ignored for this type */

View File

@ -1,37 +0,0 @@
# KallistiOS ##version##
#
# kos-ports/libgl Makefile
# Copyright (C) 2013, 2014 Josh Pearson
# Copyright (C) 2014 Lawrence Sebald
# Copyright (C) 2020 Luke Benstead
TARGET = libGLdc.a
OBJS = GL/draw.o GL/flush.o GL/framebuffer.o GL/immediate.o GL/lighting.o GL/state.o GL/texture.o GL/glu.o GL/version.h
OBJS += GL/matrix.o GL/fog.o GL/error.o GL/clip.o containers/stack.o containers/named_array.o containers/aligned_vector.o GL/profiler.o
OBJS += GL/yalloc/yalloc.o
SUBDIRS =
KOS_CFLAGS += -ffast-math -Ofast -Iinclude
GL/version.h:
rm -f $@
@printf '#pragma once\n#define GLDC_VERSION "$(shell git describe --abbrev=4 --dirty --always --tags)"\n' > $@
link:
$(KOS_AR) rcs $(TARGET) $(OBJS)
build: GL/version.h $(OBJS) link
samples: build
$(KOS_MAKE) -C samples all
defaultall: create_kos_link $(OBJS) subdirs linklib samples
include $(KOS_BASE)/addons/Makefile.prefab
# creates the kos link to the headers
create_kos_link:
rm -f ../include/GL
ln -s ../GLdc/include ../include/GL