Skip to content

Commit 0a94037

Browse files
mardyjtsiomb
authored andcommitted
Add Wii/GameCube backend stub
No real implementation for now, but just enough to build the library.
1 parent 6fed3cd commit 0a94037

16 files changed

+681
-1
lines changed

CMakeLists.txt

+22-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ SET(FREEGLUT_SRCS
122122
src/fg_window.c
123123
)
124124
# TODO: OpenGL ES requires a compatible version of these files:
125-
IF(NOT FREEGLUT_GLES)
125+
IF(NOT FREEGLUT_GLES AND NOT CMAKE_SYSTEM_NAME MATCHES "NintendoWii|NintendoGameCube")
126126
LIST(APPEND FREEGLUT_SRCS
127127
src/fg_font.c
128128
src/fg_menu.c
@@ -197,6 +197,27 @@ ELSEIF(ANDROID OR BLACKBERRY)
197197
)
198198
ENDIF()
199199

200+
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "NintendoWii|NintendoGameCube")
201+
202+
LIST(APPEND FREEGLUT_SRCS
203+
src/ogc/fg_common_ogc.h
204+
src/ogc/fg_cursor_ogc.c
205+
src/ogc/fg_display_ogc.c
206+
src/ogc/fg_ext_ogc.c
207+
src/ogc/fg_gamemode_ogc.c
208+
src/ogc/fg_init_ogc.c
209+
src/ogc/fg_internal_ogc.h
210+
src/ogc/fg_input_devices_ogc.c
211+
src/ogc/fg_joystick_ogc.c
212+
src/ogc/fg_main_ogc.c
213+
src/ogc/fg_state_ogc.c
214+
src/ogc/fg_structure_ogc.c
215+
src/ogc/fg_window_ogc.c
216+
)
217+
SET(FREEGLUT_BUILD_SHARED_LIBS OFF)
218+
# Only used in fg_window.c, to declare support for double buffering
219+
ADD_DEFINITIONS(-DEGL_VERSION_1_0)
220+
200221
ELSE()
201222
# UNIX (Wayland)
202223
IF(FREEGLUT_WAYLAND)

README.ogc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Freeglut on Wii/GameCube
2+
========================
3+
4+
Build instructions
5+
------------------
6+
7+
mkdir build
8+
cd build
9+
cmake -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake" -DFREEGLUT_BUILD_DEMOS=OFF ..

src/fg_internal.h

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
# define TARGET_HOST_POSIX_X11 1
6565
/* # define TARGET_HOST_MAC_OSX 1 */
6666

67+
#elif defined(__wii__) || defined(__gamecube__)
68+
# define TARGET_HOST_OGC 1
69+
6770
#else
6871
# error "Unrecognized target host!"
6972

@@ -103,6 +106,10 @@
103106
# define TARGET_HOST_SOLARIS 0
104107
#endif
105108

109+
#ifndef TARGET_HOST_OGC
110+
# define TARGET_HOST_OGC 0
111+
#endif
112+
106113
/* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */
107114

108115
#define FREEGLUT_MAX_MENUS 3
@@ -210,6 +217,9 @@
210217
#if TARGET_HOST_BLACKBERRY
211218
#include "blackberry/fg_internal_blackberry.h"
212219
#endif
220+
#if TARGET_HOST_OGC
221+
#include "ogc/fg_internal_ogc.h"
222+
#endif
213223

214224

215225
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */

src/ogc/fg_common_ogc.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#ifndef FREEGLUT_COMMON_OGC_H
23+
#define FREEGLUT_COMMON_OGC_H
24+
25+
#include <GL/freeglut.h>
26+
#include "../fg_internal.h"
27+
28+
#endif /* FREEGLUT_COMMON_OGC_H */

src/ogc/fg_cursor_ogc.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
void fgPlatformSetCursor(SFG_Window *window, int cursorID)
25+
{
26+
fgWarning("%s() : not implemented", __func__);
27+
}
28+
29+
void fgPlatformWarpPointer(int x, int y)
30+
{
31+
fgWarning("%s() : not implemented", __func__);
32+
}
33+
34+
void fghPlatformGetCursorPos(const SFG_Window *window, GLboolean client, SFG_XYUse *mouse_pos)
35+
{
36+
fgWarning("%s() : not implemented", __func__);
37+
}

src/ogc/fg_display_ogc.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
void fgPlatformGlutSwapBuffers(SFG_PlatformDisplay *pDisplayPtr,
25+
SFG_Window *CurrentWindow)
26+
{
27+
fgWarning("%s() : not implemented", __func__);
28+
}

src/ogc/fg_ext_ogc.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
SFG_Proc fgPlatformGetProcAddress(const char *procName)
25+
{
26+
fgWarning("%s() : not implemented", __func__);
27+
return NULL;
28+
}
29+
30+
GLUTproc fgPlatformGetGLUTProcAddress(const char *procName)
31+
{
32+
fgWarning("%s() : not implemented", __func__);
33+
return NULL;
34+
}
35+

src/ogc/fg_gamemode_ogc.c

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
void fgPlatformRememberState(void)
25+
{
26+
fgWarning("%s() : not implemented", __func__);
27+
}
28+
29+
void fgPlatformRestoreState(void)
30+
{
31+
fgWarning("%s() : not implemented", __func__);
32+
}
33+
34+
GLvoid fgPlatformGetGameModeVMaxExtent(SFG_Window *window, int *x, int *y)
35+
{
36+
fgWarning("%s() : not implemented", __func__);
37+
}
38+
39+
GLboolean fgPlatformChangeDisplayMode(GLboolean haveToTest)
40+
{
41+
fgWarning("%s() : not implemented", __func__);
42+
return GL_FALSE;
43+
}
44+
45+
46+
void fgPlatformEnterGameMode(void)
47+
{
48+
fgWarning("%s() : not implemented", __func__);
49+
}
50+
51+
void fgPlatformLeaveGameMode(void)
52+
{
53+
fgWarning("%s() : not implemented", __func__);
54+
}

src/ogc/fg_init_ogc.c

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
void fgPlatformInitialize(const char *displayName)
25+
{
26+
fgWarning("%s() : not implemented", __func__);
27+
}
28+
29+
void fgPlatformDeinitialiseInputDevices(void)
30+
{
31+
fgWarning("%s() : not implemented", __func__);
32+
}
33+
34+
void fgPlatformCloseDisplay(void)
35+
{
36+
fgWarning("%s() : not implemented", __func__);
37+
}
38+
39+
void fgPlatformDestroyContext(SFG_PlatformDisplay pDisplay,
40+
SFG_WindowContextType MContext)
41+
{
42+
fgWarning("%s() : not implemented", __func__);
43+
}

src/ogc/fg_input_devices_ogc.c

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2024 Alberto Mardegan <mardy@users.sourceforge.net>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
#include "fg_common_ogc.h"
23+
24+
void fgPlatformInitialiseInputDevices(void)
25+
{
26+
fgWarning("%s() : not implemented", __func__);
27+
}
28+
29+
void fgPlatformCloseInputDevices(void)
30+
{
31+
fgWarning("%s() : not implemented", __func__);
32+
}
33+
34+
void fgPlatformInitializeSpaceball(void)
35+
{
36+
fgWarning("%s() : not implemented", __func__);
37+
}
38+
39+
void fgPlatformSpaceballClose(void)
40+
{
41+
fgWarning("%s() : not implemented", __func__);
42+
}
43+
44+
void fgPlatformSpaceballSetWindow(SFG_Window *window)
45+
{
46+
fgWarning("%s() : not implemented", __func__);
47+
}
48+
49+
int fgPlatformHasSpaceball(void)
50+
{
51+
fgWarning("%s() : not implemented", __func__);
52+
return 0;
53+
}
54+
55+
int fgPlatformSpaceballNumButtons(void)
56+
{
57+
fgWarning("%s() : not implemented", __func__);
58+
return 0;
59+
}
60+
61+
typedef struct _serialport SERIALPORT;
62+
63+
void fgPlatformRegisterDialDevice ( const char *dial_device ) {
64+
fgWarning("GLUT_HAS_DIAL_AND_BUTTON_BOX: not implemented");
65+
}
66+
SERIALPORT *fg_serial_open (const char *device) { return NULL; }
67+
void fg_serial_close(SERIALPORT *port) {}
68+
int fg_serial_getchar(SERIALPORT *port) { return EOF; }
69+
int fg_serial_putchar(SERIALPORT *port, unsigned char ch) { return 0; }
70+
void fg_serial_flush(SERIALPORT *port) {}

0 commit comments

Comments
 (0)