Get nehe02 running on PC
This commit is contained in:
parent
f968c3b828
commit
79c3ad74e7
|
@ -1,10 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(GLdc)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
include_directories(include)
|
||||
|
||||
set(
|
||||
SOURCES
|
||||
containers/aligned_vector.c
|
||||
containers/named_array.c
|
||||
containers/stack.c
|
||||
GL/clip.c
|
||||
GL/draw.c
|
||||
GL/error.c
|
||||
|
@ -29,4 +34,9 @@ set(SOURCES ${SOURCES} GL/platforms/x86.c)
|
|||
endif()
|
||||
|
||||
add_library(GLdc ${SOURCES})
|
||||
link_libraries(m)
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_executable(nehe02 samples/nehe02/main.c)
|
||||
target_link_libraries(nehe02 GLdc)
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../include/gl.h"
|
||||
#include "../include/glext.h"
|
||||
|
||||
#include "private.h"
|
||||
#include "profiler.h"
|
||||
#include "platform.h"
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
KOS Open GL State Machine Error Code Implementation.
|
||||
*/
|
||||
|
||||
#include "gl.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
static GLenum last_error = GL_NO_ERROR;
|
||||
static char error_function[64] = { '\0' };
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
#include "../include/glkos.h"
|
||||
#include "../containers/aligned_vector.h"
|
||||
#include "private.h"
|
||||
#include "profiler.h"
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "private.h"
|
||||
#include "../include/glkos.h"
|
||||
#include "../include/glext.h"
|
||||
|
||||
typedef struct {
|
||||
GLuint index;
|
||||
|
|
|
@ -10,11 +10,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../include/gl.h"
|
||||
#include "../include/glext.h"
|
||||
#include "../include/glkos.h"
|
||||
#include "profiler.h"
|
||||
|
||||
#include "private.h"
|
||||
|
||||
static GLboolean IMMEDIATE_MODE_ACTIVE = GL_FALSE;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "private.h"
|
||||
#include "../include/gl.h"
|
||||
|
||||
#include "../containers/stack.h"
|
||||
|
||||
#define DEG2RAD (0.01745329251994329576923690768489)
|
||||
|
@ -49,8 +49,8 @@ void _glInitMatrices() {
|
|||
stack_push(&MATRIX_STACKS[1], IDENTITY);
|
||||
stack_push(&MATRIX_STACKS[2], IDENTITY);
|
||||
|
||||
memcpy4(NORMAL_MATRIX, IDENTITY, sizeof(Matrix4x4));
|
||||
memcpy4(SCREENVIEW_MATRIX, IDENTITY, sizeof(Matrix4x4));
|
||||
FASTCPY4(NORMAL_MATRIX, IDENTITY, sizeof(Matrix4x4));
|
||||
FASTCPY4(SCREENVIEW_MATRIX, IDENTITY, sizeof(Matrix4x4));
|
||||
|
||||
const VideoMode* vid_mode = GetVideoMode();
|
||||
|
||||
|
@ -96,7 +96,7 @@ static void transpose(GLfloat* m) {
|
|||
}
|
||||
|
||||
static void recalculateNormalMatrix() {
|
||||
memcpy4(NORMAL_MATRIX, stack_top(MATRIX_STACKS + (GL_MODELVIEW & 0xF)), sizeof(Matrix4x4));
|
||||
FASTCPY4(NORMAL_MATRIX, stack_top(MATRIX_STACKS + (GL_MODELVIEW & 0xF)), sizeof(Matrix4x4));
|
||||
inverse((GLfloat*) NORMAL_MATRIX);
|
||||
transpose((GLfloat*) NORMAL_MATRIX);
|
||||
}
|
||||
|
|
|
@ -67,11 +67,11 @@ typedef enum GPUTextureFormat {
|
|||
GPU_TXRFMT_STRIDE = (1 << 21)
|
||||
} GPUTextureFormat;
|
||||
|
||||
inline uint32_t GPUPaletteSelect8BPP(uint32_t x) {
|
||||
static inline uint32_t GPUPaletteSelect8BPP(uint32_t x) {
|
||||
return x << 25;
|
||||
}
|
||||
|
||||
inline uint32_t GPUPaletteSelect4BPP(uint32_t x) {
|
||||
static inline uint32_t GPUPaletteSelect4BPP(uint32_t x) {
|
||||
return x << 21;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../platform.h"
|
||||
#include "x86.h"
|
||||
|
||||
static size_t AVAILABLE_VRAM = 16 * 1024 * 1024;
|
||||
static Matrix4x4 MATRIX;
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa) {
|
||||
|
||||
}
|
||||
|
@ -24,3 +30,71 @@ void SceneListFinish() {
|
|||
void SceneFinish() {
|
||||
|
||||
}
|
||||
|
||||
void UploadMatrix4x4(const Matrix4x4* mat) {
|
||||
memcpy(&MATRIX, mat, sizeof(Matrix4x4));
|
||||
}
|
||||
|
||||
void MultiplyMatrix4x4(const Matrix4x4* mat) {
|
||||
(void) mat;
|
||||
}
|
||||
|
||||
void DownloadMatrix4x4(Matrix4x4* mat) {
|
||||
memcpy(mat, &MATRIX, sizeof(Matrix4x4));
|
||||
}
|
||||
|
||||
static VideoMode vid_mode = {
|
||||
640, 480
|
||||
};
|
||||
|
||||
const VideoMode* GetVideoMode() {
|
||||
return &vid_mode;
|
||||
}
|
||||
|
||||
size_t GPUMemoryAvailable() {
|
||||
return AVAILABLE_VRAM;
|
||||
}
|
||||
|
||||
void* GPUMemoryAlloc(size_t size) {
|
||||
if(size > AVAILABLE_VRAM) {
|
||||
return NULL;
|
||||
} else {
|
||||
return malloc(size);
|
||||
}
|
||||
}
|
||||
|
||||
void GPUSetPaletteFormat(GPUPaletteFormat format) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetPaletteEntry(uint32_t idx, uint32_t value) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetBackgroundColour(float r, float g, float b) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetAlphaCutOff(uint8_t v) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetClearDepth(float v) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetFogLinear(float start, float end) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetFogExp(float density) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetFogExp2(float density) {
|
||||
|
||||
}
|
||||
|
||||
void GPUSetFogColor(float r, float g, float b, float a) {
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#define FASTCPY(dst, src, bytes) memcpy(dst, src, bytes)
|
||||
#define FASTCPY4(dst, src, bytes) memcpy(dst, src, bytes)
|
||||
#define MEMSET4(dst, v, size) memset((dst), (v), (size))
|
||||
|
||||
#define VEC3_NORMALIZE(x, y, z) \
|
||||
do { \
|
||||
float l = MATH_fsrra((x) * (x) + (y) * (y) + (z) * (z)); \
|
||||
|
@ -31,55 +32,46 @@
|
|||
struct PolyHeader;
|
||||
struct PolyContext;
|
||||
|
||||
inline void CompilePolyHeader(PolyHeader* out, const PolyContext* in) {
|
||||
static inline void CompilePolyHeader(PolyHeader* out, const PolyContext* in) {
|
||||
(void) out;
|
||||
(void) in;
|
||||
}
|
||||
|
||||
inline void UploadMatrix4x4(const Matrix4x4* mat) {
|
||||
(void) mat;
|
||||
}
|
||||
|
||||
inline void MultiplyMatrix4x4(const Matrix4x4* mat) {
|
||||
(void) mat;
|
||||
}
|
||||
|
||||
inline void DownloadMatrix4x4(Matrix4x4* mat) {
|
||||
(void) mat;
|
||||
}
|
||||
void UploadMatrix4x4(const Matrix4x4* mat);
|
||||
void MultiplyMatrix4x4(const Matrix4x4* mat);
|
||||
void DownloadMatrix4x4(Matrix4x4* mat);
|
||||
|
||||
/* Transform a 3-element vector in-place using the stored matrix (w == 1) */
|
||||
inline void TransformVec3(float* x) {
|
||||
static inline void TransformVec3(float* x) {
|
||||
|
||||
}
|
||||
|
||||
/* Transform a 3-element vector using the stored matrix (w == 1) */
|
||||
inline void TransformVec3NoMod(const float* xIn, float* xOut) {
|
||||
static inline void TransformVec3NoMod(const float* xIn, float* xOut) {
|
||||
|
||||
}
|
||||
|
||||
/* Transform a 3-element normal using the stored matrix (w == 0)*/
|
||||
inline void TransformNormalNoMod(const float* xIn, float* xOut) {
|
||||
static inline void TransformNormalNoMod(const float* xIn, float* xOut) {
|
||||
|
||||
}
|
||||
|
||||
/* Transform a 4-element vector in-place by the stored matrix */
|
||||
inline void TransformVec4(float* x) {
|
||||
static inline void TransformVec4(float* x) {
|
||||
|
||||
}
|
||||
|
||||
inline void TransformVertices(const Vertex* vertices, const int count) {
|
||||
static inline void TransformVertices(const Vertex* vertices, const int count) {
|
||||
(void) vertices;
|
||||
(void) count;
|
||||
}
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa);
|
||||
|
||||
size_t GPUMemoryAvailable();
|
||||
void* GPUMemoryAlloc(size_t size);
|
||||
|
||||
enum GPUPaletteFormat;
|
||||
|
||||
size_t GPUMemoryAvailable();
|
||||
void* GPUMemoryAlloc(size_t size);
|
||||
void GPUSetPaletteFormat(GPUPaletteFormat format);
|
||||
void GPUSetPaletteEntry(uint32_t idx, uint32_t value);
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
#include "platform.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "../include/gl.h"
|
||||
#include "../include/GL/gl.h"
|
||||
#include "../include/GL/glext.h"
|
||||
#include "../include/GL/glkos.h"
|
||||
|
||||
#include "../containers/aligned_vector.h"
|
||||
#include "../containers/named_array.h"
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../include/gl.h"
|
||||
#include "../include/glext.h"
|
||||
#include "../include/glkos.h"
|
||||
|
||||
#include "private.h"
|
||||
|
||||
static PolyContext GL_CONTEXT;
|
||||
|
@ -641,10 +637,10 @@ void APIENTRY glGetBooleanv(GLenum pname, GLboolean* params) {
|
|||
void APIENTRY glGetFloatv(GLenum pname, GLfloat* params) {
|
||||
switch(pname) {
|
||||
case GL_PROJECTION_MATRIX:
|
||||
memcpy4(params, _glGetProjectionMatrix(), sizeof(float) * 16);
|
||||
FASTCPY4(params, _glGetProjectionMatrix(), sizeof(float) * 16);
|
||||
break;
|
||||
case GL_MODELVIEW_MATRIX:
|
||||
memcpy4(params, _glGetModelViewMatrix(), sizeof(float) * 16);
|
||||
FASTCPY4(params, _glGetModelViewMatrix(), sizeof(float) * 16);
|
||||
break;
|
||||
case GL_POLYGON_OFFSET_FACTOR:
|
||||
*params = OFFSET_FACTOR;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "platform.h"
|
||||
#include "../include/glext.h"
|
||||
#include "../include/glkos.h"
|
||||
|
||||
#include "yalloc/yalloc.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "../include/glkos.h"
|
||||
#include "private.h"
|
||||
|
||||
void APIENTRY glVertexPackColor3fKOS(GLVertexKOS* vertex, float r, float g, float b) {
|
||||
vertex->bgra[3] = 255;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "gl.h"
|
||||
#include "glu.h"
|
||||
#include "glkos.h"
|
||||
#include "GL/gl.h"
|
||||
#include "GL/glu.h"
|
||||
#include "GL/glkos.h"
|
||||
|
||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
|
||||
|
|
Loading…
Reference in New Issue
Block a user