mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Add compile notes for FreeBSD and Solaris, add detailed notes about portability of codebase
This commit is contained in:
parent
d92093dc9a
commit
c688aa148f
80
misc/portability.md
Normal file
80
misc/portability.md
Normal file
@ -0,0 +1,80 @@
|
||||
Although most of the code is platform-independent, some per-platform functionality is required.
|
||||
|
||||
By default I try to automatically define appropriate backends for your OS in Core.h. Define ```CC_BUILD_MANUAL``` to disable this.
|
||||
|
||||
Listed below are the requirements for implementing each platform-dependent file.
|
||||
You should try to take advantage of existing backends when porting to other platforms.
|
||||
|
||||
### Platform
|
||||
General platform specific functionality.
|
||||
|
||||
- Get exe path, start/exit process, open url in browser
|
||||
- Dynamic library management
|
||||
- Allocate, free, copy, set memory
|
||||
- Current system time, stopwatch time
|
||||
- File I/O, Directory I/O, Socket I/O
|
||||
- Threading, signalable wait, mutex
|
||||
- Drawing/measuring native font
|
||||
- Native font text drawing and measuring
|
||||
- Encrypt/decrypt data, getting command line args
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WIN``` - Use Win32 API (Windows)
|
||||
- ```CC_BUILD_POSIX``` - Use posix API
|
||||
|
||||
posix note: Some functions are not covered. (stopwatch, getting exe path, open url in browser)
|
||||
These must still be implemented for each operating system
|
||||
|
||||
### Window
|
||||
Create a window, show a dialog window, set window contents, keyboard/mouse input
|
||||
|
||||
Also monitor size, clipboard, cursor, raw relative mouse movement (optional)
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WINGUI``` - Use Win32 API (Windows)
|
||||
- ```CC_BUILD_GARBON``` - Use Carbon (OSX)
|
||||
- ```CC_BUILD_X11``` - Use X11/XLib
|
||||
- ```CC_BUILD_SDL``` - Use SDL library
|
||||
|
||||
If using OpenGL, also OpenGL context creation
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WGL``` - Use WGL (Windows OpenGL)
|
||||
- ```CC_BUILD_GARBON``` - Use AGL (Apple OpenGL)
|
||||
- ```CC_BUILD_GLX``` - Use glX (X11/XLib)
|
||||
- ```CC_BUILD_EGL``` - Use EGL (mainly for GLES)
|
||||
- ```CC_BUILD_SDL``` - Use SDL library
|
||||
|
||||
### Logger
|
||||
Dump registers and backtrace, log unhandled errors (e.g. invalid memory read)
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WIN``` - Use Win32 api
|
||||
- ```CC_BUILD_POSIX``` - Use POSIX api
|
||||
|
||||
posix note: Register access is highly dependent on OS and architecture.
|
||||
|
||||
(e.g. Linux uses &r.gregs[REG_EAX] while FreeBSD uses &r.mc_eax)
|
||||
|
||||
### Audio
|
||||
Play multiple audio streams with varying sample rates
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WIN``` - Use WinMM for audio
|
||||
- ```CC_BUILD_POSIX``` - Use OpenAL for audio
|
||||
|
||||
### 3D Graphics
|
||||
Texturing, depth buffer, alpha, etc (See Graphics.h for full list)
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_D3D9``` - Use Direct3D9 for 3D graphics
|
||||
- ```CC_BUILD_GL``` - Use OpenGL for 3D graphics (1.5/1.2 + ARB_VERTEX_BUFFER_OBJECT)
|
||||
- ```CC_BUILD_GL11``` - Use OpenGL 1.1 features only
|
||||
- ```CC_BUILD_GLMODERN``` - Use OpenGL/OpenGLES 2.0 shaders
|
||||
|
||||
### Http
|
||||
HTTP, HTTPS, and cookies (ETag and Last-Modified recommended)
|
||||
|
||||
Define:
|
||||
- ```CC_BUILD_WIN``` - use WinINet as http backend
|
||||
- ```CC_BUILD_POSIX``` - use libcurl as http backend
|
@ -1,17 +1,3 @@
|
||||
### Platform
|
||||
Although the majority of the code is designed to be platform-independent, some per-platform functionality is required.
|
||||
|
||||
Some of the per-platform functionality you'll be required to implement is:
|
||||
- 3D graphics API (shader support is not required)
|
||||
- File I/O, Directory I/O, Socket I/O
|
||||
- Error handling (including unhandled errors/exceptions)
|
||||
- Application window, keyboard state, mouse state
|
||||
- Text drawing, fonts
|
||||
- Threading, signalable wait, mutex
|
||||
- Stopwatch timer, current system time
|
||||
- Http and https, getting command line args
|
||||
- Memory allocation, copying, setting
|
||||
|
||||
### Types
|
||||
* Integers generally use plain ```int```, floating point numbers use ```float``` or ```double```.
|
||||
* Explicit integer types are also provided in ```Core.h```.
|
31
readme.md
31
readme.md
@ -1,4 +1,4 @@
|
||||
ClassiCube is a custom Minecraft Classic and ClassiCube client written in C that works on Windows, Linux and OSX.
|
||||
ClassiCube is a custom Minecraft Classic and ClassiCube client written in C that works on Windows, OSX, Linux, BSD, and Solaris.
|
||||
**It is not affiliated with (or supported by) Mojang AB, Minecraft, or Microsoft in any way.**
|
||||
|
||||

|
||||
@ -66,24 +66,19 @@ I am assuming you used the installer from http://www.mingw.org/
|
||||
2. Run *msys.bat* in the *C:\MinGW\msys\1.0* folder.
|
||||
3. Compile with the same flags as **MinGW-w64**, but also add ```-DUNICODE```
|
||||
|
||||
|
||||
#### Linux
|
||||
|
||||
Install appropriate libs as required. For ubuntu this means: libx11-dev, libgl1-mesa-dev, libopenal-dev, libcurl4-gnutls-dev or libcurl4-openssl-dev
|
||||
Install appropriate libs as required. For ubuntu these are: libx11-dev, libgl1-mesa-dev, libopenal-dev, libcurl4-gnutls-dev or libcurl4-openssl-dev
|
||||
|
||||
Compiling for linux:
|
||||
```gcc *.c -o ClassiCube -lm -lpthread -lX11 -lGL -lcurl -lopenal -ldl```
|
||||
|
||||
```gcc *.c -o ClassiCube -lX11 -lpthread -lGL -lm -lcurl -lopenal -ldl```
|
||||
|
||||
Cross compiling for windows:
|
||||
##### Cross compiling for windows:
|
||||
|
||||
```i586-mingw32msvc-gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9```
|
||||
|
||||
Explicitly:
|
||||
#### FreeBSD
|
||||
|
||||
```i586-mingw32msvc-gcc *.c -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_WINGUI -DCC_BUILD_D3D9 -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9```
|
||||
|
||||
```i586-mingw32msvc-gcc *.c -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_WINGUI -DCC_BUILD_WGL -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32```
|
||||
```gcc *.c -o ClassiCube -I /usr/local/include -L /usr/Xlocal/lib -lm -lpthread -lX11 -lGL -lcurl -lopenal -lexecinfo```
|
||||
|
||||
#### OpenBSD
|
||||
|
||||
@ -93,10 +88,20 @@ Install libexecinfo package if needed.
|
||||
|
||||
#### NetBSD
|
||||
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lX11 -lGL -lcurl -lopenal -lpthread -lexecinfo```
|
||||
```gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lGL -lcurl -lopenal -lexecinfo```
|
||||
|
||||
#### Solaris
|
||||
|
||||
```gcc *.c -o ClassiCube -lm -lsocket -lX11 -lGL -lcurl -lopenal```
|
||||
|
||||
NOTE: You have to change entry->d_type == DT_DIR to Directory_Exists(&path) (TODO do this automatically)
|
||||
|
||||
#### Other
|
||||
|
||||
You'll have to write the necessary code. You should read portability.md in misc folder.
|
||||
|
||||
### Documentation
|
||||
|
||||
Functions and variables in .h files are mostly documented.
|
||||
|
||||
General information (e.g. portablity) for the game's source code can be found in the misc folder.
|
||||
Further information (e.g. portablity, style) for the game's source code can be found in the misc folder.
|
||||
|
20
src/Menus.c
20
src/Menus.c
@ -120,8 +120,8 @@ struct MenuOptionsScreen {
|
||||
char ExtHelp_Buffer[MENUOPTIONS_MAX_DESC * TEXTGROUPWIDGET_LEN];
|
||||
};
|
||||
|
||||
/* Data for a menu option button */
|
||||
struct MenuOptionData {
|
||||
/* Describes a menu option button */
|
||||
struct MenuOptionDesc {
|
||||
short Dir, Y;
|
||||
const char* Name;
|
||||
Widget_LeftClick OnClick;
|
||||
@ -2044,7 +2044,7 @@ static bool MenuOptionsScreen_MouseMove(void* screen, int x, int y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void MenuOptionsScreen_MakeButtons(struct MenuOptionsScreen* s, const struct MenuOptionData* btns, int count) {
|
||||
static void MenuOptionsScreen_MakeButtons(struct MenuOptionsScreen* s, const struct MenuOptionDesc* btns, int count) {
|
||||
String title; char titleBuffer[STRING_SIZE];
|
||||
struct ButtonWidget* btn;
|
||||
int i;
|
||||
@ -2234,7 +2234,7 @@ static void ClassicOptionsScreen_ContextRecreated(void* screen) {
|
||||
const static String title = String_FromConst("Controls...");
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
|
||||
const static struct MenuOptionData buttons[9] = {
|
||||
const static struct MenuOptionDesc buttons[9] = {
|
||||
{ -1, -150, "Music", MenuOptionsScreen_Bool,
|
||||
ClassicOptionsScreen_GetMusic, ClassicOptionsScreen_SetMusic },
|
||||
{ -1, -100, "Invert mouse", MenuOptionsScreen_Bool,
|
||||
@ -2319,7 +2319,7 @@ static void EnvSettingsScreen_ContextRecreated(void* screen) {
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct Widget** widgets = s->Widgets;
|
||||
|
||||
const static struct MenuOptionData buttons[10] = {
|
||||
const static struct MenuOptionDesc buttons[10] = {
|
||||
{ -1, -150, "Clouds col", MenuOptionsScreen_Input,
|
||||
EnvSettingsScreen_GetCloudsCol, EnvSettingsScreen_SetCloudsCol },
|
||||
{ -1, -100, "Sky col", MenuOptionsScreen_Input,
|
||||
@ -2434,7 +2434,7 @@ static void GraphicsOptionsScreen_ContextRecreated(void* screen) {
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct Widget** widgets = s->Widgets;
|
||||
|
||||
const static struct MenuOptionData buttons[6] = {
|
||||
const static struct MenuOptionDesc buttons[6] = {
|
||||
{ -1, -50, "FPS mode", MenuOptionsScreen_Enum,
|
||||
MenuOptionsScreen_GetFPS, MenuOptionsScreen_SetFPS },
|
||||
{ -1, 0, "View distance", MenuOptionsScreen_Input,
|
||||
@ -2541,7 +2541,7 @@ static void GuiOptionsScreen_ContextRecreated(void* screen) {
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct Widget** widgets = s->Widgets;
|
||||
|
||||
const static struct MenuOptionData buttons[10] = {
|
||||
const static struct MenuOptionDesc buttons[10] = {
|
||||
{ -1, -150, "Black text shadows", MenuOptionsScreen_Bool,
|
||||
GuiOptionsScreen_GetShadows, GuiOptionsScreen_SetShadows },
|
||||
{ -1, -100, "Show FPS", MenuOptionsScreen_Bool,
|
||||
@ -2691,7 +2691,7 @@ static void HacksSettingsScreen_ContextRecreated(void* screen) {
|
||||
struct Widget** widgets = s->Widgets;
|
||||
Event_RegisterVoid(&UserEvents.HackPermissionsChanged, s, HacksSettingsScreen_CheckHacksAllowed);
|
||||
|
||||
const static struct MenuOptionData buttons[10] = {
|
||||
const static struct MenuOptionDesc buttons[10] = {
|
||||
{ -1, -150, "Hacks enabled", MenuOptionsScreen_Bool,
|
||||
HacksSettingsScreen_GetHacks, HacksSettingsScreen_SetHacks },
|
||||
{ -1, -100, "Speed multiplier", MenuOptionsScreen_Input,
|
||||
@ -2793,7 +2793,7 @@ static void MiscOptionsScreen_ContextRecreated(void* screen) {
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
struct Widget** widgets = s->Widgets;
|
||||
|
||||
const static struct MenuOptionData buttons[8] = {
|
||||
const static struct MenuOptionDesc buttons[8] = {
|
||||
{ -1, -100, "Reach distance", MenuOptionsScreen_Input,
|
||||
MiscOptionsScreen_GetReach, MiscOptionsScreen_SetReach },
|
||||
{ -1, -50, "Music volume", MenuOptionsScreen_Input,
|
||||
@ -2881,7 +2881,7 @@ static void NostalgiaScreen_ContextRecreated(void* screen) {
|
||||
struct MenuOptionsScreen* s = screen;
|
||||
static struct TextWidget desc;
|
||||
|
||||
const static struct MenuOptionData buttons[8] = {
|
||||
const static struct MenuOptionDesc buttons[8] = {
|
||||
{ -1, -150, "Classic hand model", MenuOptionsScreen_Bool,
|
||||
NostalgiaScreen_GetHand, NostalgiaScreen_SetHand },
|
||||
{ -1, -100, "Classic walk anim", MenuOptionsScreen_Bool,
|
||||
|
@ -697,7 +697,7 @@ void Mutex_Free(void* handle) { }
|
||||
void Mutex_Lock(void* handle) { }
|
||||
void Mutex_Unlock(void* handle) { }
|
||||
|
||||
void* Waitable_Create(void) { eeturn NULL; }
|
||||
void* Waitable_Create(void) { return NULL; }
|
||||
void Waitable_Free(void* handle) { }
|
||||
void Waitable_Signal(void* handle) { }
|
||||
void Waitable_Wait(void* handle) { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user