add some files

This commit is contained in:
NishiOwO 2025-03-29 13:55:47 +09:00
parent e8babc59a1
commit fb08464f0b
No known key found for this signature in database
GPG Key ID: 27EF69B208EB9343
9 changed files with 101 additions and 18 deletions

View File

@ -1,3 +1,8 @@
# NishBox
multiplayer sandbox game i might work on
## Stack
- OpenGL 1.1 (probably) on WGL/GLX
- Open Dynamics Engine
- PawnScript

View File

@ -1,24 +1,29 @@
/* Interface */
#include "nb_core.h"
/* NishBox */
#include "nb_draw.h"
/* External library */
#include <ode/ode.h>
/* Standard */
#include <stdlib.h>
void nb_engine_begin(void){
dInitODE();
}
void nb_engine_begin(void) { dInitODE(); }
void nb_engine_end(void){
dCloseODE();
}
void nb_engine_end(void) { dCloseODE(); }
nb_engine_t* nb_engine_create(void){
nb_engine_t* nb_engine_create(void) {
nb_engine_t* engine = malloc(sizeof(*engine));
engine->draw = nb_draw_create();
if(engine->draw == NULL) {
free(engine);
return NULL;
}
engine->world = dWorldCreate();
dWorldSetGravity(engine->world, 0, 0, -9.81);
return engine;
}
void nb_engine_destroy(nb_engine_t* engine){
dWorldDestroy(engine->world);
}
void nb_engine_destroy(nb_engine_t* engine) { dWorldDestroy(engine->world); }

View File

@ -1 +1,24 @@
/* Interface */
#include "nb_draw.h"
/* NishBox */
/* External library */
#include <GL/gl.h>
#if defined(USE_GLX)
#include <X11/Xlib.h>
#include <GL/glx.h>
#elif defined(USE_WGL)
#include <windows.h>
#endif
/* Standard */
#include <stdlib.h>
nb_draw_t* nb_draw_create(void) {
nb_draw_t* draw = malloc(sizeof(*draw));
#if defined(USE_GLX)
#elif defined(USE_WGL)
#endif
return draw;
}

View File

@ -1,18 +1,23 @@
#ifndef __NB_CORE_H__
#define __NB_CORE_H__
#include <nb_draw.h>
/* Interface */
/* NishBox */
/* External library */
#include <ode/ode.h>
/* Standard */
typedef struct nb_engine {
dWorldID world;
nb_draw_t* draw;
void* draw; /* User should not touch this directly: internally pointer of nb_draw_t */
} nb_engine_t;
void nb_engine_begin(void);
void nb_engine_end(void);
void nb_engine_begin(void);
void nb_engine_end(void);
nb_engine_t* nb_engine_create(void);
void nb_engine_destroy(nb_engine_t* engine);
void nb_engine_destroy(nb_engine_t* engine);
#endif

View File

@ -1,21 +1,34 @@
#ifndef __NB_DRAW_H__
#define __NB_DRAW_H__
/* Interface */
/* NishBox */
/* External library */
#include <GL/gl.h>
#if defined(USE_GLX)
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <GL/glxext.h>
#elif defined(USE_WGL)
#include <windows.h>
#endif
/* Standard */
typedef struct nb_draw {
#if defined(USE_GLX)
Display* display;
Window window;
Display* display;
Window window;
GLXContext context;
#elif defined(USE_WGL)
HINSTANCE instance;
HWND window;
HDC dc;
HGLRC glrc;
#endif
} nb_draw_t;
nb_draw_t* nb_draw_create(void);
#endif

View File

@ -1,6 +1,14 @@
#ifndef __NB_VERSION_H__
#define __NB_VERSION_H__
/* Interface */
/* NishBox */
/* External library */
/* Standard */
typedef struct nb_version {
int major;
int minor;

View File

@ -1,5 +1,11 @@
/* Interface */
#include "nb_version.h"
/* NishBox */
/* External library */
/* Standard */
#include <string.h>
#include <stdlib.h>

7
include_order.c Normal file
View File

@ -0,0 +1,7 @@
/* Interface */
/* NishBox */
/* External library */
/* Standard */

View File

@ -1,6 +1,12 @@
/* Interface */
/* NishBox */
#include <nb_version.h>
#include <nb_core.h>
/* External library */
/* Standard */
#include <stdio.h>
nb_engine_t* engine;
@ -12,6 +18,11 @@ int main(int argc, char** argv) {
nb_engine_begin();
engine = nb_engine_create();
if(engine == NULL) {
fprintf(stderr, "Engine creation failure\n");
nb_engine_end();
return 1;
}
nb_engine_destroy(engine);
nb_engine_end();