diff --git a/changeAppSettings.sh b/changeAppSettings.sh index 0abb3b700..398cba3f5 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -830,8 +830,13 @@ else ImmersiveMode=true fi +GLESLib=-lGLESv1_CM +GLESVersion=-DSDL_VIDEO_OPENGL_ES_VERSION=1 + if [ "$NeedGles2" = "y" ] ; then NeedGles2=true + GLESLib=-lGLESv2 + GLESVersion=-DSDL_VIDEO_OPENGL_ES_VERSION=2 else NeedGles2=false $SEDI "/==GLES2==/ d" project/AndroidManifest.xml @@ -839,6 +844,8 @@ fi if [ "$NeedGles3" = "y" ] ; then NeedGles3=true + GLESLib=-lGLESv3 + GLESVersion=-DSDL_VIDEO_OPENGL_ES_VERSION=3 else NeedGles3=false $SEDI "/==GLES3==/ d" project/AndroidManifest.xml @@ -922,6 +929,7 @@ cat project/jni/SettingsTemplate.mk | \ sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \ sed "s^APPLICATION_ADDITIONAL_CPPFLAGS :=.*^APPLICATION_ADDITIONAL_CPPFLAGS := $AppCppflags^" | \ sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \ + sed "s^APPLICATION_GLES_LIBRARY :=.*^APPLICATION_GLES_LIBRARY := $GLESLib^" | \ sed "s^APPLICATION_OVERLAPS_SYSTEM_HEADERS :=.*^APPLICATION_OVERLAPS_SYSTEM_HEADERS := $AppOverlapsSystemHeaders^" | \ sed "s^USE_GLSHIM :=.*^USE_GLSHIM := $UseGlshim^" | \ sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := \ @@ -933,7 +941,8 @@ cat project/jni/SettingsTemplate.mk | \ $CompatibilityHacksSlowCompatibleEventQueue \ $CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState \ $CompatibilityHacksProperUsageOfSDL_UpdateRects \ - $UseGlshimCFlags^" | \ + $UseGlshimCFlags \ + $GLESVersion^" | \ sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \ sed "s^APPLICATION_BUILD_EXCLUDE :=.*^APPLICATION_BUILD_EXCLUDE := $AppBuildExclude^" | \ sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \ diff --git a/project/jni/Application.mk b/project/jni/Application.mk index acf40500f..7a84cfe06 100644 --- a/project/jni/Application.mk +++ b/project/jni/Application.mk @@ -4,5 +4,5 @@ include jni/Settings.mk APP_STL := gnustl_static APP_CFLAGS := -O3 -DNDEBUG -g # arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources -APP_PLATFORM := android-14 # Android 4.0, it should be backward compatible to previous versions +APP_PLATFORM := android-18 # Android 4.3, the first one with GLES3 support APP_PIE := true # This feature makes executables incompatible to Android API 15 or lower, but executables without PIE will not run on Android 5.0 and newer diff --git a/project/jni/SettingsTemplate.mk b/project/jni/SettingsTemplate.mk index 0760c2c04..04b5b2402 100644 --- a/project/jni/SettingsTemplate.mk +++ b/project/jni/SettingsTemplate.mk @@ -36,6 +36,8 @@ APPLICATION_ADDITIONAL_CPPFLAGS := APPLICATION_ADDITIONAL_LDFLAGS := +APPLICATION_GLES_LIBRARY := -lGLESv1_CM + APPLICATION_OVERLAPS_SYSTEM_HEADERS := n APPLICATION_SUBDIRS_BUILD := src/* diff --git a/project/jni/application/Android.mk b/project/jni/application/Android.mk index 6f9d2ecd5..2f8fdf47a 100644 --- a/project/jni/application/Android.mk +++ b/project/jni/application/Android.mk @@ -51,11 +51,10 @@ LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBR APP_STL := gnustl_static -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz # -lgnustl_static +LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz # -lgnustl_static LOCAL_LDFLAGS := -Lobj/local/$(TARGET_ARCH_ABI) - LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS) LOCAL_CPP_EXTENSION := .cpp .cxx .cc diff --git a/project/jni/application/ninslash/src b/project/jni/application/ninslash/src index d50a673b5..ec8223f1e 160000 --- a/project/jni/application/ninslash/src +++ b/project/jni/application/ninslash/src @@ -1 +1 @@ -Subproject commit d50a673b5626d6d16b058d6aeeee876636dc7ae7 +Subproject commit ec8223f1e2f895cb852cc972b7e2fbde4d5a9b46 diff --git a/project/jni/application/test-gles3/AndroidAppSettings.cfg b/project/jni/application/test-gles3/AndroidAppSettings.cfg new file mode 100644 index 000000000..aebfe8152 --- /dev/null +++ b/project/jni/application/test-gles3/AndroidAppSettings.cfg @@ -0,0 +1,295 @@ +# The application settings for Android libSDL port + +# Specify application name (e.x. My Application) +AppName="GLES3 SDL test" + +# Specify reversed site name of application (e.x. com.mysite.myapp) +AppFullName=gles3.sdl.test + +# Application version code (integer) +AppVersionCode=1 + +# Application user-visible version name (string) +AppVersionName="1" + +# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' +# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu +# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped +# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir - +# these files are put inside .apk package by build system +# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version, first associated with the file +AppDataDownloadUrl="!!Data|data.zip" + +# Reset SDL config when updating application to the new version (y) / (n) +ResetSdlConfigForThisVersion=n + +# Delete application data files when upgrading (specify file/dir paths separated by spaces) +DeleteFilesOnUpgrade="%" + +# Here you may type readme text, which will be shown during startup. Format is: +# Text in English, use \\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/ +ReadmeText='^text' + +# libSDL version to use (1.2/1.3/2.0) +LibSdlVersion=1.2 + +# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape +ScreenOrientation=h + +# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only +# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32) +VideoDepthBpp=24 + +# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) +NeedDepthBuffer=n + +# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n) +NeedStencilBuffer=n + +# Use GLES 2.x context +# you need this option only if you're developing 3-d app (y) or (n) +NeedGles2=n + +# Use GLES 3.x context +# you need this option only if you're developing 3-d app (y) or (n) +NeedGles3=y + +# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n) +UseGlshim=n + +# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL, +# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n) +SwVideoMode=n + +# Application video output will be resized to fit into native device screen (y)/(n) +SdlVideoResize=n + +# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n) +SdlVideoResizeKeepAspect=n + +# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer +InhibitSuspend=y + +# Create Android service, so the app is less likely to be killed while in background +CreateService=n + +# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread - +# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n) +CompatibilityHacksForceScreenUpdate=n + +# Application does not call SDL_Flip() or SDL_UpdateRects() after mouse click (ScummVM and all Amiga emulators do that) - +# force screen update by moving mouse cursor a little after each click (y) or (n) +CompatibilityHacksForceScreenUpdateMouseClick=n + +# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n) +CompatibilityHacksStaticInit=n + +# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n) +CompatibilityHacksTextInputEmulatesHwKeyboard=n + +# Built-in text input keyboards with custom layouts for emulators, requires CompatibilityHacksTextInputEmulatesHwKeyboard=y +# 0 or empty - standard Android keyboard +# 1 - Simple QWERTY keyboard, no function keys, no arrow keys +# 2 - Commodore 64 keyboard +# 3 - Amiga keyboard +# 4 - Atari800 keyboard +TextInputKeyboard=0 + +# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) +CompatibilityHacksPreventAudioChopping=n + +# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n) +CompatibilityHacksAppIgnoresAudioBufferSize=n + +# Hack for VCMI: preload additional shared libraries before aplication start +CompatibilityHacksAdditionalPreloadedSharedLibraries="" + +# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue - +# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) +CompatibilityHacksSlowCompatibleEventQueue=n + +# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL +CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n + +# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects. +# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n) +CompatibilityHacksProperUsageOfSDL_UpdateRects= + +# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user +AppUsesMouse=y + +# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n) +AppNeedsTwoButtonMouse=n + +# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n) +# If you disable it, swiping with two fingers will send mouse wheel events +RightMouseButtonLongPress= + +# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n) +ShowMouseCursor=n + +# Screen follows mouse cursor, when it's covered by soft keyboard, this works only in software video mode (y) or (n) +ScreenFollowsMouse= + +# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n) +GenerateSubframeTouchEvents= + +# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n) +ForceRelativeMouseMode=n + +# Show on-screen dpad/joystick, that will act as arrow keys (y) or (n) +AppNeedsArrowKeys=n + +# On-screen dpad/joystick will appear under finger when it touches the screen (y) or (n) +# Joystick always follows finger, so moving mouse requires touching the screen with other finger +FloatingScreenJoystick= + +# Application needs text input (y) or (n), enables button for text input on screen +AppNeedsTextInput=y + +# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1 +# This will disable AppNeedsArrowKeys option +AppUsesJoystick=n + +# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n) +AppUsesSecondJoystick=n + +# Application uses third on-screen joystick, as SDL joystick 0 axes 20-21 (y)/(n) +AppUsesThirdJoystick= + +# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7 +AppUsesAccelerometer=n + +# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 +AppUsesGyroscope=n + +# Application uses orientation sensor (y) or (n), reported as joystick 1 axes 8-10 +AppUsesOrientationSensor= + +# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting +MoveMouseWithGyroscope= + +# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0 +AppUsesMultitouch=n + +# Application records audio (it will use any available source, such a s microphone) +# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void); +# This option will add additional permission to Android manifest (y)/(n) +AppRecordsAudio=n + +# Application needs to access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n) +AccessSdCard= + +# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n) +AccessInternet= + +# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n) +ImmersiveMode= + +# Application implements Android-specific routines to put to background, and will not draw anything to screen +# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them +# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n) +# This option is reported to be buggy, sometimes failing to restore video state +NonBlockingSwapBuffers=n + +# Redefine common hardware keys to SDL keysyms +# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent +# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices +# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th) +# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA +RedefinedKeys="RETURN" + +# Number of virtual keyboard keys (currently 6 is maximum) +AppTouchscreenKeyboardKeysAmount=0 + +# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) +RedefinedKeysScreenKb="RETURN" + +# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu +RedefinedKeysScreenKbNames="RETURN" + +# On-screen keys theme +# 0 = Ultimate Droid by Sean Stieber (green, with cross joystick) +# 1 = Simple Theme by Beholder (white, with cross joystick) +# 2 = Sun by Sirea (yellow, with round joystick) +# 3 = Keen by Gerstrong (multicolor, with round joystick) +# 4 = Retro by Santiago Radeff (red/white, with cross joystick) +# 5 = GameBoy from RetroArch +# 6 = PlayStation from RetroArch +# 7 = SuperNintendo from RetroArch +# 8 = DualShock from RetroArch +# 9 = Nintendo64 from RetroArch +TouchscreenKeysTheme=2 + +# Redefine gamepad keys to SDL keysyms, button order is: +# A B X Y L1 R1 L2 R2 LThumb RThumb +RedefinedKeysGamepad="RETURN" + +# How long to show startup menu button, in msec, 0 to disable startup menu +StartupMenuButtonTimeout=0 + +# Menu items to hide from startup menu, available menu items: +# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced +HiddenMenuOptions='' + +# Menu items to show at startup - this is Java code snippet, leave empty for default +# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration() +# Available menu items: +# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced +FirstStartMenuOptions='' + +# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower +AppMinimumRAM=0 + +# GCC version, or 'clang' for CLANG +NDK_TOOLCHAIN_VERSION= + +# Specify architectures to compile, 'all' or 'y' to compile for all architectures. +# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a +MultiABI='armeabi-v7a' + +# Optional shared libraries to compile - removing some of them will save space +# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed +# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2 +CompiledLibraries="sdl_image" + +# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) +CustomBuildScript=n + +# Aditional CFLAGS for application +AppCflags='-O2' + +# Aditional C++-specific compiler flags for application, added after AppCflags +AppCppflags='' + +# Additional LDFLAGS for application +AppLdflags='' + +# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable +AppOverlapsSystemHeaders= + +# Build only following subdirs (empty will build all dirs, ignored with custom script) +AppSubdirsBuild='' + +# Exclude these files from build +AppBuildExclude='' + +# Application command line parameters, including app name as 0-th param +AppCmdline='' + +# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens +# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge +MinimumScreenSize=s + +# Your AdMob Publisher ID, (n) if you don't want advertisements +AdmobPublisherId=n + +# Your AdMob test device ID, to receive a test ad +AdmobTestDeviceId= + +# Your AdMob banner size (BANNER/FULL_BANNER/LEADERBOARD/MEDIUM_RECTANGLE/SMART_BANNER/WIDE_SKYSCRAPER/FULL_WIDTH:Height/Width:AUTO_HEIGHT/Width:Height) +AdmobBannerSize= + +# Google Play Game Services application ID, required for cloud saves to work +GooglePlayGameServicesId= + diff --git a/project/jni/application/test-gles3/AndroidData/data.zip b/project/jni/application/test-gles3/AndroidData/data.zip new file mode 100644 index 000000000..c8a260651 Binary files /dev/null and b/project/jni/application/test-gles3/AndroidData/data.zip differ diff --git a/project/jni/application/test-gles3/Makefile b/project/jni/application/test-gles3/Makefile new file mode 100644 index 000000000..65234a0e0 --- /dev/null +++ b/project/jni/application/test-gles3/Makefile @@ -0,0 +1,4 @@ + +sdl_hello: *.cpp + g++ -g3 -O0 -o $@ $? `sdl-config --cflags` `sdl-config --libs` -lGL -lSDL_image + unzip -o AndroidData/*.zip diff --git a/project/jni/application/test-gles3/esShader.c b/project/jni/application/test-gles3/esShader.c new file mode 100644 index 000000000..d1fa22cde --- /dev/null +++ b/project/jni/application/test-gles3/esShader.c @@ -0,0 +1,184 @@ +// The MIT License (MIT) +// +// Copyright (c) 2013 Dan Ginsburg, Budirijanto Purnomo +// +// 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 THE +// AUTHORS OR COPYRIGHT HOLDERS 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. + +// +// Book: OpenGL(R) ES 3.0 Programming Guide, 2nd Edition +// Authors: Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi +// ISBN-10: 0-321-93388-5 +// ISBN-13: 978-0-321-93388-1 +// Publisher: Addison-Wesley Professional +// URLs: http://www.opengles-book.com +// http://my.safaribooksonline.com/book/animation-and-3d/9780133440133 +// +// ESShader.c +// +// Utility functions for loading shaders and creating program objects. +// + +/// +// Includes +// +#include "esUtil.h" +#include + +////////////////////////////////////////////////////////////////// +// +// Private Functions +// +// + + + +////////////////////////////////////////////////////////////////// +// +// Public Functions +// +// + +// +/// +/// \brief Load a shader, check for compile errors, print error messages to output log +/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) +/// \param shaderSrc Shader source string +/// \return A new shader object on success, 0 on failure +// +GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ) +{ + GLuint shader; + GLint compiled; + + // Create the shader object + shader = glCreateShader ( type ); + + if ( shader == 0 ) + { + return 0; + } + + // Load the shader source + glShaderSource ( shader, 1, &shaderSrc, NULL ); + + // Compile the shader + glCompileShader ( shader ); + + // Check the compile status + glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled ); + + if ( !compiled ) + { + GLint infoLen = 0; + + glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen ); + + if ( infoLen > 1 ) + { + char *infoLog = malloc ( sizeof ( char ) * infoLen ); + + glGetShaderInfoLog ( shader, infoLen, NULL, infoLog ); + esLogMessage ( "Error compiling shader:\n%s\n", infoLog ); + + free ( infoLog ); + } + + glDeleteShader ( shader ); + return 0; + } + + return shader; + +} + + +// +/// +/// \brief Load a vertex and fragment shader, create a program object, link program. +// Errors output to log. +/// \param vertShaderSrc Vertex shader source code +/// \param fragShaderSrc Fragment shader source code +/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure +// +GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ) +{ + GLuint vertexShader; + GLuint fragmentShader; + GLuint programObject; + GLint linked; + + // Load the vertex/fragment shaders + vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc ); + + if ( vertexShader == 0 ) + { + return 0; + } + + fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc ); + + if ( fragmentShader == 0 ) + { + glDeleteShader ( vertexShader ); + return 0; + } + + // Create the program object + programObject = glCreateProgram ( ); + + if ( programObject == 0 ) + { + return 0; + } + + glAttachShader ( programObject, vertexShader ); + glAttachShader ( programObject, fragmentShader ); + + // Link the program + glLinkProgram ( programObject ); + + // Check the link status + glGetProgramiv ( programObject, GL_LINK_STATUS, &linked ); + + if ( !linked ) + { + GLint infoLen = 0; + + glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen ); + + if ( infoLen > 1 ) + { + char *infoLog = malloc ( sizeof ( char ) * infoLen ); + + glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog ); + esLogMessage ( "Error linking program:\n%s\n", infoLog ); + + free ( infoLog ); + } + + glDeleteProgram ( programObject ); + return 0; + } + + // Free up no longer needed shader resources + glDeleteShader ( vertexShader ); + glDeleteShader ( fragmentShader ); + + return programObject; +} \ No newline at end of file diff --git a/project/jni/application/test-gles3/esShapes.c b/project/jni/application/test-gles3/esShapes.c new file mode 100644 index 000000000..006648022 --- /dev/null +++ b/project/jni/application/test-gles3/esShapes.c @@ -0,0 +1,367 @@ +// The MIT License (MIT) +// +// Copyright (c) 2013 Dan Ginsburg, Budirijanto Purnomo +// +// 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 THE +// AUTHORS OR COPYRIGHT HOLDERS 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. + +// +// Book: OpenGL(R) ES 3.0 Programming Guide, 2nd Edition +// Authors: Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi +// ISBN-10: 0-321-93388-5 +// ISBN-13: 978-0-321-93388-1 +// Publisher: Addison-Wesley Professional +// URLs: http://www.opengles-book.com +// http://my.safaribooksonline.com/book/animation-and-3d/9780133440133 +// +// ESShapes.c +// +// Utility functions for generating shapes +// + +/// +// Includes +// +#include "esUtil.h" +#include +#include +#include + +/// +// Defines +// +#define ES_PI (3.14159265f) + +////////////////////////////////////////////////////////////////// +// +// Private Functions +// +// + + + +////////////////////////////////////////////////////////////////// +// +// Public Functions +// +// + +// +/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list for a TRIANGLE_STRIP +/// \param numSlices The number of slices in the sphere +/// \param vertices If not NULL, will contain array of float3 positions +/// \param normals If not NULL, will contain array of float3 normals +/// \param texCoords If not NULL, will contain array of float2 texCoords +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLE_STRIP +// +int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, + GLfloat **texCoords, GLuint **indices ) +{ + int i; + int j; + int numParallels = numSlices / 2; + int numVertices = ( numParallels + 1 ) * ( numSlices + 1 ); + int numIndices = numParallels * numSlices * 6; + float angleStep = ( 2.0f * ES_PI ) / ( ( float ) numSlices ); + + // Allocate memory for buffers + if ( vertices != NULL ) + { + *vertices = malloc ( sizeof ( GLfloat ) * 3 * numVertices ); + } + + if ( normals != NULL ) + { + *normals = malloc ( sizeof ( GLfloat ) * 3 * numVertices ); + } + + if ( texCoords != NULL ) + { + *texCoords = malloc ( sizeof ( GLfloat ) * 2 * numVertices ); + } + + if ( indices != NULL ) + { + *indices = malloc ( sizeof ( GLuint ) * numIndices ); + } + + for ( i = 0; i < numParallels + 1; i++ ) + { + for ( j = 0; j < numSlices + 1; j++ ) + { + int vertex = ( i * ( numSlices + 1 ) + j ) * 3; + + if ( vertices ) + { + ( *vertices ) [vertex + 0] = radius * sinf ( angleStep * ( float ) i ) * + sinf ( angleStep * ( float ) j ); + ( *vertices ) [vertex + 1] = radius * cosf ( angleStep * ( float ) i ); + ( *vertices ) [vertex + 2] = radius * sinf ( angleStep * ( float ) i ) * + cosf ( angleStep * ( float ) j ); + } + + if ( normals ) + { + ( *normals ) [vertex + 0] = ( *vertices ) [vertex + 0] / radius; + ( *normals ) [vertex + 1] = ( *vertices ) [vertex + 1] / radius; + ( *normals ) [vertex + 2] = ( *vertices ) [vertex + 2] / radius; + } + + if ( texCoords ) + { + int texIndex = ( i * ( numSlices + 1 ) + j ) * 2; + ( *texCoords ) [texIndex + 0] = ( float ) j / ( float ) numSlices; + ( *texCoords ) [texIndex + 1] = ( 1.0f - ( float ) i ) / ( float ) ( numParallels - 1 ); + } + } + } + + // Generate the indices + if ( indices != NULL ) + { + GLuint *indexBuf = ( *indices ); + + for ( i = 0; i < numParallels ; i++ ) + { + for ( j = 0; j < numSlices; j++ ) + { + *indexBuf++ = i * ( numSlices + 1 ) + j; + *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + j; + *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 ); + + *indexBuf++ = i * ( numSlices + 1 ) + j; + *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 ); + *indexBuf++ = i * ( numSlices + 1 ) + ( j + 1 ); + } + } + } + + return numIndices; +} + +// +/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list for a TRIANGLES +/// \param scale The size of the cube, use 1.0 for a unit cube. +/// \param vertices If not NULL, will contain array of float3 positions +/// \param normals If not NULL, will contain array of float3 normals +/// \param texCoords If not NULL, will contain array of float2 texCoords +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLE_STRIP +// +int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, + GLfloat **texCoords, GLuint **indices ) +{ + int i; + int numVertices = 24; + int numIndices = 36; + + GLfloat cubeVerts[] = + { + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, -0.5f, + -0.5f, 0.5f, -0.5f, + -0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f, + }; + + GLfloat cubeNormals[] = + { + 0.0f, -1.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 1.0f, + -1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + }; + + GLfloat cubeTex[] = + { + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + }; + + // Allocate memory for buffers + if ( vertices != NULL ) + { + *vertices = malloc ( sizeof ( GLfloat ) * 3 * numVertices ); + memcpy ( *vertices, cubeVerts, sizeof ( cubeVerts ) ); + + for ( i = 0; i < numVertices * 3; i++ ) + { + ( *vertices ) [i] *= scale; + } + } + + if ( normals != NULL ) + { + *normals = malloc ( sizeof ( GLfloat ) * 3 * numVertices ); + memcpy ( *normals, cubeNormals, sizeof ( cubeNormals ) ); + } + + if ( texCoords != NULL ) + { + *texCoords = malloc ( sizeof ( GLfloat ) * 2 * numVertices ); + memcpy ( *texCoords, cubeTex, sizeof ( cubeTex ) ) ; + } + + + // Generate the indices + if ( indices != NULL ) + { + GLuint cubeIndices[] = + { + 0, 2, 1, + 0, 3, 2, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 15, 14, + 12, 14, 13, + 16, 17, 18, + 16, 18, 19, + 20, 23, 22, + 20, 22, 21 + }; + + *indices = malloc ( sizeof ( GLuint ) * numIndices ); + memcpy ( *indices, cubeIndices, sizeof ( cubeIndices ) ); + } + + return numIndices; +} + +// +/// \brief Generates a square grid consisting of triangles. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list as TRIANGLES. +/// \param size create a grid of size by size (number of triangles = (size-1)*(size-1)*2) +/// \param vertices If not NULL, will contain array of float3 positions +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLES +// +int ESUTIL_API esGenSquareGrid ( int size, GLfloat **vertices, GLuint **indices ) +{ + int i, j; + int numIndices = ( size - 1 ) * ( size - 1 ) * 2 * 3; + + // Allocate memory for buffers + if ( vertices != NULL ) + { + int numVertices = size * size; + float stepSize = ( float ) size - 1; + *vertices = malloc ( sizeof ( GLfloat ) * 3 * numVertices ); + + for ( i = 0; i < size; ++i ) // row + { + for ( j = 0; j < size; ++j ) // column + { + ( *vertices ) [ 3 * ( j + i * size ) ] = i / stepSize; + ( *vertices ) [ 3 * ( j + i * size ) + 1 ] = j / stepSize; + ( *vertices ) [ 3 * ( j + i * size ) + 2 ] = 0.0f; + } + } + } + + // Generate the indices + if ( indices != NULL ) + { + *indices = malloc ( sizeof ( GLuint ) * numIndices ); + + for ( i = 0; i < size - 1; ++i ) + { + for ( j = 0; j < size - 1; ++j ) + { + // two triangles per quad + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) ] = j + ( i ) * ( size ) ; + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) + 1 ] = j + ( i ) * ( size ) + 1; + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) + 2 ] = j + ( i + 1 ) * ( size ) + 1; + + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) + 3 ] = j + ( i ) * ( size ) ; + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) + 4 ] = j + ( i + 1 ) * ( size ) + 1; + ( *indices ) [ 6 * ( j + i * ( size - 1 ) ) + 5 ] = j + ( i + 1 ) * ( size ) ; + } + } + } + + return numIndices; +} diff --git a/project/jni/application/test-gles3/esTransform.c b/project/jni/application/test-gles3/esTransform.c new file mode 100644 index 000000000..8ca769e9c --- /dev/null +++ b/project/jni/application/test-gles3/esTransform.c @@ -0,0 +1,314 @@ +// The MIT License (MIT) +// +// Copyright (c) 2013 Dan Ginsburg, Budirijanto Purnomo +// +// 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 THE +// AUTHORS OR COPYRIGHT HOLDERS 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. + +// +// Book: OpenGL(R) ES 3.0 Programming Guide, 2nd Edition +// Authors: Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi +// ISBN-10: 0-321-93388-5 +// ISBN-13: 978-0-321-93388-1 +// Publisher: Addison-Wesley Professional +// URLs: http://www.opengles-book.com +// http://my.safaribooksonline.com/book/animation-and-3d/9780133440133 +// +// ESUtil.c +// +// A utility library for OpenGL ES. This library provides a +// basic common framework for the example applications in the +// OpenGL ES 3.0 Programming Guide. +// + +/// +// Includes +// +#include "esUtil.h" +#include +#include + +#define PI 3.1415926535897932384626433832795f + +void ESUTIL_API +esScale ( ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz ) +{ + result->m[0][0] *= sx; + result->m[0][1] *= sx; + result->m[0][2] *= sx; + result->m[0][3] *= sx; + + result->m[1][0] *= sy; + result->m[1][1] *= sy; + result->m[1][2] *= sy; + result->m[1][3] *= sy; + + result->m[2][0] *= sz; + result->m[2][1] *= sz; + result->m[2][2] *= sz; + result->m[2][3] *= sz; +} + +void ESUTIL_API +esTranslate ( ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz ) +{ + result->m[3][0] += ( result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz ); + result->m[3][1] += ( result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz ); + result->m[3][2] += ( result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz ); + result->m[3][3] += ( result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz ); +} + +void ESUTIL_API +esRotate ( ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) +{ + GLfloat sinAngle, cosAngle; + GLfloat mag = sqrtf ( x * x + y * y + z * z ); + + sinAngle = sinf ( angle * PI / 180.0f ); + cosAngle = cosf ( angle * PI / 180.0f ); + + if ( mag > 0.0f ) + { + GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs; + GLfloat oneMinusCos; + ESMatrix rotMat; + + x /= mag; + y /= mag; + z /= mag; + + xx = x * x; + yy = y * y; + zz = z * z; + xy = x * y; + yz = y * z; + zx = z * x; + xs = x * sinAngle; + ys = y * sinAngle; + zs = z * sinAngle; + oneMinusCos = 1.0f - cosAngle; + + rotMat.m[0][0] = ( oneMinusCos * xx ) + cosAngle; + rotMat.m[0][1] = ( oneMinusCos * xy ) - zs; + rotMat.m[0][2] = ( oneMinusCos * zx ) + ys; + rotMat.m[0][3] = 0.0F; + + rotMat.m[1][0] = ( oneMinusCos * xy ) + zs; + rotMat.m[1][1] = ( oneMinusCos * yy ) + cosAngle; + rotMat.m[1][2] = ( oneMinusCos * yz ) - xs; + rotMat.m[1][3] = 0.0F; + + rotMat.m[2][0] = ( oneMinusCos * zx ) - ys; + rotMat.m[2][1] = ( oneMinusCos * yz ) + xs; + rotMat.m[2][2] = ( oneMinusCos * zz ) + cosAngle; + rotMat.m[2][3] = 0.0F; + + rotMat.m[3][0] = 0.0F; + rotMat.m[3][1] = 0.0F; + rotMat.m[3][2] = 0.0F; + rotMat.m[3][3] = 1.0F; + + esMatrixMultiply ( result, &rotMat, result ); + } +} + +void ESUTIL_API +esFrustum ( ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ ) +{ + float deltaX = right - left; + float deltaY = top - bottom; + float deltaZ = farZ - nearZ; + ESMatrix frust; + + if ( ( nearZ <= 0.0f ) || ( farZ <= 0.0f ) || + ( deltaX <= 0.0f ) || ( deltaY <= 0.0f ) || ( deltaZ <= 0.0f ) ) + { + return; + } + + frust.m[0][0] = 2.0f * nearZ / deltaX; + frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f; + + frust.m[1][1] = 2.0f * nearZ / deltaY; + frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f; + + frust.m[2][0] = ( right + left ) / deltaX; + frust.m[2][1] = ( top + bottom ) / deltaY; + frust.m[2][2] = - ( nearZ + farZ ) / deltaZ; + frust.m[2][3] = -1.0f; + + frust.m[3][2] = -2.0f * nearZ * farZ / deltaZ; + frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f; + + esMatrixMultiply ( result, &frust, result ); +} + + +void ESUTIL_API +esPerspective ( ESMatrix *result, float fovy, float aspect, float nearZ, float farZ ) +{ + GLfloat frustumW, frustumH; + + frustumH = tanf ( fovy / 360.0f * PI ) * nearZ; + frustumW = frustumH * aspect; + + esFrustum ( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ ); +} + +void ESUTIL_API +esOrtho ( ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ ) +{ + float deltaX = right - left; + float deltaY = top - bottom; + float deltaZ = farZ - nearZ; + ESMatrix ortho; + + if ( ( deltaX == 0.0f ) || ( deltaY == 0.0f ) || ( deltaZ == 0.0f ) ) + { + return; + } + + esMatrixLoadIdentity ( &ortho ); + ortho.m[0][0] = 2.0f / deltaX; + ortho.m[3][0] = - ( right + left ) / deltaX; + ortho.m[1][1] = 2.0f / deltaY; + ortho.m[3][1] = - ( top + bottom ) / deltaY; + ortho.m[2][2] = -2.0f / deltaZ; + ortho.m[3][2] = - ( nearZ + farZ ) / deltaZ; + + esMatrixMultiply ( result, &ortho, result ); +} + + +void ESUTIL_API +esMatrixMultiply ( ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB ) +{ + ESMatrix tmp; + int i; + + for ( i = 0; i < 4; i++ ) + { + tmp.m[i][0] = ( srcA->m[i][0] * srcB->m[0][0] ) + + ( srcA->m[i][1] * srcB->m[1][0] ) + + ( srcA->m[i][2] * srcB->m[2][0] ) + + ( srcA->m[i][3] * srcB->m[3][0] ) ; + + tmp.m[i][1] = ( srcA->m[i][0] * srcB->m[0][1] ) + + ( srcA->m[i][1] * srcB->m[1][1] ) + + ( srcA->m[i][2] * srcB->m[2][1] ) + + ( srcA->m[i][3] * srcB->m[3][1] ) ; + + tmp.m[i][2] = ( srcA->m[i][0] * srcB->m[0][2] ) + + ( srcA->m[i][1] * srcB->m[1][2] ) + + ( srcA->m[i][2] * srcB->m[2][2] ) + + ( srcA->m[i][3] * srcB->m[3][2] ) ; + + tmp.m[i][3] = ( srcA->m[i][0] * srcB->m[0][3] ) + + ( srcA->m[i][1] * srcB->m[1][3] ) + + ( srcA->m[i][2] * srcB->m[2][3] ) + + ( srcA->m[i][3] * srcB->m[3][3] ) ; + } + + memcpy ( result, &tmp, sizeof ( ESMatrix ) ); +} + + +void ESUTIL_API +esMatrixLoadIdentity ( ESMatrix *result ) +{ + memset ( result, 0x0, sizeof ( ESMatrix ) ); + result->m[0][0] = 1.0f; + result->m[1][1] = 1.0f; + result->m[2][2] = 1.0f; + result->m[3][3] = 1.0f; +} + +void ESUTIL_API +esMatrixLookAt ( ESMatrix *result, + float posX, float posY, float posZ, + float lookAtX, float lookAtY, float lookAtZ, + float upX, float upY, float upZ ) +{ + float axisX[3], axisY[3], axisZ[3]; + float length; + + // axisZ = lookAt - pos + axisZ[0] = lookAtX - posX; + axisZ[1] = lookAtY - posY; + axisZ[2] = lookAtZ - posZ; + + // normalize axisZ + length = sqrtf ( axisZ[0] * axisZ[0] + axisZ[1] * axisZ[1] + axisZ[2] * axisZ[2] ); + + if ( length != 0.0f ) + { + axisZ[0] /= length; + axisZ[1] /= length; + axisZ[2] /= length; + } + + // axisX = up X axisZ + axisX[0] = upY * axisZ[2] - upZ * axisZ[1]; + axisX[1] = upZ * axisZ[0] - upX * axisZ[2]; + axisX[2] = upX * axisZ[1] - upY * axisZ[0]; + + // normalize axisX + length = sqrtf ( axisX[0] * axisX[0] + axisX[1] * axisX[1] + axisX[2] * axisX[2] ); + + if ( length != 0.0f ) + { + axisX[0] /= length; + axisX[1] /= length; + axisX[2] /= length; + } + + // axisY = axisZ x axisX + axisY[0] = axisZ[1] * axisX[2] - axisZ[2] * axisX[1]; + axisY[1] = axisZ[2] * axisX[0] - axisZ[0] * axisX[2]; + axisY[2] = axisZ[0] * axisX[1] - axisZ[1] * axisX[0]; + + // normalize axisY + length = sqrtf ( axisY[0] * axisY[0] + axisY[1] * axisY[1] + axisY[2] * axisY[2] ); + + if ( length != 0.0f ) + { + axisY[0] /= length; + axisY[1] /= length; + axisY[2] /= length; + } + + memset ( result, 0x0, sizeof ( ESMatrix ) ); + + result->m[0][0] = -axisX[0]; + result->m[0][1] = axisY[0]; + result->m[0][2] = -axisZ[0]; + + result->m[1][0] = -axisX[1]; + result->m[1][1] = axisY[1]; + result->m[1][2] = -axisZ[1]; + + result->m[2][0] = -axisX[2]; + result->m[2][1] = axisY[2]; + result->m[2][2] = -axisZ[2]; + + // translate (-posX, -posY, -posZ) + result->m[3][0] = axisX[0] * posX + axisX[1] * posY + axisX[2] * posZ; + result->m[3][1] = -axisY[0] * posX - axisY[1] * posY - axisY[2] * posZ; + result->m[3][2] = axisZ[0] * posX + axisZ[1] * posY + axisZ[2] * posZ; + result->m[3][3] = 1.0f; +} diff --git a/project/jni/application/test-gles3/esUtil.h b/project/jni/application/test-gles3/esUtil.h new file mode 100644 index 000000000..354070201 --- /dev/null +++ b/project/jni/application/test-gles3/esUtil.h @@ -0,0 +1,325 @@ +// The MIT License (MIT) +// +// Copyright (c) 2013 Dan Ginsburg, Budirijanto Purnomo +// +// 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 THE +// AUTHORS OR COPYRIGHT HOLDERS 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. + +// +// Book: OpenGL(R) ES 3.0 Programming Guide, 2nd Edition +// Authors: Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi +// ISBN-10: 0-321-93388-5 +// ISBN-13: 978-0-321-93388-1 +// Publisher: Addison-Wesley Professional +// URLs: http://www.opengles-book.com +// http://my.safaribooksonline.com/book/animation-and-3d/9780133440133 +// +// +/// \file ESUtil.h +/// \brief A utility library for OpenGL ES. This library provides a +/// basic common framework for the example applications in the +/// OpenGL ES 3.0 Programming Guide. +// +#ifndef ESUTIL_H +#define ESUTIL_H + +/// +// Includes +// +#include + +#ifdef __APPLE__ +#include +#else +#include +#include +#include +#endif +#ifdef __cplusplus + +extern "C" { +#endif + + +/// +// Macros +// +#ifdef WIN32 +#define ESUTIL_API __cdecl +#define ESCALLBACK __cdecl +#else +#define ESUTIL_API +#define ESCALLBACK +#endif + + +typedef struct +{ + GLfloat m[4][4]; +} ESMatrix; + +typedef struct ESContext ESContext; + +struct ESContext +{ + /// Put platform specific data here + void *platformData; + + /// Put your user data here... + void *userData; + + /// Window width + GLint width; + + /// Window height + GLint height; + +#ifndef __APPLE__ + /// Display handle + EGLNativeDisplayType eglNativeDisplay; + + /// Window handle + EGLNativeWindowType eglNativeWindow; + + /// EGL display + EGLDisplay eglDisplay; + + /// EGL context + EGLContext eglContext; + + /// EGL surface + EGLSurface eglSurface; +#endif + + /// Callbacks + void ( ESCALLBACK *drawFunc ) ( ESContext * ); + void ( ESCALLBACK *shutdownFunc ) ( ESContext * ); + void ( ESCALLBACK *keyFunc ) ( ESContext *, unsigned char, int, int ); + void ( ESCALLBACK *updateFunc ) ( ESContext *, float deltaTime ); +}; + + +/// +// Public Functions +// + +// +/// \brief Create a window with the specified parameters +/// \param esContext Application context +/// \param title Name for title bar of window +/// \param width Width in pixels of window to create +/// \param height Height in pixels of window to create +/// \param flags Bitfield for the window creation flags +/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels +/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha +/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created +/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created +/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created +/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise +GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char *title, GLint width, GLint height, GLuint flags ); + +// +/// \brief Register a draw callback function to be used to render each frame +/// \param esContext Application context +/// \param drawFunc Draw callback function that will be used to render the scene +// +void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void ( ESCALLBACK *drawFunc ) ( ESContext * ) ); + +// +/// \brief Register a callback function to be called on shutdown +/// \param esContext Application context +/// \param shutdownFunc Shutdown callback function +// +void ESUTIL_API esRegisterShutdownFunc ( ESContext *esContext, void ( ESCALLBACK *shutdownFunc ) ( ESContext * ) ); + +// +/// \brief Register an update callback function to be used to update on each time step +/// \param esContext Application context +/// \param updateFunc Update callback function that will be used to render the scene +// +void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void ( ESCALLBACK *updateFunc ) ( ESContext *, float ) ); + +// +/// \brief Register an keyboard input processing callback function +/// \param esContext Application context +/// \param keyFunc Key callback function for application processing of keyboard input +// +void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext, + void ( ESCALLBACK *drawFunc ) ( ESContext *, unsigned char, int, int ) ); +// +/// \brief Log a message to the debug output for the platform +/// \param formatStr Format string for error log. +// +#ifdef __ANDROID__ +#include +#define esLogMessage(...) __android_log_print(ANDROID_LOG_INFO, "Test-GLES3", __VA_ARGS__) +#else +void ESUTIL_API esLogMessage ( const char *formatStr, ... ); +#endif + +// +/// +/// \brief Load a shader, check for compile errors, print error messages to output log +/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) +/// \param shaderSrc Shader source string +/// \return A new shader object on success, 0 on failure +// +GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ); + +// +/// +/// \brief Load a vertex and fragment shader, create a program object, link program. +/// Errors output to log. +/// \param vertShaderSrc Vertex shader source code +/// \param fragShaderSrc Fragment shader source code +/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure +// +GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ); + + +// +/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list for a TRIANGLE_STRIP +/// \param numSlices The number of slices in the sphere +/// \param vertices If not NULL, will contain array of float3 positions +/// \param normals If not NULL, will contain array of float3 normals +/// \param texCoords If not NULL, will contain array of float2 texCoords +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLE_STRIP +// +int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, + GLfloat **texCoords, GLuint **indices ); + +// +/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list for a TRIANGLES +/// \param scale The size of the cube, use 1.0 for a unit cube. +/// \param vertices If not NULL, will contain array of float3 positions +/// \param normals If not NULL, will contain array of float3 normals +/// \param texCoords If not NULL, will contain array of float2 texCoords +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLES +// +int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, + GLfloat **texCoords, GLuint **indices ); + +// +/// \brief Generates a square grid consisting of triangles. Allocates memory for the vertex data and stores +/// the results in the arrays. Generate index list as TRIANGLES. +/// \param size create a grid of size by size (number of triangles = (size-1)*(size-1)*2) +/// \param vertices If not NULL, will contain array of float3 positions +/// \param indices If not NULL, will contain the array of indices for the triangle strip +/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array +/// if it is not NULL ) as a GL_TRIANGLES +// +int ESUTIL_API esGenSquareGrid ( int size, GLfloat **vertices, GLuint **indices ); + +// +/// \brief Loads a 8-bit, 24-bit or 32-bit TGA image from a file +/// \param ioContext Context related to IO facility on the platform +/// \param fileName Name of the file on disk +/// \param width Width of loaded image in pixels +/// \param height Height of loaded image in pixels +/// \return Pointer to loaded image. NULL on failure. +// +char *ESUTIL_API esLoadTGA ( void *ioContext, const char *fileName, int *width, int *height ); + + +// +/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result +/// \param result Specifies the input matrix. Scaled matrix is returned in result. +/// \param sx, sy, sz Scale factors along the x, y and z axes respectively +// +void ESUTIL_API esScale ( ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz ); + +// +/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result +/// \param result Specifies the input matrix. Translated matrix is returned in result. +/// \param tx, ty, tz Scale factors along the x, y and z axes respectively +// +void ESUTIL_API esTranslate ( ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz ); + +// +/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result +/// \param result Specifies the input matrix. Rotated matrix is returned in result. +/// \param angle Specifies the angle of rotation, in degrees. +/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively +// +void ESUTIL_API esRotate ( ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); + +// +// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param left, right Coordinates for the left and right vertical clipping planes +/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes +/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive. +// +void ESUTIL_API esFrustum ( ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ ); + +// +/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param fovy Field of view y angle in degrees +/// \param aspect Aspect ratio of screen +/// \param nearZ Near plane distance +/// \param farZ Far plane distance +// +void ESUTIL_API esPerspective ( ESMatrix *result, float fovy, float aspect, float nearZ, float farZ ); + +// +/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param left, right Coordinates for the left and right vertical clipping planes +/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes +/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer +// +void ESUTIL_API esOrtho ( ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ ); + +// +/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix +/// \param result Returns multiplied matrix +/// \param srcA, srcB Input matrices to be multiplied +// +void ESUTIL_API esMatrixMultiply ( ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB ); + +// +//// \brief return an indentity matrix +//// \param result returns identity matrix +// +void ESUTIL_API esMatrixLoadIdentity ( ESMatrix *result ); + +// +/// \brief Generate a transformation matrix from eye position, look at and up vectors +/// \param result Returns transformation matrix +/// \param posX, posY, posZ eye position +/// \param lookAtX, lookAtY, lookAtZ look at vector +/// \param upX, upY, upZ up vector +// +void ESUTIL_API +esMatrixLookAt ( ESMatrix *result, + float posX, float posY, float posZ, + float lookAtX, float lookAtY, float lookAtZ, + float upX, float upY, float upZ ); + +#ifdef __cplusplus +} +#endif + +#endif // ESUTIL_H diff --git a/project/jni/application/test-gles3/icon.png b/project/jni/application/test-gles3/icon.png new file mode 100644 index 000000000..ad30aedf6 Binary files /dev/null and b/project/jni/application/test-gles3/icon.png differ diff --git a/project/jni/application/test-gles3/main.cpp b/project/jni/application/test-gles3/main.cpp new file mode 100644 index 000000000..faf2fe393 --- /dev/null +++ b/project/jni/application/test-gles3/main.cpp @@ -0,0 +1,274 @@ +#include +#include +#include +#include + +#include "esUtil.h" + +#ifdef __ANDROID__ +#include +#define printf(...) __android_log_print(ANDROID_LOG_INFO, "Test-GLES3", __VA_ARGS__) +#endif + +int screenWidth = 0; +int screenHeight = 0; + +GLuint drawTextureProgram = 0; +GLint drawTextureSamplerLocation = 0; + +static void initSDL() +{ + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); + SDL_EnableUNICODE(1); + + screenWidth = SDL_GetVideoInfo()->current_w; + screenHeight = SDL_GetVideoInfo()->current_h; + + if ( ! SDL_SetVideoMode(screenWidth, screenHeight, 24, SDL_OPENGL|SDL_DOUBLEBUF|SDL_FULLSCREEN) ) + { + printf("Couldn't set GL video mode: %s\n", SDL_GetError()); + SDL_Quit(); + exit(2); + } + SDL_WM_SetCaption("test", "test"); +} + +void loadShaders() +{ + char vShaderStr[] = + "#version 300 es \n" + "precision mediump float; \n" + "layout(location = 0) in vec4 a_position; \n" + "layout(location = 1) in vec2 a_texCoord; \n" + "out vec2 v_texCoord; \n" + "void main() \n" + "{ \n" + " gl_Position = a_position; \n" + " v_texCoord = a_texCoord; \n" + "} \n"; + + char fShaderStr[] = + "#version 300 es \n" + "precision mediump float; \n" + "in vec2 v_texCoord; \n" + "layout(location = 0) out vec4 outColor; \n" + "uniform sampler2D s_texture; \n" + "void main() \n" + "{ \n" + " outColor = texture( s_texture, v_texCoord ); \n" + "} \n"; + + // Load the shaders and get a linked program object + drawTextureProgram = esLoadProgram ( vShaderStr, fShaderStr ); + + // Get the sampler location + drawTextureSamplerLocation = glGetUniformLocation ( drawTextureProgram, "s_texture" ); +} + +static void initGL() +{ + glViewport(0, 0, screenWidth, screenHeight); + + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glActiveTexture ( GL_TEXTURE0 ); + + loadShaders(); +} + +static void clearScreen() +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Always clear your scene before rendering, unless you're sure that you'll fill whole screen with textures/models etc +} + +struct Sprite { + + Sprite(const char * path) + { + w = h = texture = 0; + imagePath = path; + loadTexture(); + } + + bool loadTexture() + { + SDL_Surface *pic; + + pic = IMG_Load(imagePath.c_str()); + + if (!pic) + { + printf("Error: image %s cannot be loaded\n", imagePath.c_str()); + return false; + } + if (pic->format->BitsPerPixel != 32 && pic->format->BitsPerPixel != 24) + { + printf("Error: image %s is %dbpp - it should be either 24bpp or 32bpp, images with palette are not supported\n", imagePath.c_str(), pic->format->BitsPerPixel); + SDL_FreeSurface(pic); + return false; + } + + GLenum glFormat = (pic->format->BitsPerPixel == 32 ? GL_RGBA : GL_RGB); + w = pic->w; + h = pic->h; + // GLES3 always supports non-power-of-two textures, no need to recalculate texture dimensions + + glGenTextures(1, &texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, glFormat, w, h, 0, glFormat, GL_UNSIGNED_BYTE, pic->pixels); + SDL_FreeSurface(pic); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + disableRepeat(); + + return true; + } + + void disableRepeat() + { + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + + void enableRepeat() + { + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + } + + void enableMirroredRepeat() + { + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); + } + + void draw(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLfloat tex_x1 = 0.0f, GLfloat tex_y1 = 0.0f, GLfloat tex_x2 = 1.0f, GLfloat tex_y2 = 1.0f) + { + if (texture == 0) + return; + + glUseProgram( drawTextureProgram ); + + GLfloat coords[] = { + x, y, // Position 0 + tex_x1, tex_y1, // TexCoord 0 + x, y + width, // Position 1 + tex_x1, tex_y2, // TexCoord 1 + x + height, y + width, // Position 2 + tex_x2, tex_y2, // TexCoord 2 + x + height, y, // Position 3 + tex_x2, tex_y1 // TexCoord 3 + }; + + // Load the vertex position + glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof ( GLfloat ), coords ); + // Load the texture coordinate + glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof ( GLfloat ), &coords[2] ); + + glEnableVertexAttribArray( 0 ); + glEnableVertexAttribArray( 1 ); + + glActiveTexture( GL_TEXTURE0 ); + glBindTexture( GL_TEXTURE_2D, texture ); + + glUniform1i ( drawTextureSamplerLocation, 0 ); + + glDrawArrays ( GL_TRIANGLE_FAN, 0, 4 ); + } + + void draw(GLfloat x, GLfloat y) + { + draw(x, y, w, h); + } + + GLuint texture; + int w, h; + std::string imagePath; +}; + +int +main(int argc, char *argv[]) +{ + initSDL(); + initGL(); + + std::vector sprites; + sprites.push_back(Sprite("test.png")); + sprites.push_back(Sprite("element0.png")); + sprites.push_back(Sprite("element1.png")); + sprites.push_back(Sprite("element2.png")); + sprites.push_back(Sprite("element3.png")); + sprites.push_back(Sprite("stars.jpg")); + sprites.back().enableMirroredRepeat(); // Looks nice + + int coords[][2] = { {0, 0}, + {200, 0}, + {300, 200}, + {400, 300} }; + + float pulse = 1.0f, pulseChange = 0.01f; + int anim = 1; + + while ( ! SDL_GetKeyState(NULL)[SDLK_ESCAPE] ) // Exit by pressing Back button + { + // clearScreen(); // Do not clear screen, we will fill the screens with tiled background image instead + sprites[5].draw(0, 0, screenWidth, screenHeight, 0, 0, (float) screenWidth / sprites[5].w, (float) screenHeight / sprites[5].h); + + int mouseX = 0, mouseY = 0, buttons = 0; + buttons = SDL_GetMouseState(&mouseX, &mouseY); + sprites[0].draw(mouseX - sprites[0].w/2, mouseY - sprites[0].h/2); + + sprites[1].draw(coords[0][0], coords[0][1]); + sprites[2].draw(coords[1][0], coords[1][1], sprites[2].w * pulse * 4, sprites[2].h * pulse * 4); + sprites[3].draw(coords[2][0], coords[2][1], sprites[3].w * pulse * 4, sprites[3].h * 2); + sprites[4].draw(coords[3][0], coords[3][1], sprites[4].w, sprites[4].h * pulse * 2); + + SDL_GL_SwapBuffers(); + SDL_Event event; + while( SDL_PollEvent(&event) ) + { + if(event.type == SDL_VIDEORESIZE) + { + // GL context was destroyed - reload all textures + initGL(); + for(int i = 0; i < sprites.size(); i++) + sprites[i].loadTexture(); + } + + if(event.type == SDL_KEYUP || event.type == SDL_KEYDOWN) + { + __android_log_print(ANDROID_LOG_INFO, "Hello", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", event.type == SDL_KEYUP ? "UP " : "DOWN" , event.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym), (int)event.key.keysym.scancode, (int)event.key.keysym.mod, (int)event.key.keysym.unicode); + if(event.key.keysym.sym == SDLK_ESCAPE) + return 0; + } + } + + // Some kinda animation + + pulse += pulseChange; + if(pulse >= 1.0f) + pulseChange = -0.01f; + if(pulse <= 0) + pulseChange = 0.01f; + + for(int i = 0; i < 4; i++) + { + coords[i][0] += anim; + coords[i][1] += anim; + } + if( coords[0][0] < 0 ) + anim = 1; + if( coords[3][1] > screenHeight ) + anim = -1; + } + + SDL_Quit(); + return 0; +} diff --git a/project/jni/application/test-opengl/sdl_hello.cpp b/project/jni/application/test-opengl/sdl_hello.cpp index 914654359..f8c8d0698 100644 --- a/project/jni/application/test-opengl/sdl_hello.cpp +++ b/project/jni/application/test-opengl/sdl_hello.cpp @@ -185,53 +185,54 @@ main(int argc, char *argv[]) while ( ! SDL_GetKeyState(NULL)[SDLK_ESCAPE] ) // Exit by pressing Back button { - clearScreen(); - int mouseX = 0, mouseY = 0, buttons = 0; - buttons = SDL_GetMouseState(&mouseX, &mouseY); + clearScreen(); + int mouseX = 0, mouseY = 0, buttons = 0; + buttons = SDL_GetMouseState(&mouseX, &mouseY); - sprites[0].draw(mouseX - sprites[0].w/2, mouseY - sprites[0].h/2, sprites[0].w, sprites[0].h, buttons ? 0 : 1, 1, 1, pulse); + sprites[1].draw(coords[0][0], coords[0][1]); + sprites[2].draw(coords[1][0], coords[1][1], sprites[2].w * pulse * 4, sprites[2].h * pulse * 4); + sprites[3].draw(coords[2][0], coords[2][1], sprites[3].w * pulse * 4, sprites[3].h * 2); + sprites[4].draw(coords[3][0], coords[3][1], sprites[4].w, sprites[4].h * pulse * 2); + sprites[2].draw(coords[1][0] + 300, coords[1][1] + sprites[2].h * pulse * 3, sprites[2].w * 3, sprites[2].h * 3, pulse, pulse, 1.0f - pulse ); - sprites[1].draw(coords[0][0], coords[0][1]); - sprites[2].draw(coords[1][0], coords[1][1], sprites[2].w * pulse * 4, sprites[2].h * pulse * 4); - sprites[3].draw(coords[2][0], coords[2][1], sprites[3].w * pulse * 4, sprites[3].h * 2); - sprites[4].draw(coords[3][0], coords[3][1], sprites[4].w, sprites[4].h * pulse * 2); + sprites[0].draw(mouseX - sprites[0].w/2, mouseY - sprites[0].h/2, sprites[0].w, sprites[0].h, buttons ? 0 : 1, 1, 1, pulse); - SDL_GL_SwapBuffers(); - SDL_Event event; - while( SDL_PollEvent(&event) ) - { - if(event.type == SDL_VIDEORESIZE) + SDL_GL_SwapBuffers(); + SDL_Event event; + while( SDL_PollEvent(&event) ) { - // Reload textures to OpenGL - initGL(); - for(int i = 0; i < sprites.size(); i++) - sprites[i].loadTexture(); + if(event.type == SDL_VIDEORESIZE) + { + // Reload textures to OpenGL + initGL(); + for(int i = 0; i < sprites.size(); i++) + sprites[i].loadTexture(); + } + if(event.type == SDL_KEYUP || event.type == SDL_KEYDOWN) + { + __android_log_print(ANDROID_LOG_INFO, "Hello", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", event.type == SDL_KEYUP ? "UP " : "DOWN" , event.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym), (int)event.key.keysym.scancode, (int)event.key.keysym.mod, (int)event.key.keysym.unicode); + if(event.key.keysym.sym == SDLK_ESCAPE) + return 0; + } } - if(event.type == SDL_KEYUP || event.type == SDL_KEYDOWN) + + // Some kinda animation + + pulse += pulseChange; + if(pulse > 1.0f) + pulseChange = -0.01f; + if(pulse < 0) + pulseChange = 0.01f; + + for(int i = 0; i < 4; i++) { - __android_log_print(ANDROID_LOG_INFO, "Hello", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", event.type == SDL_KEYUP ? "UP " : "DOWN" , event.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym), (int)event.key.keysym.scancode, (int)event.key.keysym.mod, (int)event.key.keysym.unicode); - if(event.key.keysym.sym == SDLK_ESCAPE) - return 0; + coords[i][0] += anim; + coords[i][1] += anim; } - } - - // Some kinda animation - - pulse += pulseChange; - if(pulse > 1.0f) - pulseChange = -0.01f; - if(pulse < 0) - pulseChange = 0.01f; - - for(int i = 0; i < 4; i++) - { - coords[i][0] += anim; - coords[i][1] += anim; - } - if( coords[0][0] < 0 ) - anim = 1; - if( coords[3][1] > screenHeight ) - anim = -1; + if( coords[0][0] < 0 ) + anim = 1; + if( coords[3][1] > screenHeight ) + anim = -1; } SDL_Quit(); diff --git a/project/jni/sdl-1.2/Android.mk b/project/jni/sdl-1.2/Android.mk index 45eb2b10e..39526b85c 100644 --- a/project/jni/sdl-1.2/Android.mk +++ b/project/jni/sdl-1.2/Android.mk @@ -57,10 +57,10 @@ LOCAL_SRC_FILES := $(foreach F, $(SDL_SRCS), $(addprefix $(dir $(F)),$(notdir $( LOCAL_SHARED_LIBRARIES := sdl_native_helpers # Not really a dependency, needed for CustomBuildScript -ifdef USE_GLSHIM +ifdef USE_GLSHIM LOCAL_STATIC_LIBRARIES := glshim endif -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog +LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog include $(BUILD_SHARED_LIBRARY) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index 40252870a..c3bd23a40 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -43,8 +43,6 @@ If you compile this code with SDL 1.3 or newer, or use in some other way, the li #include #include -#include -#include #include #include #include @@ -61,6 +59,8 @@ If you compile this code with SDL 1.3 or newer, or use in some other way, the li #define DEBUGOUT(...) #endif +#include "SDL_opengles.h" + #ifdef USE_GLSHIM #include #endif @@ -493,8 +493,10 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, HwSurfaceList[HwSurfaceCount-1] = current; DEBUGOUT("ANDROID_SetVideoMode() HwSurfaceCount %d HwSurfaceList %p", HwSurfaceCount, HwSurfaceList); } +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 glViewport(0, 0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight); glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0, 0, 1); +#endif } /* Allocate the new pixel format for the screen */ @@ -1038,6 +1040,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects) SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, &dstrect); int buttons = SDL_GetMouseState(NULL, NULL); // Do it old-fashioned way with direct GL calls +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 glPushMatrix(); glLoadIdentity(); glOrthof( 0.0f, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight, 0.0f, 0.0f, 1.0f ); @@ -1051,6 +1054,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects) glDrawArrays(GL_LINE_LOOP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); +#endif } #ifdef VIDEO_DEBUG if( SDL_ANDROID_VideoDebugRect.w > 0 ) @@ -1206,8 +1210,10 @@ void SDL_ANDROID_VideoContextRecreated() SDL_PrivateAndroidSetDesktopMode(SDL_VideoWindow, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight); SDL_SelectRenderer(SDL_VideoWindow); // Re-apply glOrtho() and blend modes // Re-apply our custom 4:3 screen aspect ratio +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 glViewport(0, 0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight); glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sWindowHeight, 0, 0, 1); +#endif for( i = 0; i < HwSurfaceCount; i++ ) { // Allocate HW texture diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c index db8ff94fa..18117e5c0 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c @@ -27,14 +27,14 @@ If you compile this code with SDL 1.3 or newer, or use in some other way, the li #include #include -#include -#include #include #include #include #include #include // for memset() +#include "SDL_opengles.h" + #include "SDL_config.h" #include "SDL_version.h" @@ -124,7 +124,7 @@ static inline JNIEnv *GetJavaEnv(void) { JavaVM *vm = SDL_ANDROID_JavaVM(); JNIEnv *ret = NULL; - (*vm)->GetEnv(vm, &ret, JNI_VERSION_1_6); + (*vm)->GetEnv(vm, (void **) &ret, JNI_VERSION_1_6); return ret; } @@ -134,6 +134,7 @@ int SDL_ANDROID_CallJavaSwapBuffers() if( !glContextLost ) { // Clear part of screen not used by SDL - on Android the screen contains garbage after each frame +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 if( SDL_ANDROID_ForceClearScreenRectAmount > 0 ) { int i; @@ -157,7 +158,7 @@ int SDL_ANDROID_CallJavaSwapBuffers() glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); } - +#endif SDL_ANDROID_drawTouchscreenKeyboard(); } diff --git a/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h b/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h deleted file mode 100644 index d8dc79dd5..000000000 --- a/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h +++ /dev/null @@ -1,229 +0,0 @@ -/* list of OpenGL ES functions sorted alphabetically - If you need to use a GLES function from the SDL video subsystem, - change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. -*/ -#define SDL_PROC_UNUSED(ret,func,params) - -SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum func, GLclampf ref)) -SDL_PROC(void, glClearColor, - (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) -SDL_PROC_UNUSED(void, glClearDepthf, (GLclampf depth)) -SDL_PROC_UNUSED(void, glClipPlanef, (GLenum plane, const GLfloat * equation)) -SDL_PROC(void, glColor4f, - (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) -SDL_PROC_UNUSED(void, glDepthRangef, (GLclampf zNear, GLclampf zFar)) -SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glFrustumf, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar)) -SDL_PROC_UNUSED(void, glGetClipPlanef, (GLenum pname, GLfloat eqn[4])) -SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetLightfv, - (GLenum light, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetMaterialfv, - (GLenum face, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetTexEnvfv, - (GLenum env, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetTexParameterfv, - (GLenum target, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glLightfv, - (GLenum light, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width)) -SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glMaterialfv, - (GLenum face, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED(void, glMultiTexCoord4f, - (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)) -SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) -SDL_PROC(void, glOrthof, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar)) -SDL_PROC_UNUSED(void, glPointParameterf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glPointParameterfv, - (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glPointSize, (GLfloat size)) -SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) -SDL_PROC_UNUSED(void, glRotatef, - (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glTexEnvfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glTexParameterfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) - -/* Available in both Common and Common-Lite profiles */ -SDL_PROC_UNUSED(void, glActiveTexture, (GLenum texture)) -SDL_PROC_UNUSED(void, glAlphaFuncx, (GLenum func, GLclampx ref)) -SDL_PROC_UNUSED(void, glBindBuffer, (GLenum target, GLuint buffer)) -SDL_PROC(void, glBindTexture, (GLenum target, GLuint texture)) -SDL_PROC(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)) -SDL_PROC_UNUSED(void, glBufferData, - (GLenum target, GLsizeiptr size, const GLvoid * data, - GLenum usage)) -SDL_PROC_UNUSED(void, glBufferSubData, - (GLenum target, GLintptr offset, GLsizeiptr size, - const GLvoid * data)) -SDL_PROC(void, glClear, (GLbitfield mask)) -SDL_PROC_UNUSED(void, glClearColorx, - (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)) -SDL_PROC_UNUSED(void, glClearDepthx, (GLclampx depth)) -SDL_PROC_UNUSED(void, glClearStencil, (GLint s)) -SDL_PROC_UNUSED(void, glClientActiveTexture, (GLenum texture)) -SDL_PROC_UNUSED(void, glClipPlanex, (GLenum plane, const GLfixed * equation)) -SDL_PROC_UNUSED(void, glColor4ub, - (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) -SDL_PROC_UNUSED(void, glColor4x, - (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)) -SDL_PROC_UNUSED(void, glColorMask, - (GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha)) -SDL_PROC(void, glColorPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glCompressedTexImage2D, - (GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid * data)) -SDL_PROC_UNUSED(void, glCompressedTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid * data)) -SDL_PROC_UNUSED(void, glCopyTexImage2D, - (GLenum target, GLint level, GLenum internalformat, GLint x, - GLint y, GLsizei width, GLsizei height, GLint border)) -SDL_PROC_UNUSED(void, glCopyTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) -SDL_PROC_UNUSED(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers)) -SDL_PROC_UNUSED(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) -SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) -SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) -SDL_PROC_UNUSED(void, glDepthRangex, (GLclampx zNear, GLclampx zFar)) -SDL_PROC(void, glDisable, (GLenum cap)) -SDL_PROC(void, glDisableClientState, (GLenum array)) -SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) -SDL_PROC_UNUSED(void, glDrawElements, - (GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices)) -SDL_PROC(void, glEnable, (GLenum cap)) -SDL_PROC(void, glEnableClientState, (GLenum array)) -SDL_PROC_UNUSED(void, glFinish, (void)) -SDL_PROC_UNUSED(void, glFlush, (void)) -SDL_PROC_UNUSED(void, glFogx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glFogxv, (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) -SDL_PROC_UNUSED(void, glFrustumx, - (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar)) -SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) -SDL_PROC_UNUSED(void, glGetBufferParameteriv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetClipPlanex, (GLenum pname, GLfixed eqn[4])) -SDL_PROC_UNUSED(void, glGenBuffers, (GLsizei n, GLuint * buffers)) -SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) -SDL_PROC(GLenum, glGetError, (void)) -SDL_PROC_UNUSED(void, glGetFixedv, (GLenum pname, GLfixed * params)) -SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetLightxv, - (GLenum light, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetMaterialxv, - (GLenum face, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, void **params)) -SDL_PROC_UNUSED(const GLubyte *, glGetString, (GLenum name)) -SDL_PROC_UNUSED(void, glGetTexEnviv, - (GLenum env, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetTexEnvxv, - (GLenum env, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetTexParameteriv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetTexParameterxv, - (GLenum target, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) -SDL_PROC_UNUSED(GLboolean, glIsBuffer, (GLuint buffer)) -SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) -SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) -SDL_PROC_UNUSED(void, glLightModelx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glLightModelxv, (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glLightx, (GLenum light, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glLightxv, - (GLenum light, GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glLineWidthx, (GLfixed width)) -SDL_PROC(void, glLoadIdentity, (void)) -SDL_PROC_UNUSED(void, glLoadMatrixx, (const GLfixed * m)) -SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) -SDL_PROC_UNUSED(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glMaterialxv, - (GLenum face, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glMatrixMode, (GLenum mode)) -SDL_PROC_UNUSED(void, glMultMatrixx, (const GLfixed * m)) -SDL_PROC_UNUSED(void, glMultiTexCoord4x, - (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)) -SDL_PROC_UNUSED(void, glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz)) -SDL_PROC_UNUSED(void, glNormalPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glOrthox, - (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar)) -SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glPointParameterx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glPointParameterxv, - (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glPointSizex, (GLfixed size)) -SDL_PROC_UNUSED(void, glPolygonOffsetx, (GLfixed factor, GLfixed units)) -SDL_PROC_UNUSED(void, glPopMatrix, (void)) -SDL_PROC_UNUSED(void, glPushMatrix, (void)) -SDL_PROC_UNUSED(void, glReadPixels, - (GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels)) -SDL_PROC_UNUSED(void, glRotatex, - (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC_UNUSED(void, glSampleCoverage, (GLclampf value, GLboolean invert)) -SDL_PROC_UNUSED(void, glSampleCoveragex, (GLclampx value, GLboolean invert)) -SDL_PROC_UNUSED(void, glScalex, (GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode)) -SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) -SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) -SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) -SDL_PROC(void, glTexCoordPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glTexEnvx, (GLenum target, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glTexEnviv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED(void, glTexEnvxv, - (GLenum target, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glTexImage2D, - (GLenum target, GLint level, GLint internalformat, GLsizei width, - GLsizei height, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glTexParameterx, - (GLenum target, GLenum pname, GLfixed param)) -SDL_PROC(void, glTexParameteriv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED(void, glTexParameterxv, - (GLenum target, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC_UNUSED(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC(void, glVertexPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) - -/* extension functions used */ -SDL_PROC(void, glDrawTexiOES, - (GLint x, GLint y, GLint z, GLint width, GLint height)) - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_opengles.h b/project/jni/sdl-1.2/src/video/android/SDL_opengles.h index c42acf521..45e95c142 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_opengles.h +++ b/project/jni/sdl-1.2/src/video/android/SDL_opengles.h @@ -25,1020 +25,13 @@ falls under "stronger" LGPL terms, so is this file. If you compile this code with SDL 1.3 or newer, or use in some other way, the license stays ZLIB. */ -/** - * \file SDL_opengles.h - * - * This is a simple file to encapsulate the OpenGL ES API headers. - * - * Headers copied from The Kronos Group website. - * http://www.khronos.org/opengles/ - */ - -#ifndef __gles_h_ -#define __gles_h_ - -/* $Id: gl.h 4533 2007-11-26 11:19:35Z markc $ */ - -#ifdef __cplusplus -extern "C" -{ +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 +#include +#include #endif - -#ifdef __IPHONEOS__ -#include /* Header File For The OpenGL ES Library */ +#if SDL_VIDEO_OPENGL_ES_VERSION == 2 +#include #endif - -#ifndef APIENTRY -#define APIENTRY +#if SDL_VIDEO_OPENGL_ES_VERSION == 3 +#include #endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY -#endif - -#ifndef GL_API -#define GL_API -#endif /* GL_API */ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.0 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -*/ - - typedef unsigned int GLenum; - typedef unsigned char GLboolean; - typedef unsigned int GLbitfield; - typedef signed char GLbyte; - typedef short GLshort; - typedef int GLint; - typedef int GLsizei; - typedef unsigned char GLubyte; - typedef unsigned short GLushort; - typedef unsigned int GLuint; - typedef float GLfloat; - typedef float GLclampf; - typedef void GLvoid; - typedef int GLfixed; - typedef int GLclampx; - - typedef int GLintptr; - typedef int GLsizeiptr; - - -/*************************************************************/ - -/* OpenGL ES core versions */ -#define GL_VERSION_ES_CM_1_0 1 -#define GL_VERSION_ES_CL_1_0 1 -#define GL_VERSION_ES_CM_1_1 1 -#define GL_VERSION_ES_CL_1_1 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* ColorMaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_UNSIGNED_BYTE */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_FOG 0x0B60 -#define GL_LIGHTING 0x0B50 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_BLEND 0x0BE2 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -#define GL_POINT_SMOOTH 0x0B10 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_NORMALIZE 0x0BA1 -#define GL_RESCALE_NORMAL 0x803A -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - -/* FogParameter */ -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_LINE_WIDTH 0x0B21 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_SHADE_MODEL 0x0B54 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* OpenGL ES 1.0 defines, they gone in 1.1 and 2.0 */ -#ifndef GL_MAX_ELEMENTS_VERTICES -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#endif /* GL_MAX_ELEMENTS_VERTICES */ -#ifndef GL_MAX_ELEMENTS_INDICES -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#endif /* GL_MAX_ELEMENTS_INDICES */ - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_FOG_HINT 0x0C54 -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* LightModelParameter */ -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* PixelFormat */ -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelStoreParameter */ -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -#define GL_ADD 0x0104 -/* GL_REPLACE */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_GENERATE_MIPMAP 0x8191 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 - -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A - -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -/* Texture combine + dot3 */ -#define GL_SUBTRACT 0x84E7 -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A - -#define GL_ALPHA_SCALE 0x0D1C - -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 -#define GL_SRC2_ALPHA 0x858A - -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF - -/*------------------------------------------------------------------------* - * required OES extension tokens - *------------------------------------------------------------------------*/ - -/* OES_read_format */ -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_POINT_SPRITE_OES 0x8861 -#define GL_COORD_REPLACE_OES 0x8862 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif /* GL_OES_draw_texture */ - -/* GL_OES_vertex_buffer_object */ -#ifndef GL_OES_vertex_buffer_object -#define GL_ARRAY_BUFFER_OES 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_OES 0x8893 -#define GL_ARRAY_BUFFER_BINDING_OES 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_OES 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_OES 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_OES 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_OES 0x8898 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_OES 0x889A -#define GL_STATIC_DRAW_OES 0x88E4 -#define GL_DYNAMIC_DRAW_OES 0x88E8 -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_SIZE_OES 0x8764 -#define GL_BUFFER_USAGE_OES 0x8765 -#define GL_BUFFER_ACCESS_OES 0x88BB -#endif /* GL_OES_vertex_buffer_object */ - -/*************************************************************/ - -/* Available only in Common profile */ - GL_API void GL_APIENTRY glAlphaFunc(GLenum func, GLclampf ref); - GL_API void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha); - GL_API void GL_APIENTRY glClearDepthf(GLclampf depth); - GL_API void GL_APIENTRY glClipPlanef(GLenum plane, - const GLfloat * equation); - GL_API void GL_APIENTRY glColor4f(GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha); - GL_API void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar); - GL_API void GL_APIENTRY glFogf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glFogfv(GLenum pname, const GLfloat * params); - GL_API void GL_APIENTRY glFrustumf(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glGetClipPlanef(GLenum pname, GLfloat eqn[4]); - GL_API void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat * params); - GL_API void GL_APIENTRY glGetLightfv(GLenum light, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetMaterialfv(GLenum face, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetTexEnvfv(GLenum env, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glLightModelf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glLightModelfv(GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glLightf(GLenum light, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glLightfv(GLenum light, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glLineWidth(GLfloat width); - GL_API void GL_APIENTRY glLoadMatrixf(const GLfloat * m); - GL_API void GL_APIENTRY glMaterialf(GLenum face, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glMaterialfv(GLenum face, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glMultMatrixf(const GLfloat * m); - GL_API void GL_APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s, - GLfloat t, GLfloat r, - GLfloat q); - GL_API void GL_APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); - GL_API void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glPointParameterf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glPointParameterfv(GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glPointSize(GLfloat size); - GL_API void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); - GL_API void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, - GLfloat z); - GL_API void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z); - GL_API void GL_APIENTRY glTexEnvf(GLenum target, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glTexEnvfv(GLenum target, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z); - -/* Available in both Common and Common-Lite profiles */ - GL_API void GL_APIENTRY glActiveTexture(GLenum texture); - GL_API void GL_APIENTRY glAlphaFuncx(GLenum func, GLclampx ref); - GL_API void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); - GL_API void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); - GL_API void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); - GL_API void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, - const GLvoid * data, GLenum usage); - GL_API void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, - GLsizeiptr size, - const GLvoid * data); - GL_API void GL_APIENTRY glClear(GLbitfield mask); - GL_API void GL_APIENTRY glClearColorx(GLclampx red, GLclampx green, - GLclampx blue, GLclampx alpha); - GL_API void GL_APIENTRY glClearDepthx(GLclampx depth); - GL_API void GL_APIENTRY glClearStencil(GLint s); - GL_API void GL_APIENTRY glClientActiveTexture(GLenum texture); - GL_API void GL_APIENTRY glClipPlanex(GLenum plane, - const GLfixed * equation); - GL_API void GL_APIENTRY glColor4ub(GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha); - GL_API void GL_APIENTRY glColor4x(GLfixed red, GLfixed green, - GLfixed blue, GLfixed alpha); - GL_API void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha); - GL_API void GL_APIENTRY glColorPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const GLvoid * data); - GL_API void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const GLvoid * data); - GL_API void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLint x, - GLint y, GLsizei width, - GLsizei height, GLint border); - GL_API void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, - GLsizei height); - GL_API void GL_APIENTRY glCullFace(GLenum mode); - GL_API void GL_APIENTRY glDeleteBuffers(GLsizei n, - const GLuint * buffers); - GL_API void GL_APIENTRY glDeleteTextures(GLsizei n, - const GLuint * textures); - GL_API void GL_APIENTRY glDepthFunc(GLenum func); - GL_API void GL_APIENTRY glDepthMask(GLboolean flag); - GL_API void GL_APIENTRY glDepthRangex(GLclampx zNear, GLclampx zFar); - GL_API void GL_APIENTRY glDisable(GLenum cap); - GL_API void GL_APIENTRY glDisableClientState(GLenum array); - GL_API void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, - GLsizei count); - GL_API void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, - GLenum type, - const GLvoid * indices); - GL_API void GL_APIENTRY glEnable(GLenum cap); - GL_API void GL_APIENTRY glEnableClientState(GLenum array); - GL_API void GL_APIENTRY glFinish(void); - GL_API void GL_APIENTRY glFlush(void); - GL_API void GL_APIENTRY glFogx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glFogxv(GLenum pname, const GLfixed * params); - GL_API void GL_APIENTRY glFrontFace(GLenum mode); - GL_API void GL_APIENTRY glFrustumx(GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar); - GL_API void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean * params); - GL_API void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetClipPlanex(GLenum pname, GLfixed eqn[4]); - GL_API void GL_APIENTRY glGenBuffers(GLsizei n, GLuint * buffers); - GL_API void GL_APIENTRY glGenTextures(GLsizei n, GLuint * textures); - GL_API GLenum GL_APIENTRY glGetError(void); - GL_API void GL_APIENTRY glGetFixedv(GLenum pname, GLfixed * params); - GL_API void GL_APIENTRY glGetIntegerv(GLenum pname, GLint * params); - GL_API void GL_APIENTRY glGetLightxv(GLenum light, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetMaterialxv(GLenum face, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetPointerv(GLenum pname, void **params); - GL_API const GLubyte *GL_APIENTRY glGetString(GLenum name); - GL_API void GL_APIENTRY glGetTexEnviv(GLenum env, GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetTexEnvxv(GLenum env, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetTexParameterxv(GLenum target, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glHint(GLenum target, GLenum mode); - GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); - GL_API GLboolean GL_APIENTRY glIsEnabled(GLenum cap); - GL_API GLboolean GL_APIENTRY glIsTexture(GLuint texture); - GL_API void GL_APIENTRY glLightModelx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glLightModelxv(GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glLightx(GLenum light, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glLightxv(GLenum light, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glLineWidthx(GLfixed width); - GL_API void GL_APIENTRY glLoadIdentity(void); - GL_API void GL_APIENTRY glLoadMatrixx(const GLfixed * m); - GL_API void GL_APIENTRY glLogicOp(GLenum opcode); - GL_API void GL_APIENTRY glMaterialx(GLenum face, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glMatrixMode(GLenum mode); - GL_API void GL_APIENTRY glMultMatrixx(const GLfixed * m); - GL_API void GL_APIENTRY glMultiTexCoord4x(GLenum target, GLfixed s, - GLfixed t, GLfixed r, - GLfixed q); - GL_API void GL_APIENTRY glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz); - GL_API void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar); - GL_API void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); - GL_API void GL_APIENTRY glPointParameterx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glPointParameterxv(GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glPointSizex(GLfixed size); - GL_API void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units); - GL_API void GL_APIENTRY glPopMatrix(void); - GL_API void GL_APIENTRY glPushMatrix(void); - GL_API void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, - GLsizei height, GLenum format, - GLenum type, GLvoid * pixels); - GL_API void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, - GLfixed z); - GL_API void GL_APIENTRY glSampleCoverage(GLclampf value, - GLboolean invert); - GL_API void GL_APIENTRY glSampleCoveragex(GLclampx value, - GLboolean invert); - GL_API void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z); - GL_API void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, - GLsizei height); - GL_API void GL_APIENTRY glShadeModel(GLenum mode); - GL_API void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, - GLuint mask); - GL_API void GL_APIENTRY glStencilMask(GLuint mask); - GL_API void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, - GLenum zpass); - GL_API void GL_APIENTRY glTexCoordPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glTexEnvi(GLenum target, GLenum pname, - GLint param); - GL_API void GL_APIENTRY glTexEnvx(GLenum target, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glTexEnviv(GLenum target, GLenum pname, - const GLint * params); - GL_API void GL_APIENTRY glTexEnvxv(GLenum target, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glTexImage2D(GLenum target, GLint level, - GLint internalformat, GLsizei width, - GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid * pixels); - GL_API void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, - GLint param); - GL_API void GL_APIENTRY glTexParameterx(GLenum target, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, - const GLint * params); - GL_API void GL_APIENTRY glTexParameterxv(GLenum target, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid * pixels); - GL_API void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z); - GL_API void GL_APIENTRY glVertexPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, - GLsizei height); - -/*------------------------------------------------------------------------* - * Required OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_read_format */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_OES_point_size_array 1 - GL_API void GL_APIENTRY glPointSizePointerOES(GLenum type, GLsizei stride, - const GLvoid * pointer); -#endif - -/* GL_OES_query_matrix */ -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 - GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16], - GLint exponent[16]); -#endif /* GL_OES_query_matrix */ - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_OES_point_sprite 1 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_OES_draw_texture 1 - GL_API void GL_APIENTRY glDrawTexsOES(GLshort x, GLshort y, GLshort z, - GLshort width, GLshort height); - GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z, - GLint width, GLint height); - GL_API void GL_APIENTRY glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, - GLfixed width, GLfixed height); - GL_API void GL_APIENTRY glDrawTexsvOES(const GLshort * coords); - GL_API void GL_APIENTRY glDrawTexivOES(const GLint * coords); - GL_API void GL_APIENTRY glDrawTexxvOES(const GLfixed * coords); - GL_API void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height); - GL_API void GL_APIENTRY glDrawTexfvOES(const GLfloat * coords); -#endif /* GL_OES_draw_texture */ - -/* GL_OES_single_precision */ -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 - GL_API void GL_APIENTRY glDepthRangefOES(GLclampf zNear, GLclampf zFar); - GL_API void GL_APIENTRY glFrustumfOES(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glOrthofOES(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glClipPlanefOES(GLenum plane, - const GLfloat * equation); - GL_API void GL_APIENTRY glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]); - GL_API void GL_APIENTRY glClearDepthfOES(GLclampf depth); -#endif /* GL_OES_single_precision */ - -/* GL_OES_vertex_buffer_object */ -#ifndef GL_OES_vertex_buffer_object -#define GL_OES_vertex_buffer_object 1 - GL_API void APIENTRY glBindBufferOES(GLenum, GLuint); - GL_API void APIENTRY glDeleteBuffersOES(GLsizei, const GLuint *); - GL_API void APIENTRY glGenBuffersOES(GLsizei, GLuint *); - GL_API GLboolean APIENTRY glIsBufferOES(GLuint); - GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *, - GLenum); - GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr, - const GLvoid *); - GL_API void APIENTRY glGetBufferParameterivOES(GLenum, GLenum, GLint *); -#endif /* GL_OES_vertex_buffer_object */ - -#ifdef __cplusplus -} -#endif - -#endif /* __gles_h_ */ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c index 3db4aeb2c..2f2586997 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c @@ -158,9 +158,6 @@ typedef struct SDL_bool GL_OES_draw_texture_supported; /* OpenGL ES functions */ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#include "SDL_glesfuncs.h" -#undef SDL_PROC } GLES_RenderData; @@ -195,12 +192,6 @@ GLES_SetError(const char *prefix, GLenum result) case GL_INVALID_OPERATION: error = "GL_INVALID_OPERATION"; break; - case GL_STACK_OVERFLOW: - error = "GL_STACK_OVERFLOW"; - break; - case GL_STACK_UNDERFLOW: - error = "GL_STACK_UNDERFLOW"; - break; case GL_OUT_OF_MEMORY: error = "GL_OUT_OF_MEMORY"; break; @@ -214,12 +205,6 @@ GLES_SetError(const char *prefix, GLenum result) static int GLES_LoadFunctions(GLES_RenderData * data) { - -#define SDL_PROC(ret,func,params) \ - data->func = func; -#include "SDL_glesfuncs.h" -#undef SDL_PROC - return 0; } @@ -342,15 +327,15 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) #endif #endif - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_width = value; - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_height = value; /* Set up parameters for rendering */ data->blendMode = -1; - data->glDisable(GL_DEPTH_TEST); - data->glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); data->updateSize = SDL_TRUE; return renderer; @@ -359,7 +344,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) static int GLES_ActivateRenderer(SDL_Renderer * renderer) { - +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; SDL_Window *window = renderer->window; @@ -369,26 +354,27 @@ GLES_ActivateRenderer(SDL_Renderer * renderer) /* Set up parameters for rendering */ data->blendMode = -1; - data->glDisable(GL_DEPTH_TEST); - data->glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); data->updateSize = SDL_TRUE; if (data->updateSize) { - data->glMatrixMode(GL_PROJECTION); - data->glLoadIdentity(); - data->glMatrixMode(GL_MODELVIEW); - data->glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); #if SDL_VIDEO_RENDER_RESIZE - data->glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h); - data->glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h, + glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h); + glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h, 0.0, 0.0, 1.0); #else - data->glViewport(0, 0, window->w, window->h); - data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, + glViewport(0, 0, window->w, window->h); + glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0, 0.0, 1.0); #endif data->updateSize = SDL_FALSE; } +#endif return 0; } @@ -475,9 +461,9 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) texture->driverdata = data; - renderdata->glGetError(); - renderdata->glEnable(GL_TEXTURE_2D); - renderdata->glGenTextures(1, &data->texture); + glGetError(); + glEnable(GL_TEXTURE_2D); + glGenTextures(1, &data->texture); data->type = GL_TEXTURE_2D; /* no NPOV textures allowed in OpenGL ES (yet) */ @@ -491,21 +477,21 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) data->format = format; data->formattype = type; - renderdata->glBindTexture(data->type, data->texture); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + glBindTexture(data->type, data->texture); + glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + glTexImage2D(data->type, 0, internalFormat, texture_w, texture_h, 0, format, type, NULL); - renderdata->glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); - result = renderdata->glGetError(); + result = glGetError(); if (result != GL_NO_ERROR) { GLES_SetError("glTexImage2D()", result); return -1; @@ -545,8 +531,8 @@ SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture, int pitch) { GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - renderdata->glBindTexture(data->type, data->texture); - renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glBindTexture(data->type, data->texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } static int @@ -609,8 +595,8 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, void * temp_ptr; int i; - renderdata->glGetError(); - renderdata->glEnable(data->type); + glGetError(); + glEnable(data->type); SetupTextureUpdate(renderdata, texture, pitch); if( rect->w * bpp == pitch ) { @@ -626,7 +612,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } } - renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, rect->h, data->format, data->formattype, temp_buffer); @@ -634,8 +620,8 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, SDL_free(temp_buffer); } - renderdata->glDisable(data->type); - result = renderdata->glGetError(); + glDisable(data->type); + result = glGetError(); if (result != GL_NO_ERROR) { GLES_SetError("glTexSubImage2D()", result); return -1; @@ -681,52 +667,55 @@ GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, static void GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 if (blendMode != data->blendMode) { switch (blendMode) { case SDL_BLENDMODE_NONE: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glDisable(GL_BLEND); break; case SDL_BLENDMODE_MASK: if (isprimitive) { - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glDisable(GL_BLEND); /* The same as SDL_BLENDMODE_NONE */ blendMode = SDL_BLENDMODE_NONE; break; } /* fall through */ case SDL_BLENDMODE_BLEND: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; case SDL_BLENDMODE_ADD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; case SDL_BLENDMODE_MOD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_SRC_COLOR); break; } data->blendMode = blendMode; } +#endif } static int GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; GLES_SetBlendMode(data, renderer->blendMode, 1); - data->glColor4f((GLfloat) renderer->r * inv255f, + glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); @@ -736,12 +725,12 @@ GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, vertices[2*i+0] = (GLshort)points[i].x; vertices[2*i+1] = (GLshort)points[i].y; } - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); - data->glDrawArrays(GL_POINTS, 0, count); - data->glDisableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_SHORT, 0, vertices); + glEnableClientState(GL_VERTEX_ARRAY); + glDrawArrays(GL_POINTS, 0, count); + glDisableClientState(GL_VERTEX_ARRAY); SDL_stack_free(vertices); - +#endif return 0; } @@ -749,13 +738,14 @@ static int GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; GLES_SetBlendMode(data, renderer->blendMode, 1); - data->glColor4f((GLfloat) renderer->r * inv255f, + glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); @@ -765,19 +755,19 @@ GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, vertices[2*i+0] = (GLshort)points[i].x; vertices[2*i+1] = (GLshort)points[i].y; } - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_SHORT, 0, vertices); + glEnableClientState(GL_VERTEX_ARRAY); if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { /* GL_LINE_LOOP takes care of the final segment */ --count; - data->glDrawArrays(GL_LINE_LOOP, 0, count); + glDrawArrays(GL_LINE_LOOP, 0, count); } else { - data->glDrawArrays(GL_LINE_STRIP, 0, count); + glDrawArrays(GL_LINE_STRIP, 0, count); } - data->glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); SDL_stack_free(vertices); - +#endif return 0; } @@ -785,17 +775,18 @@ static int GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLES_SetBlendMode(data, renderer->blendMode, 1); - data->glColor4f((GLfloat) renderer->r * inv255f, + glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); - data->glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); for (i = 0; i < count; ++i) { const SDL_Rect *rect = rects[i]; GLshort minx = rect->x; @@ -812,11 +803,11 @@ GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[6] = maxx; vertices[7] = maxy; - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glDrawArrays(GL_LINE_LOOP, 0, 4); + glVertexPointer(2, GL_SHORT, 0, vertices); + glDrawArrays(GL_LINE_LOOP, 0, 4); } - data->glDisableClientState(GL_VERTEX_ARRAY); - + glDisableClientState(GL_VERTEX_ARRAY); +#endif return 0; } @@ -824,17 +815,18 @@ static int GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLES_SetBlendMode(data, renderer->blendMode, 1); - data->glColor4f((GLfloat) renderer->r * inv255f, + glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); - data->glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); for (i = 0; i < count; ++i) { const SDL_Rect *rect = rects[i]; GLshort minx = rect->x; @@ -851,11 +843,11 @@ GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[6] = maxx; vertices[7] = maxy; - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glVertexPointer(2, GL_SHORT, 0, vertices); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - data->glDisableClientState(GL_VERTEX_ARRAY); - + glDisableClientState(GL_VERTEX_ARRAY); +#endif return 0; } @@ -863,7 +855,7 @@ static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { - +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; int minx, miny, maxx, maxy; @@ -872,7 +864,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, void *temp_buffer; /* used for reformatting dirty rect pixels */ void *temp_ptr; - data->glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); if (texturedata->dirty.list) { SDL_DirtyRect *dirty; @@ -882,7 +874,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, SetupTextureUpdate(data, texture, pitch); - data->glBindTexture(texturedata->type, texturedata->texture); + glBindTexture(texturedata->type, texturedata->texture); for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { SDL_Rect *rect = &dirty->rect; pixels = @@ -906,7 +898,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, } } - data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, + glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, rect->w, rect->h, texturedata->format, texturedata->formattype, temp_buffer); @@ -917,15 +909,15 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ClearDirtyRects(&texturedata->dirty); } - data->glBindTexture(texturedata->type, texturedata->texture); + glBindTexture(texturedata->type, texturedata->texture); if (texture->modMode) { - data->glColor4f((GLfloat) texture->r * inv255f, + glColor4f((GLfloat) texture->r * inv255f, (GLfloat) texture->g * inv255f, (GLfloat) texture->b * inv255f, (GLfloat) texture->a * inv255f); } else { - data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } GLES_SetBlendMode(data, texture->blendMode, 0); @@ -933,16 +925,16 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, switch (texture->scaleMode) { case SDL_SCALEMODE_NONE: case SDL_SCALEMODE_FAST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, + glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, + glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); break; case SDL_SCALEMODE_SLOW: case SDL_SCALEMODE_BEST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, + glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, + glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, GL_LINEAR); break; } @@ -955,10 +947,10 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, cropRect[1] = srcrect->y + srcrect->h; cropRect[2] = srcrect->w; cropRect[3] = -srcrect->h; - data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); //__android_log_print(ANDROID_LOG_INFO, "libSDL", "GLES_RenderCopy glDrawTexiOES(%d, %d, %d, %d) cropRect %d:%d:%d:%d", dstrect->x, window->display->desktop_mode.h - dstrect->y - dstrect->h, dstrect->w, dstrect->h, cropRect[0], cropRect[1], cropRect[2], cropRect[3]); - data->glDrawTexiOES(dstrect->x, + glDrawTexiOES(dstrect->x, #if SDL_VIDEO_RENDER_RESIZE window->display->desktop_mode.h - dstrect->y - dstrect->h, #else @@ -1002,17 +994,17 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, texCoords[6] = maxu; texCoords[7] = maxv; - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); - data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); - data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); - data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); - data->glDisableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_SHORT, 0, vertices); + glEnableClientState(GL_VERTEX_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); } - data->glDisable(GL_TEXTURE_2D); - + glDisable(GL_TEXTURE_2D); +#endif return 0; } diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c index 944f78948..7e34379ff 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c @@ -32,15 +32,14 @@ If you compile this code with SDL 1.3 or newer, or use in some other way, the li #include #include #include // for memset() -#include -#include #include +#include "SDL_opengles.h" + #include "SDL_config.h" #include "SDL_version.h" -//#include "SDL_opengles.h" #include "SDL_screenkeyboard.h" #include "../SDL_sysvideo.h" #include "SDL_androidvideo.h" @@ -153,6 +152,8 @@ oldGlState; static inline void beginDrawingTex() { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 + #ifndef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE // Make the video somehow work on emulator oldGlState.texture2d = GL_TRUE; @@ -170,7 +171,6 @@ static inline void beginDrawingTex() // However GLES 1.1 spec defines all theese values, so it's a device fault for not implementing them oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D); glGetIntegerv(GL_ACTIVE_TEXTURE, &oldGlState.texunitId); - glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &oldGlState.clientTexunitId); #endif //R_DumpOpenGlState(); @@ -186,7 +186,6 @@ static inline void beginDrawingTex() */ glActiveTexture(GL_TEXTURE0); - glClientActiveTexture(GL_TEXTURE0); #ifdef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId); @@ -195,15 +194,15 @@ static inline void beginDrawingTex() oldGlState.blend = glIsEnabled(GL_BLEND); glGetIntegerv(GL_BLEND_SRC, &oldGlState.blend1); glGetIntegerv(GL_BLEND_DST, &oldGlState.blend2); - glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray); + //glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray); // It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it #endif + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glDisable(GL_CULL_FACE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisableClientState(GL_COLOR_ARRAY); //static const GLfloat color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; //glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); @@ -213,27 +212,31 @@ static inline void beginDrawingTex() //glDisableClientState(GL_NORMAL_ARRAY); //glDisableClientState(GL_VERTEX_ARRAY); //glDisableClientState(GL_TEXTURE_COORD_ARRAY); +#endif } static inline void endDrawingTex() { // Restore OpenGL state - if( oldGlState.texture2d == GL_FALSE ) - glDisable(GL_TEXTURE_2D); +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 glBindTexture(GL_TEXTURE_2D, oldGlState.textureId); - glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode); if( oldGlState.blend == GL_FALSE ) glDisable(GL_BLEND); glBlendFunc(oldGlState.blend1, oldGlState.blend2); glActiveTexture(oldGlState.texunitId); - glClientActiveTexture(oldGlState.clientTexunitId); + + if( oldGlState.texture2d == GL_FALSE ) + glDisable(GL_TEXTURE_2D); + glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode); if( oldGlState.colorArray ) glEnableClientState(GL_COLOR_ARRAY); +#endif } static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, float r, float g, float b, float a) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 GLint cropRect[4]; if( !dest->h || !dest->w ) @@ -269,6 +272,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * } glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); glDrawTexiOES(dest->x + SDL_ANDROID_ScreenVisibleRect.x, SDL_ANDROID_sRealWindowHeight - dest->y - dest->h - SDL_ANDROID_ScreenVisibleRect.y, 0, dest->w, dest->h); +#endif } static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, float r, float g, float b, float a) @@ -1336,6 +1340,7 @@ extern DECLSPEC int SDL_ANDROID_ScreenKeyboardUpdateToNewVideoMode(int oldx, int */ void R_DumpOpenGlState(void) { +#if SDL_VIDEO_OPENGL_ES_VERSION == 1 #define CAPABILITY( X ) {GL_ ## X, # X} /* List taken from here: http://www.khronos.org/opengles/sdk/1.1/docs/man/glIsEnabled.xml */ const struct { GLenum idx; const char * text; } openGLCaps[] = { @@ -1423,4 +1428,5 @@ void R_DumpOpenGlState(void) glActiveTexture(activeTexUnit); glClientActiveTexture(activeClientTexUnit); +#endif } diff --git a/project/jni/sdl-1.2/src/video/android/SDL_video.c b/project/jni/sdl-1.2/src/video/android/SDL_video.c index 1b81368da..1ddb9740c 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_video.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_video.c @@ -3184,7 +3184,6 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) { #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES - const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); const char *extensions; const char *start; const char *where, *terminator; @@ -3200,12 +3199,7 @@ SDL_GL_ExtensionSupported(const char *extension) return SDL_FALSE; } /* Lookup the available extensions */ - glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc) { - extensions = (const char *) glGetStringFunc(GL_EXTENSIONS); - } else { - extensions = NULL; - } + extensions = (const char *) glGetString(GL_EXTENSIONS); if (!extensions) { return SDL_FALSE; }