Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added texture type OES #914

Merged
merged 14 commits into from Nov 2, 2018
5 changes: 5 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,5 @@
{
paroj marked this conversation as resolved.
Show resolved Hide resolved
"files.associations": {
"vector": "cpp"
}
}
1 change: 1 addition & 0 deletions CMake/Templates/AndroidManifest.xml.in
Expand Up @@ -5,6 +5,7 @@
android:versionName="@OGRE_VERSION@"
android:installLocation="auto">

<uses-permission android:name="android.permission.CAMERA" />
paroj marked this conversation as resolved.
Show resolved Hide resolved
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />

<application android:label="@ANDROID_MOD_NAME@" android:icon="@drawable/ic_launcher" android:hasCode="@HAS_CODE@">
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -224,6 +224,7 @@ elseif (ANDROID)
set(OGRE_PLATFORM OGRE_PLATFORM_ANDROID)
set(OGRE_CONFIG_ENABLE_VIEWPORT_ORIENTATIONMODE FALSE CACHE BOOL "Disable viewport orientation Android" FORCE)
option(OGRE_BUILD_ANDROID_JNI_SAMPLE "Enable JNI Sample" FALSE)
option(OGRE_BUILD_ANDROID_TEXTURE_OES_SAMPLE "Enable OES Texture Sample" FALSE)

set(OGRE_BUILD_RENDERSYSTEM_GLES2 TRUE CACHE BOOL "Forcing OpenGL ES 2 RenderSystem for Android" FORCE)

Expand Down
6 changes: 3 additions & 3 deletions Components/Java/CMakeLists.txt
Expand Up @@ -29,15 +29,15 @@ else()
add_definitions(-Wno-strict-aliasing -Wno-cast-qual -Wno-shadow -Wno-missing-declarations)
endif()

set(CMAKE_SWIG_FLAGS -w401,314 -package org.Ogre)
set(CMAKE_SWIG_FLAGS -w401,314 -package org.ogre)

if (APPLE AND NOT ANDROID)
# we are using libc++ on OSX
list(APPEND CMAKE_SWIG_FLAGS -D_LIBCPP_VERSION)
endif()

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OGRE_BINARY_DIR}/java/libs")
set(CMAKE_SWIG_OUTDIR "${OGRE_BINARY_DIR}/java/src/org/Ogre")
set(CMAKE_SWIG_OUTDIR "${OGRE_BINARY_DIR}/java/src/org/ogre")

if(ANDROID)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ANDROID_NDK_ABI_NAME}")
Expand Down Expand Up @@ -79,7 +79,7 @@ if(${Java_FOUND})
set(JAR_NAME "${OGRE_BINARY_DIR}/java/Ogre-${OGRE_VERSION}.jar")
file(MAKE_DIRECTORY ${CLASS_OUTPUT_PATH})
add_custom_command(TARGET ${SWIG_MODULE_OgreJNI_REAL_NAME} POST_BUILD
COMMAND "${Java_JAVAC_EXECUTABLE}" -d ${CLASS_OUTPUT_PATH} "${OGRE_BINARY_DIR}/java/src/org/Ogre/*.java"
COMMAND "${Java_JAVAC_EXECUTABLE}" -d ${CLASS_OUTPUT_PATH} "${OGRE_BINARY_DIR}/java/src/org/ogre/*.java"
COMMAND "${Java_JAR_EXECUTABLE}" cf ${JAR_NAME} -C ${CLASS_OUTPUT_PATH} .
)
endif()
Expand Down
3 changes: 3 additions & 0 deletions Components/RTShaderSystem/src/OgreShaderFFPTexturing.cpp
Expand Up @@ -881,6 +881,9 @@ void FFPTexturing::setTextureUnit(unsigned short index, TextureUnitState* textur
curParams.mTextureSamplerType = GCT_SAMPLERRECT;
curParams.mVSInTextureCoordinateType = GCT_FLOAT2;
break;
case TEX_TYPE_EXTERNAL_OES:
curParams.mTextureSamplerType = GCT_SAMPLER_EXTERNAL_OES;
curParams.mVSInTextureCoordinateType = GCT_FLOAT2;
paroj marked this conversation as resolved.
Show resolved Hide resolved
case TEX_TYPE_2D_ARRAY:
curParams.mTextureSamplerType = GCT_SAMPLER2DARRAY;
curParams.mVSInTextureCoordinateType = GCT_FLOAT3;
Expand Down
Expand Up @@ -60,6 +60,7 @@ void GLSLProgramWriter::initializeStringMaps()
mGpuConstTypeMap[GCT_SAMPLERCUBE] = "samplerCube";
mGpuConstTypeMap[GCT_SAMPLER1DSHADOW] = "sampler1DShadow";
mGpuConstTypeMap[GCT_SAMPLER2DSHADOW] = "sampler2DShadow";
mGpuConstTypeMap[GCT_SAMPLER_EXTERNAL_OES] = "samplerExternalOES";
paroj marked this conversation as resolved.
Show resolved Hide resolved
mGpuConstTypeMap[GCT_MATRIX_2X2] = "mat2";
mGpuConstTypeMap[GCT_MATRIX_2X3] = "mat2x3";
mGpuConstTypeMap[GCT_MATRIX_2X4] = "mat2x4";
Expand Down
1 change: 1 addition & 0 deletions OgreMain/include/OgreGpuProgramParams.h
Expand Up @@ -78,6 +78,7 @@ namespace Ogre {
GCT_SAMPLER1DSHADOW = BCT_SAMPLER + 6,
GCT_SAMPLER2DSHADOW = BCT_SAMPLER + 7,
GCT_SAMPLER2DARRAY = BCT_SAMPLER + 8,
GCT_SAMPLER_EXTERNAL_OES = BCT_SAMPLER + 9,
GCT_MATRIX_2X2 = BCT_FLOAT + 5,
GCT_MATRIX_2X3 = BCT_FLOAT + 6,
GCT_MATRIX_2X4 = BCT_FLOAT + 7,
Expand Down
4 changes: 3 additions & 1 deletion OgreMain/include/OgreTexture.h
Expand Up @@ -96,7 +96,9 @@ namespace Ogre {
/// 2D texture array
TEX_TYPE_2D_ARRAY = 5,
/// 2D non-square texture, used in combination with 2D texture coordinates
TEX_TYPE_2D_RECT = 6
TEX_TYPE_2D_RECT = 6,
/// texture type for oes
TEX_TYPE_EXTERNAL_OES = 7
};

/** Enum identifying special mipmap numbers
Expand Down
6 changes: 5 additions & 1 deletion OgreMain/src/OgreTextureUnitState.cpp
Expand Up @@ -272,7 +272,11 @@ namespace Ogre {
setContentType(CONTENT_NAMED);
mTextureLoadFailed = false;

if (texPtr->getTextureType() == TEX_TYPE_CUBE_MAP)
if (texPtr->getTextureType() == TEX_TYPE_EXTERNAL_OES || texPtr->getTextureType() == TEX_TYPE_2D_RECT)
{
setTextureAddressingMode( TAM_CLAMP );
}
else if (texPtr->getTextureType() == TEX_TYPE_CUBE_MAP)
{
// delegate to cubic texture implementation
setCubicTexture(&texPtr, true);
Expand Down
2 changes: 2 additions & 0 deletions RenderSystems/GL/src/OgreGLTexture.cpp
Expand Up @@ -95,6 +95,8 @@ namespace Ogre {
return GL_TEXTURE_CUBE_MAP;
case TEX_TYPE_2D_ARRAY:
return GL_TEXTURE_2D_ARRAY_EXT;
case TEX_TYPE_EXTERNAL_OES:
paroj marked this conversation as resolved.
Show resolved Hide resolved
return GL_TEXTURE_EXTERNAL_OES;
default:
return 0;
};
Expand Down
Expand Up @@ -69,6 +69,7 @@ namespace Ogre {
mTypeEnumMap.insert(StringToEnumMap::value_type("sampler2D", GL_SAMPLER_2D));
mTypeEnumMap.insert(StringToEnumMap::value_type("samplerCube", GL_SAMPLER_CUBE));
mTypeEnumMap.insert(StringToEnumMap::value_type("sampler2DShadow", GL_SAMPLER_2D_SHADOW_EXT));
mTypeEnumMap.insert(StringToEnumMap::value_type("samplerExternalOES", GL_SAMPLER_EXTERNAL_OES));
mTypeEnumMap.insert(StringToEnumMap::value_type("int", GL_INT));
mTypeEnumMap.insert(StringToEnumMap::value_type("ivec2", GL_INT_VEC2));
mTypeEnumMap.insert(StringToEnumMap::value_type("ivec3", GL_INT_VEC3));
Expand Down
13 changes: 12 additions & 1 deletion RenderSystems/GLES2/src/OgreGLES2Texture.cpp
Expand Up @@ -70,6 +70,8 @@ namespace Ogre {
return GL_TEXTURE_3D_OES;
case TEX_TYPE_2D_ARRAY:
return GL_TEXTURE_2D_ARRAY;
case TEX_TYPE_EXTERNAL_OES:
return GL_TEXTURE_EXTERNAL_OES;
default:
return 0;
};
Expand Down Expand Up @@ -127,7 +129,11 @@ namespace Ogre {
mRenderSystem->_getStateCacheManager()->setTexParameteri(texTarget, GL_TEXTURE_MAX_LEVEL_APPLE, mNumRequestedMipmaps ? mNumMipmaps + 1 : 0);

// Set some misc default parameters, these can of course be changed later
mRenderSystem->_getStateCacheManager()->setTexParameteri(texTarget,
if(mTextureType == TEX_TYPE_EXTERNAL_OES && mNumRequestedMipmaps > 0) {
LogManager::getSingleton().logError("Mipmaps are not available for TEX_TYPE_EXTERNAL_OES");
}

mRenderSystem->_getStateCacheManager()->setTexParameteri(texTarget,
GL_TEXTURE_MIN_FILTER, ((mUsage & TU_AUTOMIPMAP) && mNumRequestedMipmaps) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
mRenderSystem->_getStateCacheManager()->setTexParameteri(texTarget,
GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Expand Down Expand Up @@ -216,6 +222,8 @@ namespace Ogre {
width, height, depth, 0,
size, &tmpdata[0]);
break;
case TEX_TYPE_EXTERNAL_OES:
LogManager::getSingleton().logError("Mipmaps are not available for TEX_TYPE_EXTERNAL_OES");
};

if(width > 1)
Expand Down Expand Up @@ -257,6 +265,9 @@ namespace Ogre {
case TEX_TYPE_3D:
OGRE_CHECK_GL_ERROR(glTexStorage3D(getGLES2TextureTarget(), GLsizei(mNumMipmaps+1), internalformat, GLsizei(width), GLsizei(height), GLsizei(depth)));
break;
case TEX_TYPE_EXTERNAL_OES:
paroj marked this conversation as resolved.
Show resolved Hide resolved
// No available for TEX_TYPE_EXTERNAL_OES
break;
}
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Samples/AndroidJNI/CMakeLists.txt
Expand Up @@ -24,13 +24,13 @@ if(ANDROID AND OGRE_BUILD_COMPONENT_JAVA)
# Set this variable to false if no java code will be present (google android:hasCode for more info)
SET(HAS_CODE "true")

SET(MAIN_ACTIVITY "org.Ogre.example.MainActivity")
SET(MAIN_ACTIVITY "org.ogre.example.MainActivity")
SET(HEADERS "")
SET(SAMPLE_LDLIBS "")

# Copy and create resource files
# file(COPY "${JNI_PATH}/OgreActivityJNI.java" DESTINATION "${NDKOUT}/src/org/ogre/android")
file(COPY "${JNI_PATH}/MainActivity.java" DESTINATION "${NDKOUT}/src/org/Ogre/example")
file(COPY "${JNI_PATH}/MainActivity.java" DESTINATION "${NDKOUT}/src/org/ogre/example")

copy_assets_to_android_proj()

Expand Down
4 changes: 2 additions & 2 deletions Samples/AndroidJNI/MainActivity.java
Expand Up @@ -26,9 +26,9 @@ of this software and associated documentation files (the "Software"), to deal
-----------------------------------------------------------------------------
*/

package org.Ogre.example;
package org.ogre.example;

import org.Ogre.*;
import org.ogre.*;

import android.app.Activity;
import android.hardware.Sensor;
Expand Down
46 changes: 46 additions & 0 deletions Samples/AndroidTextureOES/CMakeLists.txt
@@ -0,0 +1,46 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------

# Include the CreateAndroidProj macro to create a basic android setup
# and add_static_libs macro to define additional target static libs
include(AndroidMacros)

if(ANDROID AND OGRE_BUILD_COMPONENT_JAVA)
# Setup create_android_proj macro requirements
SET(ANDROID_MOD_NAME "AndroidTextureOES")
SET(JNI_PATH ".")
#SET(JNI_SRC_FILES "OgreActivityJNI.cpp")

SET(NDKOUT "${CMAKE_BINARY_DIR}/${ANDROID_MOD_NAME}")

SET(PKG_NAME "org.ogre.jni")

paroj marked this conversation as resolved.
Show resolved Hide resolved
# Set this variable to false if no java code will be present (google android:hasCode for more info)
SET(HAS_CODE "true")

SET(MAIN_ACTIVITY "org.ogre.example.MainActivity")
SET(HEADERS "")
SET(SAMPLE_LDLIBS "")

# Copy and create resource files
file(COPY "${JNI_PATH}/MainActivity.java" DESTINATION "${NDKOUT}/src/org/ogre/example")

copy_assets_to_android_proj()

# Create CMake target
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummyJNIforOES.cpp "int x = 23;")
ADD_LIBRARY(OgreJNIDummyOES SHARED ${CMAKE_CURRENT_BINARY_DIR}/dummyJNIforOES.cpp)

# copy the SDK
add_custom_command(TARGET OgreJNIDummyOES PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${OGRE_BINARY_DIR}/java" "${NDKOUT}")

# set(JNI_PATH "${NDKOUT}/jni")
create_android_proj(OgreJNIDummyOES)
endif()