Fix compiler warnings

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1256 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
beuc 2012-04-21 17:40:25 +00:00
parent e2f3f6181e
commit c0fceb37bb
27 changed files with 250 additions and 103 deletions

4
.gitattributes vendored
View File

@ -68,6 +68,7 @@ freeglut/freeglut/src/android/fg_input_devices_android.c -text
freeglut/freeglut/src/android/fg_internal_android.h -text freeglut/freeglut/src/android/fg_internal_android.h -text
freeglut/freeglut/src/android/fg_joystick_android.c -text freeglut/freeglut/src/android/fg_joystick_android.c -text
freeglut/freeglut/src/android/fg_main_android.c -text freeglut/freeglut/src/android/fg_main_android.c -text
freeglut/freeglut/src/android/fg_main_android.h -text
freeglut/freeglut/src/android/fg_runtime_android.c -text freeglut/freeglut/src/android/fg_runtime_android.c -text
freeglut/freeglut/src/android/fg_spaceball_android.c -text freeglut/freeglut/src/android/fg_spaceball_android.c -text
freeglut/freeglut/src/android/fg_state_android.c -text freeglut/freeglut/src/android/fg_state_android.c -text
@ -79,8 +80,10 @@ freeglut/freeglut/src/android/native_app_glue/android_native_app_glue.h -text
freeglut/freeglut/src/egl/fg_display_egl.c -text freeglut/freeglut/src/egl/fg_display_egl.c -text
freeglut/freeglut/src/egl/fg_ext_egl.c -text freeglut/freeglut/src/egl/fg_ext_egl.c -text
freeglut/freeglut/src/egl/fg_init_egl.c -text freeglut/freeglut/src/egl/fg_init_egl.c -text
freeglut/freeglut/src/egl/fg_init_egl.h -text
freeglut/freeglut/src/egl/fg_internal_egl.h -text freeglut/freeglut/src/egl/fg_internal_egl.h -text
freeglut/freeglut/src/egl/fg_state_egl.c -text freeglut/freeglut/src/egl/fg_state_egl.c -text
freeglut/freeglut/src/egl/fg_state_egl.h -text
freeglut/freeglut/src/egl/fg_structure_egl.c -text freeglut/freeglut/src/egl/fg_structure_egl.c -text
freeglut/freeglut/src/egl/fg_structure_egl.h -text freeglut/freeglut/src/egl/fg_structure_egl.h -text
freeglut/freeglut/src/egl/fg_window_egl.c -text freeglut/freeglut/src/egl/fg_window_egl.c -text
@ -100,6 +103,7 @@ freeglut/freeglut/src/fg_input_devices.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_internal.h svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_internal.h svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_joystick.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_joystick.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_main.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_main.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_main.h -text
freeglut/freeglut/src/fg_menu.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_menu.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_misc.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_misc.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/fg_overlay.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/fg_overlay.c svn_keywords=Author+Date+Id+Revision

View File

@ -50,6 +50,7 @@ SET(FREEGLUT_SRCS
src/fg_input_devices.c src/fg_input_devices.c
src/fg_joystick.c src/fg_joystick.c
src/fg_main.c src/fg_main.c
src/fg_main.h
src/fg_misc.c src/fg_misc.c
src/fg_overlay.c src/fg_overlay.c
src/fg_spaceball.c src/fg_spaceball.c
@ -103,15 +104,6 @@ IF(WIN32)
ELSEIF(ANDROID) ELSEIF(ANDROID)
LIST(APPEND FREEGLUT_SRCS LIST(APPEND FREEGLUT_SRCS
src/egl/fg_internal_egl.h
src/egl/fg_display_egl.c
src/egl/fg_ext_egl.c
src/egl/fg_init_egl.c
src/egl/fg_state_egl.c
src/egl/fg_structure_egl.c
src/egl/fg_structure_egl.h
src/egl/fg_window_egl.c
src/egl/fg_window_egl.h
src/android/native_app_glue/android_native_app_glue.c src/android/native_app_glue/android_native_app_glue.c
src/android/native_app_glue/android_native_app_glue.h src/android/native_app_glue/android_native_app_glue.h
src/android/fg_internal_android.h src/android/fg_internal_android.h
@ -122,6 +114,7 @@ ELSEIF(ANDROID)
src/android/fg_input_devices_android.c src/android/fg_input_devices_android.c
src/android/fg_joystick_android.c src/android/fg_joystick_android.c
src/android/fg_main_android.c src/android/fg_main_android.c
src/android/fg_main_android.h
src/android/fg_runtime_android.c src/android/fg_runtime_android.c
src/android/fg_spaceball_android.c src/android/fg_spaceball_android.c
src/android/fg_state_android.c src/android/fg_state_android.c
@ -146,17 +139,7 @@ ELSE()
src/x11/fg_window_x11.c src/x11/fg_window_x11.c
src/x11/fg_xinput_x11.c src/x11/fg_xinput_x11.c
) )
IF(FREEGLUT_GLES2 OR FREEGLUT_GLES1) IF(!(FREEGLUT_GLES2 OR FREEGLUT_GLES1))
LIST(APPEND FREEGLUT_SRCS
src/egl/fg_internal_egl.h
src/egl/fg_display_egl.c
src/egl/fg_ext_egl.c
src/egl/fg_init_egl.c
src/egl/fg_state_egl.c
src/egl/fg_structure_egl.c
src/egl/fg_window_egl.c
)
ELSE()
LIST(APPEND FREEGLUT_SRCS LIST(APPEND FREEGLUT_SRCS
src/x11/fg_internal_x11_glx.h src/x11/fg_internal_x11_glx.h
src/x11/fg_display_x11_glx.c src/x11/fg_display_x11_glx.c
@ -166,6 +149,21 @@ ELSE()
) )
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(FREEGLUT_GLES2 OR FREEGLUT_GLES1)
LIST(APPEND FREEGLUT_SRCS
src/egl/fg_internal_egl.h
src/egl/fg_display_egl.c
src/egl/fg_ext_egl.c
src/egl/fg_init_egl.c
src/egl/fg_init_egl.h
src/egl/fg_state_egl.c
src/egl/fg_state_egl.h
src/egl/fg_structure_egl.c
src/egl/fg_structure_egl.h
src/egl/fg_window_egl.c
src/egl/fg_window_egl.h
)
ENDIF()
# For OpenGL ES (GLES): # For OpenGL ES (GLES):
# - compile with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2 to cleanly # - compile with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2 to cleanly

View File

@ -1,6 +1,14 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(test-shapes-gles1) project(test-shapes-gles1)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
IF(!ANDROID)
# not setting -ansi as EGL/KHR headers doesn't support it
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi")
ENDIF()
ENDIF(CMAKE_COMPILER_IS_GNUCC)
# FreeGLUT # FreeGLUT
include(FindPkgConfig) include(FindPkgConfig)
pkg_check_modules(freeglut REQUIRED freeglut-gles1>=3.0.0) pkg_check_modules(freeglut REQUIRED freeglut-gles1>=3.0.0)

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_gamemode_x11.c * fg_gamemode_x11.c
* *
* The game mode handling code. * The game mode handling code.
* *

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_init_android.c * fg_init_android.c
* *
* Various freeglut initialization functions. * Various freeglut initialization functions.
* *
@ -25,6 +25,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "egl/fg_init_egl.h"
void fgPlatformInitialize() void fgPlatformInitialize()
{ {

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_input_devices_android.c * fg_input_devices_android.c
* *
* Handles miscellaneous input devices via direct serial-port access. * Handles miscellaneous input devices via direct serial-port access.
* *

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_internal_android.h * fg_internal_android.h
* *
* The freeglut library private include file. * The freeglut library private include file.
* *
@ -104,6 +104,7 @@ struct tagSFG_PlatformJoystick
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState struct tagSFG_PlatformWindowState
{ {
int unused;
}; };
#endif /* FREEGLUT_INTERNAL_ANDROID_H */ #endif /* FREEGLUT_INTERNAL_ANDROID_H */

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_joystick_android.c * fg_joystick_android.c
* *
* Joystick handling code * Joystick handling code
* *

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_main_android.c * fg_main_android.c
* *
* The Android-specific windows message processing methods. * The Android-specific windows message processing methods.
* *
@ -28,6 +28,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "fg_main.h"
#include <android/log.h> #include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "FreeGLUT", __VA_ARGS__)) #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "FreeGLUT", __VA_ARGS__))
@ -217,13 +218,13 @@ int32_t handle_input(struct android_app* app, AInputEvent* event) {
LOGI("motion %.01f,%.01f action=%d", x, y, AMotionEvent_getAction(event)); LOGI("motion %.01f,%.01f action=%d", x, y, AMotionEvent_getAction(event));
/* Virtual arrows PAD */ /* Virtual arrows PAD */
// Don't interfere with existing mouse move event /* Don't interfere with existing mouse move event */
if (!touchscreen.in_mmotion) { if (!touchscreen.in_mmotion) {
struct vpad_state prev_vpad = touchscreen.vpad; struct vpad_state prev_vpad = touchscreen.vpad;
touchscreen.vpad.left = touchscreen.vpad.right touchscreen.vpad.left = touchscreen.vpad.right
= touchscreen.vpad.up = touchscreen.vpad.down = false; = touchscreen.vpad.up = touchscreen.vpad.down = false;
int32_t width = ANativeWindow_getWidth(window->Window.Handle); /* int32_t width = ANativeWindow_getWidth(window->Window.Handle); */
int32_t height = ANativeWindow_getHeight(window->Window.Handle); int32_t height = ANativeWindow_getHeight(window->Window.Handle);
if (action == AMOTION_EVENT_ACTION_DOWN || action == AMOTION_EVENT_ACTION_MOVE) { if (action == AMOTION_EVENT_ACTION_DOWN || action == AMOTION_EVENT_ACTION_MOVE) {
if ((x > 0 && x < 100) && (y > (height - 100) && y < height)) if ((x > 0 && x < 100) && (y > (height - 100) && y < height))
@ -273,7 +274,7 @@ int32_t handle_input(struct android_app* app, AInputEvent* event) {
if (!touchscreen.vpad.on) { if (!touchscreen.vpad.on) {
window->State.MouseX = x; window->State.MouseX = x;
window->State.MouseY = y; window->State.MouseY = y;
LOGI("Changed mouse position: %d,%d", x, y); LOGI("Changed mouse position: %f,%f", x, y);
if (action == AMOTION_EVENT_ACTION_DOWN && FETCH_WCB(*window, Mouse)) { if (action == AMOTION_EVENT_ACTION_DOWN && FETCH_WCB(*window, Mouse)) {
touchscreen.in_mmotion = true; touchscreen.in_mmotion = true;
INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, GLUT_DOWN, x, y)); INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, GLUT_DOWN, x, y));

View File

@ -0,0 +1,37 @@
/*
* fg_main_android.h
*
* The Android-specific windows message processing methods.
*
* Copyright (C) 2012 Sylvain Beucler
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __FG_MAIN_ANDROID_H__
#define __FG_MAIN_ANDROID_H__
extern void fgPlatformProcessSingleEvent(void);
extern void fgPlatformReshapeWindow(SFG_Window *window, int width, int height);
extern void fgPlatformDisplayWindow(SFG_Window *window);
extern unsigned long fgPlatformSystemTime(void);
extern void fgPlatformSleepForEvents(long msec);
extern void fgPlatformMainLoopPreliminaryWork(void);
extern void fgPlatformDeinitialiseInputDevices(void);
#endif

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_runtime_android.c * fg_runtime_android.c
* *
* Android runtime * Android runtime
* *
@ -78,7 +78,6 @@ static void onNativeWindowResized(ANativeActivity* activity, ANativeWindow* wind
static void onNativeWindowRedrawNeeded(ANativeActivity* activity, ANativeWindow* window) { static void onNativeWindowRedrawNeeded(ANativeActivity* activity, ANativeWindow* window) {
LOGI("onNativeWindowRedrawNeeded: %p\n", (void*)activity); LOGI("onNativeWindowRedrawNeeded: %p\n", (void*)activity);
struct android_app* app = (struct android_app*)activity->instance; struct android_app* app = (struct android_app*)activity->instance;
//if (fgDisplay.pDisplay.single_window->Window.pContext.eglSurface != EGL_NO_SURFACE)
android_app_write_cmd(app, APP_CMD_WINDOW_RESIZED); android_app_write_cmd(app, APP_CMD_WINDOW_RESIZED);
} }
@ -138,7 +137,7 @@ static void extract_assets(struct android_app* app) {
void android_main(struct android_app* app) { void android_main(struct android_app* app) {
LOGI("android_main"); LOGI("android_main");
// Register window resize callback /* Register window resize callback */
app->activity->callbacks->onNativeWindowResized = onNativeWindowResized; app->activity->callbacks->onNativeWindowResized = onNativeWindowResized;
app->activity->callbacks->onContentRectChanged = onContentRectChanged; app->activity->callbacks->onContentRectChanged = onContentRectChanged;
app->activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeeded; app->activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeeded;

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_spaceball_android.c * fg_spaceball_android.c
* *
* Spaceball support for Windows * Spaceball support for Windows
* *

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_state_android.c * fg_state_android.c
* *
* Android-specific freeglut state query methods. * Android-specific freeglut state query methods.
* *
@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <android/native_window.h> #include <android/native_window.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "egl/fg_state_egl.h"
int fgPlatformGlutDeviceGet ( GLenum eWhat ) int fgPlatformGlutDeviceGet ( GLenum eWhat )
{ {

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_window_android.c * fg_window_android.c
* *
* Window management methods for Android * Window management methods for Android
* *
@ -30,6 +30,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "egl/fg_window_egl.h" #include "egl/fg_window_egl.h"
#include "android/fg_main_android.h"
/* /*
* Opens a window. Requires a SFG_Window object created and attached * Opens a window. Requires a SFG_Window object created and attached
@ -40,14 +41,11 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
GLboolean sizeUse, int w, int h, GLboolean sizeUse, int w, int h,
GLboolean gameMode, GLboolean isSubWindow ) GLboolean gameMode, GLboolean isSubWindow )
{ {
// printf("fgPlatformOpenWindow %p ID=%d\n", (void*)window, window->ID);
/* TODO: only one full-screen window possible? */ /* TODO: only one full-screen window possible? */
static int nb_windows = 0; static int nb_windows = 0;
if (nb_windows == 0) { if (nb_windows == 0) {
nb_windows++; nb_windows++;
fgDisplay.pDisplay.single_window = window; fgDisplay.pDisplay.single_window = window;
// printf("=> %p ID=%d\n", (void*)fgDisplay.pDisplay.single_window, fgDisplay.pDisplay.single_window->ID);
} else { } else {
return; return;
} }

View File

@ -342,6 +342,8 @@ void app_dummy();
*/ */
extern void android_main(struct android_app* app); extern void android_main(struct android_app* app);
/* static */void android_app_write_cmd(struct android_app* android_app, int8_t cmd);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -28,5 +28,5 @@
SFG_Proc fgPlatformGetProcAddress( const char *procName ) SFG_Proc fgPlatformGetProcAddress( const char *procName )
{ {
return (SFG_Proc)eglGetProcAddress( ( const GLubyte * )procName ); return (SFG_Proc)eglGetProcAddress(procName);
} }

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_init_egl.c * fg_init_egl.c
* *
* Various freeglut initialization functions. * Various freeglut initialization functions.
* *
@ -48,10 +48,10 @@ void fghPlatformInitializeEGL()
eglBindAPI(EGL_OPENGL_ES_API); eglBindAPI(EGL_OPENGL_ES_API);
# endif # endif
// fgDisplay.ScreenWidth = ...; /* fgDisplay.ScreenWidth = ...; */
// fgDisplay.ScreenHeight = ...; /* fgDisplay.ScreenHeight = ...; */
// fgDisplay.ScreenWidthMM = ...; /* fgDisplay.ScreenWidthMM = ...; */
// fgDisplay.ScreenHeightMM = ...; /* fgDisplay.ScreenHeightMM = ...; */
} }
void fghPlatformCloseDisplayEGL() void fghPlatformCloseDisplayEGL()

View File

@ -0,0 +1,33 @@
/*
* fg_init_egl.h
*
* Various freeglut initialization functions.
*
* Copyright (C) 2012 Sylvain Beucler
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __FG_INIT_EGL_H__
#define __FG_INIT_EGL_H__
extern void fghPlatformInitializeEGL();
extern void fghPlatformCloseDisplayEGL();
extern void fgPlatformDestroyContext();
#endif

View File

@ -25,6 +25,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "egl/fg_window_egl.h"
/* /*
* Queries the GL context about some attributes * Queries the GL context about some attributes
@ -122,7 +123,6 @@ int* fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
attribute_name = EGL_SAMPLES; attribute_name = EGL_SAMPLES;
EGLConfig* configArray; EGLConfig* configArray;
EGLConfig* config;
EGLint configArraySize = 0; EGLint configArraySize = 0;
/* Get number of available configs */ /* Get number of available configs */
@ -139,21 +139,19 @@ int* fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
/* We get results in ascending order */ /* We get results in ascending order */
{ {
int * temp_array; int previous_value = 0;
int previous_value;
int i; int i;
array = malloc(sizeof(int) * configArraySize); array = malloc(sizeof(int) * configArraySize);
previous_value = 0;
for (i = 0; i < configArraySize; i++) { for (i = 0; i < configArraySize; i++) {
int value; int value = 0;
eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display, eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display,
configArray[i], attribute_name, &value); configArray[i], attribute_name, &value);
if (value > previous_value) if (value > previous_value)
{ {
previous_value = value; previous_value = value;
temp_array[*size] = value; array[*size] = value;
(*size)++; (*size)++;
} }
} }

View File

@ -0,0 +1,33 @@
/*
* fg_state_egl.c
*
* EGL-specific freeglut state query methods.
*
* Copyright (C) 2012 Sylvain Beucler
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __FG_STATE_EGL_H__
#define __FG_STATE_EGL_H__
#include <GL/freeglut.h>
#include "fg_internal.h"
int fghPlatformGlutGetEGL(GLenum eWhat);
#endif

View File

@ -116,9 +116,9 @@ void fghPlatformOpenWindowEGL( SFG_Window* window )
fgPlatformSetWindow(window); fgPlatformSetWindow(window);
//EGLint w, h; /* EGLint w, h; */
//eglQuerySurface(display, surface, EGL_WIDTH, &w); /* eglQuerySurface(display, surface, EGL_WIDTH, &w); */
//eglQuerySurface(display, surface, EGL_HEIGHT, &h); /* eglQuerySurface(display, surface, EGL_HEIGHT, &h); */
} }

View File

@ -1,5 +1,5 @@
/* /*
* freeglut_display_android.c * fg_window_egl.h
* *
* Window management methods for EGL * Window management methods for EGL
* *

View File

@ -93,12 +93,12 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
fghEnableVertexAttribArray(attribute_v_coord); fghEnableVertexAttribArray(attribute_v_coord);
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
fghVertexAttribPointer( fghVertexAttribPointer(
attribute_v_coord, // attribute attribute_v_coord, /* attribute */
3, // number of elements per vertex, here (x,y,z) 3, /* number of elements per vertex, here (x,y,z) */
GL_FLOAT, // the type of each element GL_FLOAT, /* the type of each element */
GL_FALSE, // take our values as-is GL_FALSE, /* take our values as-is */
0, // no extra data between each position 0, /* no extra data between each position */
0 // offset of first element 0 /* offset of first element */
); );
} }
@ -106,12 +106,12 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
fghEnableVertexAttribArray(attribute_v_normal); fghEnableVertexAttribArray(attribute_v_normal);
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
fghVertexAttribPointer( fghVertexAttribPointer(
attribute_v_normal, // attribute attribute_v_normal, /* attribute */
3, // number of elements per vertex, here (x,y,z) 3, /* number of elements per vertex, here (x,y,z) */
GL_FLOAT, // the type of each element GL_FLOAT, /* the type of each element */
GL_FALSE, // take our values as-is GL_FALSE, /* take our values as-is */
0, // no extra data between each position 0, /* no extra data between each position */
0 // offset of first element 0 /* offset of first element */
); );
} }
@ -208,12 +208,12 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte
fghEnableVertexAttribArray(attribute_v_coord); fghEnableVertexAttribArray(attribute_v_coord);
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords); fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
fghVertexAttribPointer( fghVertexAttribPointer(
attribute_v_coord, // attribute attribute_v_coord, /* attribute */
3, // number of elements per vertex, here (x,y,z) 3, /* number of elements per vertex, here (x,y,z) */
GL_FLOAT, // the type of each element GL_FLOAT, /* the type of each element */
GL_FALSE, // take our values as-is GL_FALSE, /* take our values as-is */
0, // no extra data between each position 0, /* no extra data between each position */
0 // offset of first element 0 /* offset of first element */
); );
}; };
@ -221,12 +221,12 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte
fghEnableVertexAttribArray(attribute_v_normal); fghEnableVertexAttribArray(attribute_v_normal);
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals); fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
fghVertexAttribPointer( fghVertexAttribPointer(
attribute_v_normal, // attribute attribute_v_normal, /* attribute */
3, // number of elements per vertex, here (x,y,z) 3, /* number of elements per vertex, here (x,y,z) */
GL_FLOAT, // the type of each element GL_FLOAT, /* the type of each element */
GL_FALSE, // take our values as-is GL_FALSE, /* take our values as-is */
0, // no extra data between each position 0, /* no extra data between each position */
0 // offset of first element 0 /* offset of first element */
); );
}; };
@ -304,7 +304,7 @@ static void fghGenerateGeometryWithIndexArray(int numFaces, int numEdgePerFace,
for (i=0; i<numFaces; i++) for (i=0; i<numFaces; i++)
{ {
int normIdx = i*3; int normIdx = i*3;
int faceIdxVertIdx = i*numEdgePerFace; // index to first element of "row" in vertex indices int faceIdxVertIdx = i*numEdgePerFace; /* index to first element of "row" in vertex indices */
for (j=0; j<numEdgePerFace; j++) for (j=0; j<numEdgePerFace; j++)
{ {
int outIdx = i*numEdgePerFace*3+j*3; int outIdx = i*numEdgePerFace*3+j*3;
@ -402,7 +402,7 @@ static GLubyte cube_vi[CUBE_VERT_PER_OBJ] =
7,4,3,2, 7,4,3,2,
4,7,6,5 4,7,6,5
}; };
DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(cube,Cube,CUBE); DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(cube,Cube,CUBE)
/* -- Dodecahedron -- */ /* -- Dodecahedron -- */
/* Magic Numbers: It is possible to create a dodecahedron by attaching two /* Magic Numbers: It is possible to create a dodecahedron by attaching two
@ -478,7 +478,7 @@ static GLubyte dodecahedron_vi[DODECAHEDRON_VERT_PER_OBJ] =
18, 1, 0, 5, 9, 18, 1, 0, 5, 9,
19, 14, 13, 10, 12 19, 14, 13, 10, 12
}; };
DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(dodecahedron,Dodecahedron,DODECAHEDRON); DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(dodecahedron,Dodecahedron,DODECAHEDRON)
/* -- Icosahedron -- */ /* -- Icosahedron -- */
@ -557,7 +557,7 @@ static GLubyte icosahedron_vi[ICOSAHEDRON_VERT_PER_OBJ] =
11, 6, 7 , 11, 6, 7 ,
11, 10, 6 11, 10, 6
}; };
DECLARE_SHAPE_CACHE(icosahedron,Icosahedron,ICOSAHEDRON); DECLARE_SHAPE_CACHE(icosahedron,Icosahedron,ICOSAHEDRON)
/* -- Octahedron -- */ /* -- Octahedron -- */
#define OCTAHEDRON_NUM_VERT 6 #define OCTAHEDRON_NUM_VERT 6
@ -604,7 +604,7 @@ static GLubyte octahedron_vi[OCTAHEDRON_VERT_PER_OBJ] =
3, 4, 2, 3, 4, 2,
3, 5, 4 3, 5, 4
}; };
DECLARE_SHAPE_CACHE(octahedron,Octahedron,OCTAHEDRON); DECLARE_SHAPE_CACHE(octahedron,Octahedron,OCTAHEDRON)
/* -- RhombicDodecahedron -- */ /* -- RhombicDodecahedron -- */
#define RHOMBICDODECAHEDRON_NUM_VERT 14 #define RHOMBICDODECAHEDRON_NUM_VERT 14
@ -665,7 +665,7 @@ static GLubyte rhombicdodecahedron_vi[RHOMBICDODECAHEDRON_VERT_PER_OBJ] =
7, 11, 13, 12, 7, 11, 13, 12,
8, 12, 13, 9 8, 12, 13, 9
}; };
DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(rhombicdodecahedron,RhombicDodecahedron,RHOMBICDODECAHEDRON); DECLARE_SHAPE_CACHE_DECOMPOSE_TO_TRIANGLE(rhombicdodecahedron,RhombicDodecahedron,RHOMBICDODECAHEDRON)
/* -- Tetrahedron -- */ /* -- Tetrahedron -- */
/* Magic Numbers: r0 = ( 1, 0, 0 ) /* Magic Numbers: r0 = ( 1, 0, 0 )
@ -709,7 +709,7 @@ static GLubyte tetrahedron_vi[TETRAHEDRON_VERT_PER_OBJ] =
0, 3, 1, 0, 3, 1,
0, 1, 2 0, 1, 2
}; };
DECLARE_SHAPE_CACHE(tetrahedron,Tetrahedron,TETRAHEDRON); DECLARE_SHAPE_CACHE(tetrahedron,Tetrahedron,TETRAHEDRON)
/* -- Sierpinski Sponge -- */ /* -- Sierpinski Sponge -- */
static unsigned int ipow (int x, unsigned int y) static unsigned int ipow (int x, unsigned int y)
@ -757,6 +757,7 @@ static void fghSierpinskiSpongeGenerate ( int numLevels, double offset[3], GLflo
} }
} }
#ifndef GL_ES_VERSION_2_0
/* -- Now the various shapes involving circles -- */ /* -- Now the various shapes involving circles -- */
/* /*
* Compute lookup table of cos and sin values forming a circle * Compute lookup table of cos and sin values forming a circle
@ -893,7 +894,7 @@ static void fghGenerateSphere(GLfloat radius, GLint slices, GLint stacks, GLfloa
free(sint2); free(sint2);
free(cost2); free(cost2);
} }
#endif
/* -- INTERNAL DRAWING functions --------------------------------------- */ /* -- INTERNAL DRAWING functions --------------------------------------- */
#define _DECLARE_INTERNAL_DRAW_DO_DECLARE(name,nameICaps,nameCaps,vertIdxs)\ #define _DECLARE_INTERNAL_DRAW_DO_DECLARE(name,nameICaps,nameCaps,vertIdxs)\
@ -961,11 +962,11 @@ static void fghCube( GLfloat dSize, GLboolean useWireMode )
free(vertices); free(vertices);
} }
DECLARE_INTERNAL_DRAW_DECOMPOSED_TO_TRIANGLE(dodecahedron,Dodecahedron,DODECAHEDRON); DECLARE_INTERNAL_DRAW_DECOMPOSED_TO_TRIANGLE(dodecahedron,Dodecahedron,DODECAHEDRON)
DECLARE_INTERNAL_DRAW(icosahedron,Icosahedron,ICOSAHEDRON); DECLARE_INTERNAL_DRAW(icosahedron,Icosahedron,ICOSAHEDRON)
DECLARE_INTERNAL_DRAW(octahedron,Octahedron,OCTAHEDRON); DECLARE_INTERNAL_DRAW(octahedron,Octahedron,OCTAHEDRON)
DECLARE_INTERNAL_DRAW_DECOMPOSED_TO_TRIANGLE(rhombicdodecahedron,RhombicDodecahedron,RHOMBICDODECAHEDRON); DECLARE_INTERNAL_DRAW_DECOMPOSED_TO_TRIANGLE(rhombicdodecahedron,RhombicDodecahedron,RHOMBICDODECAHEDRON)
DECLARE_INTERNAL_DRAW(tetrahedron,Tetrahedron,TETRAHEDRON); DECLARE_INTERNAL_DRAW(tetrahedron,Tetrahedron,TETRAHEDRON)
static void fghSierpinskiSponge ( int numLevels, double offset[3], GLfloat scale, GLboolean useWireMode ) static void fghSierpinskiSponge ( int numLevels, double offset[3], GLfloat scale, GLboolean useWireMode )
{ {
@ -1653,10 +1654,10 @@ void FGAPIENTRY glutSolidCube( double dSize )
fghCube( (GLfloat)dSize, FALSE ); fghCube( (GLfloat)dSize, FALSE );
} }
DECLARE_SHAPE_INTERFACE(Dodecahedron); DECLARE_SHAPE_INTERFACE(Dodecahedron)
DECLARE_SHAPE_INTERFACE(Icosahedron); DECLARE_SHAPE_INTERFACE(Icosahedron)
DECLARE_SHAPE_INTERFACE(Octahedron); DECLARE_SHAPE_INTERFACE(Octahedron)
DECLARE_SHAPE_INTERFACE(RhombicDodecahedron); DECLARE_SHAPE_INTERFACE(RhombicDodecahedron)
void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, double offset[3], double scale ) void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, double offset[3], double scale )
{ {
@ -1669,7 +1670,7 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, double offset[3], do
fghSierpinskiSponge ( num_levels, offset, (GLfloat)scale, FALSE ); fghSierpinskiSponge ( num_levels, offset, (GLfloat)scale, FALSE );
} }
DECLARE_SHAPE_INTERFACE(Tetrahedron); DECLARE_SHAPE_INTERFACE(Tetrahedron)
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -40,8 +40,8 @@ void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib) {
void fgInitGL2() { void fgInitGL2() {
#ifndef GL_ES_VERSION_2_0 #ifndef GL_ES_VERSION_2_0
fgState.HasOpenGL20 = 0; fgState.HasOpenGL20 = 0;
// TODO: Mesa returns a valid stub function, rather than NULL, /* TODO: Mesa returns a valid stub function, rather than NULL,
// when we request a non-existent function when we request a non-existent function */
#define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; } #define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; }
CHECK("fghGenBuffers", fghGenBuffers = (FGH_PFNGLGENBUFFERSPROC)glutGetProcAddress("glGenBuffers")); CHECK("fghGenBuffers", fghGenBuffers = (FGH_PFNGLGENBUFFERSPROC)glutGetProcAddress("glGenBuffers"));
CHECK("fghDeleteBuffers", fghDeleteBuffers = (FGH_PFNGLDELETEBUFFERSPROC)glutGetProcAddress("glDeleteBuffers")); CHECK("fghDeleteBuffers", fghDeleteBuffers = (FGH_PFNGLDELETEBUFFERSPROC)glutGetProcAddress("glDeleteBuffers"));

View File

@ -0,0 +1,34 @@
/*
* fg_main.h
*
* The windows message processing methods.
*
* Copyright (C) 2012 Sylvain Beucler
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __FG_MAIN_H__
#define __FG_MAIN_H__
#include <GL/freeglut.h>
#include "fg_internal.h"
extern void fghRedrawWindow(SFG_Window *window);
#endif

View File

@ -18,7 +18,7 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
return GL_FALSE; return GL_FALSE;
} }
int glutCreateMenu( void (* callback)( int menu ) ) {} int glutCreateMenu( void (* callback)( int menu ) ) { return 0; }
void glutDestroyMenu( int menu ) {} void glutDestroyMenu( int menu ) {}
int glutGetMenu( void ) { return 0; } int glutGetMenu( void ) { return 0; }
void glutSetMenu( int menu ) {} void glutSetMenu( int menu ) {}
@ -37,7 +37,7 @@ int glutStrokeWidth( void* font, int character ) { return 0; }
int glutBitmapLength( void* font, const unsigned char* string ) { return 0; } int glutBitmapLength( void* font, const unsigned char* string ) { return 0; }
int glutStrokeLength( void* font, const unsigned char* string ) { return 0; } int glutStrokeLength( void* font, const unsigned char* string ) { return 0; }
void *glutGetMenuData( void ) {} void *glutGetMenuData( void ) { return NULL; }
void glutSetMenuData(void* data) {} void glutSetMenuData(void* data) {}
int glutBitmapHeight( void* font ) { return 0; } int glutBitmapHeight( void* font ) { return 0; }

View File

@ -92,10 +92,8 @@ struct tagSFG_PlatformDisplay
* Make "freeglut" window handle and context types so that we don't need so * Make "freeglut" window handle and context types so that we don't need so
* much conditionally-compiled code later in the library. * much conditionally-compiled code later in the library.
*/ */
#ifndef EGL_VERSION_1_0
typedef Window SFG_WindowHandleType ; typedef Window SFG_WindowHandleType ;
#ifdef EGL_VERSION_1_0
typedef EGLContext SFG_WindowContextType ;
#else
typedef GLXContext SFG_WindowContextType ; typedef GLXContext SFG_WindowContextType ;
#endif #endif
typedef struct tagSFG_PlatformContext SFG_PlatformContext; typedef struct tagSFG_PlatformContext SFG_PlatformContext;