More work on Android port

This commit is contained in:
rdb 2014-10-08 15:09:25 +00:00
parent 32a9e4d9ed
commit fbc3564bf9
16 changed files with 237 additions and 174 deletions

View File

@ -52,7 +52,6 @@ import __builtin__
from StringIO import StringIO from StringIO import StringIO
import marshal import marshal
import ElementTree as ET import ElementTree as ET
from HTMLParser import HTMLParser
import BpDb import BpDb
import unicodedata import unicodedata
import bisect import bisect
@ -4201,75 +4200,6 @@ if __debug__ and __name__ == '__main__':
assert unescapeHtmlString('as%32df') == 'as2df' assert unescapeHtmlString('as%32df') == 'as2df'
assert unescapeHtmlString('asdf%32') == 'asdf2' assert unescapeHtmlString('asdf%32') == 'asdf2'
class HTMLStringToElements(HTMLParser):
def __init__(self, str, *a, **kw):
self._elements = []
self._elementStack = Stack()
HTMLParser.__init__(self, *a, **kw)
self.feed(str)
self.close()
def getElements(self):
return self._elements
def _handleNewElement(self, element):
if len(self._elementStack):
self._elementStack.top().append(element)
else:
self._elements.append(element)
self._elementStack.push(element)
def handle_starttag(self, tag, attrs):
kwArgs = {}
for name, value in attrs:
kwArgs[name] = value
el = ET.Element(tag, **kwArgs)
self._handleNewElement(el)
def handle_data(self, data):
# this ignores text outside of a tag
if len(self._elementStack):
self._elementStack.top().text = data
def handle_endtag(self, tag):
top = self._elementStack.top()
if len(top.getchildren()) == 0:
# insert a comment to prevent ElementTree from using <... /> convention
# force it to create a tag closer a la </tag>
# prevents problems in certain browsers
if top.tag == 'script' and top.get('type') == 'text/javascript':
if top.text == None:
top.text = '// force tag closer'
else:
self.handle_comment('force tag closer')
self._elementStack.pop()
self._elementStack.pop()
def handle_comment(self, data):
comment = ET.Comment(data)
self._handleNewElement(comment)
def str2elements(str):
return HTMLStringToElements(str).getElements()
if __debug__ and __name__ == '__main__':
s = ScratchPad()
assert len(str2elements('')) == 0
s.br = str2elements('<br>')
assert len(s.br) == 1
assert s.br[0].tag == 'br'
s.b = str2elements('<b><br></b>')
assert len(s.b) == 1
assert len(s.b[0].getchildren()) == 1
s.a = str2elements('<a href=\'/\'>test</a>')
assert len(s.a) == 1
assert s.a[0].get('href') == '/'
assert s.a[0].text == 'test'
s.c = str2elements('<!--testComment-->')
assert len(s.c) == 1
assert s.c[0].text == 'testComment'
del s
def repeatableRepr(obj): def repeatableRepr(obj):
if type(obj) is types.DictType: if type(obj) is types.DictType:
keys = obj.keys() keys = obj.keys()

View File

@ -7,7 +7,8 @@ __all__ = ['ShowBase', 'WindowControls']
# Annoying and very noisy, but sometimes useful # Annoying and very noisy, but sometimes useful
#import VerboseImport #import VerboseImport
from pandac.PandaModules import * from panda3d.core import *
from panda3d.direct import getConfigShowbase
# This needs to be available early for DirectGUI imports # This needs to be available early for DirectGUI imports
import __builtin__ import __builtin__

View File

@ -3,7 +3,6 @@ import sys
import os import os
import marshal import marshal
import imp import imp
import struct
import types import types
import __builtin__ import __builtin__
@ -286,7 +285,8 @@ class VFSLoader:
code = None code = None
data = vfile.readFile(True) data = vfile.readFile(True)
if data[:4] == imp.get_magic(): if data[:4] == imp.get_magic():
t = struct.unpack('<I', data[4:8])[0] t = ord(data[4]) + (ord(data[5]) << 8) + \
(ord(data[6]) << 16) + (ord(data[7]) << 24)
if not timestamp or t == timestamp: if not timestamp or t == timestamp:
code = marshal.loads(data[8:]) code = marshal.loads(data[8:])
else: else:
@ -314,7 +314,10 @@ class VFSLoader:
pass pass
else: else:
f.write('\0\0\0\0') f.write('\0\0\0\0')
f.write(struct.pack('<I', self.timestamp)) f.write(chr(self.timestamp & 0xff) +
chr((self.timestamp >> 8) & 0xff) +
chr((self.timestamp >> 16) & 0xff) +
chr((self.timestamp >> 24) & 0xff))
f.write(marshal.dumps(code)) f.write(marshal.dumps(code))
f.flush() f.flush()
f.seek(0, 0) f.seek(0, 0)

View File

@ -119,3 +119,23 @@ INLINE string ExecutionEnvironment::
get_dtool_name() { get_dtool_name() {
return get_ptr()->ns_get_dtool_name(); return get_ptr()->ns_get_dtool_name();
} }
////////////////////////////////////////////////////////////////////
// Function: ExecutionEnvironment::set_binary_name
// Access: Public, Static
// Description: Do not use.
////////////////////////////////////////////////////////////////////
INLINE void ExecutionEnvironment::
set_binary_name(const string &name) {
get_ptr()->_binary_name = name;
}
////////////////////////////////////////////////////////////////////
// Function: ExecutionEnvironment::set_dtool_name
// Access: Public, Static
// Description: Do not use.
////////////////////////////////////////////////////////////////////
INLINE void ExecutionEnvironment::
set_dtool_name(const string &name) {
get_ptr()->_dtool_name = name;
}

View File

@ -613,7 +613,7 @@ read_environment_variables() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void ExecutionEnvironment:: void ExecutionEnvironment::
read_args() { read_args() {
#ifndef ANDROID
// First, we need to fill in _dtool_name. This contains // First, we need to fill in _dtool_name. This contains
// the full path to the p3dtool library. // the full path to the p3dtool library.
@ -835,7 +835,7 @@ read_args() {
} }
#endif #endif
#ifndef WIN32 #ifndef _WIN32
// Try to use realpath to get cleaner paths. // Try to use realpath to get cleaner paths.
if (!_binary_name.empty()) { if (!_binary_name.empty()) {
@ -851,7 +851,9 @@ read_args() {
_dtool_name = newpath; _dtool_name = newpath;
} }
} }
#endif #endif // _WIN32
#endif // ANDROID
if (_dtool_name.empty()) { if (_dtool_name.empty()) {
_dtool_name = _binary_name; _dtool_name = _binary_name;

View File

@ -50,6 +50,9 @@ PUBLISHED:
INLINE static string get_binary_name(); INLINE static string get_binary_name();
INLINE static string get_dtool_name(); INLINE static string get_dtool_name();
INLINE static void set_binary_name(const string &name);
INLINE static void set_dtool_name(const string &name);
static Filename get_cwd(); static Filename get_cwd();
private: private:

View File

@ -57,6 +57,10 @@ TVOLATILE AtomicAdjust::Pointer Filename::_user_appdata_directory;
TVOLATILE AtomicAdjust::Pointer Filename::_common_appdata_directory; TVOLATILE AtomicAdjust::Pointer Filename::_common_appdata_directory;
TypeHandle Filename::_type_handle; TypeHandle Filename::_type_handle;
#ifdef ANDROID
string Filename::_internal_data_dir;
#endif
#ifdef WIN32 #ifdef WIN32
/* begin Win32-specific code */ /* begin Win32-specific code */
@ -459,7 +463,7 @@ Filename Filename::
temporary(const string &dirname, const string &prefix, const string &suffix, temporary(const string &dirname, const string &prefix, const string &suffix,
Type type) { Type type) {
Filename fdirname = dirname; Filename fdirname = dirname;
#ifdef WIN32 #if defined(_WIN32) || defined(ANDROID)
// The Windows tempnam() function doesn't do a good job of choosing // The Windows tempnam() function doesn't do a good job of choosing
// a temporary directory. Choose one ourselves. // a temporary directory. Choose one ourselves.
if (fdirname.empty()) { if (fdirname.empty()) {
@ -523,7 +527,7 @@ get_home_directory() {
if (home_directory.empty()) { if (home_directory.empty()) {
#ifdef WIN32 #ifdef WIN32
wchar_t buffer[MAX_PATH]; wchar_t buffer[MAX_PATH];
// On Windows, fall back to the "My Documents" folder. // On Windows, fall back to the "My Documents" folder.
if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_PERSONAL, true)) { if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_PERSONAL, true)) {
Filename dirname = from_os_specific_w(buffer); Filename dirname = from_os_specific_w(buffer);
@ -534,15 +538,22 @@ get_home_directory() {
} }
} }
#elif defined(ANDROID)
// Temporary hack.
home_directory = "/data/data/org.panda3d.sdk";
#elif defined(IS_OSX) #elif defined(IS_OSX)
home_directory = get_osx_home_directory(); home_directory = get_osx_home_directory();
#elif defined(ANDROID)
home_directory = _internal_data_dir;
#else #else
// Posix case: check /etc/passwd? // Posix case: check /etc/passwd?
#endif // WIN32 #endif // WIN32
} }
if (home_directory.empty()) { if (home_directory.empty()) {
// Fallback case. // Fallback case.
home_directory = ExecutionEnvironment::get_cwd(); home_directory = ExecutionEnvironment::get_cwd();
@ -555,7 +566,7 @@ get_home_directory() {
delete newdir; delete newdir;
} }
} }
return (*(Filename *)_home_directory); return (*(Filename *)_home_directory);
} }
@ -585,6 +596,10 @@ get_temp_directory() {
#elif defined(IS_OSX) #elif defined(IS_OSX)
temp_directory = get_osx_temp_directory(); temp_directory = get_osx_temp_directory();
#elif defined(ANDROID)
temp_directory.set_dirname(_internal_data_dir);
temp_directory.set_basename("cache");
#else #else
// Posix case. // Posix case.
temp_directory = "/tmp"; temp_directory = "/tmp";
@ -634,6 +649,10 @@ get_user_appdata_directory() {
#elif defined(IS_OSX) #elif defined(IS_OSX)
user_appdata_directory = get_osx_user_appdata_directory(); user_appdata_directory = get_osx_user_appdata_directory();
#elif defined(ANDROID)
user_appdata_directory.set_dirname(_internal_data_dir);
user_appdata_directory.set_basename("files");
#else #else
// Posix case. // Posix case.
user_appdata_directory = get_home_directory(); user_appdata_directory = get_home_directory();
@ -683,6 +702,10 @@ get_common_appdata_directory() {
#elif defined(IS_OSX) #elif defined(IS_OSX)
common_appdata_directory = get_osx_common_appdata_directory(); common_appdata_directory = get_osx_common_appdata_directory();
#elif defined(ANDROID)
common_appdata_directory.set_dirname(_internal_data_dir);
common_appdata_directory.set_basename("files");
#else #else
// Posix case. // Posix case.
common_appdata_directory = "/var"; common_appdata_directory = "/var";

View File

@ -263,6 +263,11 @@ protected:
static TVOLATILE AtomicAdjust::Pointer _user_appdata_directory; static TVOLATILE AtomicAdjust::Pointer _user_appdata_directory;
static TVOLATILE AtomicAdjust::Pointer _common_appdata_directory; static TVOLATILE AtomicAdjust::Pointer _common_appdata_directory;
#ifdef ANDROID
public:
static string _internal_data_dir;
#endif
public: public:
static TypeHandle get_class_type() { static TypeHandle get_class_type() {
return _type_handle; return _type_handle;

View File

@ -16,6 +16,7 @@
#include "config_util.h" #include "config_util.h"
#include "virtualFileMountAndroidAsset.h" #include "virtualFileMountAndroidAsset.h"
#include "virtualFileSystem.h" #include "virtualFileSystem.h"
#include "filename.h"
#include "config_display.h" #include "config_display.h"
//#define OPENGLES_1 //#define OPENGLES_1
@ -45,9 +46,36 @@ void android_main(struct android_app* app) {
return; return;
} }
// Fetch the data directory.
jclass activity_class = env->GetObjectClass(activity->clazz);
jmethodID get_appinfo = env->GetMethodID(activity_class, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
jobject appinfo = env->CallObjectMethod(activity->clazz, get_appinfo);
jclass appinfo_class = env->GetObjectClass(appinfo);
// Fetch the path to the data directory.
jfieldID datadir_field = env->GetFieldID(appinfo_class, "dataDir", "Ljava/lang/String;");
jstring datadir = (jstring) env->GetObjectField(appinfo, datadir_field);
const char *data_path = env->GetStringUTFChars(datadir, NULL);
Filename::_internal_data_dir = data_path;
android_cat.info() << "Path to data: " << data_path << "\n";
env->ReleaseStringUTFChars(datadir, data_path);
// Fetch the path to the library directory.
jfieldID libdir_field = env->GetFieldID(appinfo_class, "nativeLibraryDir", "Ljava/lang/String;");
jstring libdir = (jstring) env->GetObjectField(appinfo, libdir_field);
const char *lib_path = env->GetStringUTFChars(libdir, NULL);
string dtool_name = string(lib_path) + "/libp3dtool.so";
ExecutionEnvironment::set_dtool_name(dtool_name);
android_cat.info() << "Path to dtool: " << dtool_name << "\n";
env->ReleaseStringUTFChars(libdir, lib_path);
// Get the path to the APK. // Get the path to the APK.
jclass clazz = env->GetObjectClass(activity->clazz); jmethodID methodID = env->GetMethodID(activity_class, "getPackageCodePath", "()Ljava/lang/String;");
jmethodID methodID = env->GetMethodID(clazz, "getPackageCodePath", "()Ljava/lang/String;");
jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID); jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID);
const char* apk_path; const char* apk_path;

View File

@ -326,7 +326,7 @@ open_window() {
return false; return false;
} }
//_fb_properties = androidgsg->get_fb_properties(); _fb_properties = androidgsg->get_fb_properties();
androiddisplay_cat.error() << "open_window done\n"; androiddisplay_cat.error() << "open_window done\n";
@ -434,7 +434,7 @@ handle_command(struct android_app *app, int32_t command) {
void AndroidGraphicsWindow:: void AndroidGraphicsWindow::
ns_handle_command(int32_t command) { ns_handle_command(int32_t command) {
WindowProperties properties; WindowProperties properties;
switch (command) { switch (command) {
case APP_CMD_SAVE_STATE: case APP_CMD_SAVE_STATE:
// The system has asked us to save our current state. Do so. // The system has asked us to save our current state. Do so.
@ -446,16 +446,25 @@ ns_handle_command(int32_t command) {
// The window is being shown, get it ready. // The window is being shown, get it ready.
if (_app->window != NULL) { if (_app->window != NULL) {
create_surface(); create_surface();
properties.set_size(ANativeWindow_getWidth(_app->window),
ANativeWindow_getHeight(_app->window));
properties.set_minimized(false); properties.set_minimized(false);
system_changed_properties(properties); system_changed_properties(properties);
} }
break; break;
case APP_CMD_CONFIG_CHANGED:
properties.set_size(ANativeWindow_getWidth(_app->window),
ANativeWindow_getHeight(_app->window));
system_changed_properties(properties);
break;
case APP_CMD_TERM_WINDOW: case APP_CMD_TERM_WINDOW:
destroy_surface(); destroy_surface();
properties.set_minimized(true); properties.set_minimized(true);
system_changed_properties(properties); system_changed_properties(properties);
break; break;
case APP_CMD_WINDOW_RESIZED: case APP_CMD_WINDOW_RESIZED:
properties.set_size(ANativeWindow_getWidth(_app->window),
ANativeWindow_getHeight(_app->window));
break; break;
case APP_CMD_WINDOW_REDRAW_NEEDED: case APP_CMD_WINDOW_REDRAW_NEEDED:
break; break;

View File

@ -57,7 +57,7 @@ get_fd(const Filename &file, off_t *start, off_t *length) const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool VirtualFileMountAndroidAsset:: bool VirtualFileMountAndroidAsset::
has_file(const Filename &file) const { has_file(const Filename &file) const {
return (file.empty() || is_directory(file) || is_regular_file(file)); return (file.empty() || /*is_directory(file) ||*/ is_regular_file(file));
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -90,6 +90,7 @@
#define GL_DEPTH_STENCIL_EXT GL_DEPTH_STENCIL_OES #define GL_DEPTH_STENCIL_EXT GL_DEPTH_STENCIL_OES
#define GL_UNSIGNED_INT_24_8_EXT GL_UNSIGNED_INT_24_8_OES #define GL_UNSIGNED_INT_24_8_EXT GL_UNSIGNED_INT_24_8_OES
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES #define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT16_OES #define GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT16_OES
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES #define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES #define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES

View File

@ -174,6 +174,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
// In case of multisample rendering, we don't need to issue // In case of multisample rendering, we don't need to issue
// the barrier until we call glBlitFramebuffer. // the barrier until we call glBlitFramebuffer.
#ifndef OPENGLES
if (gl_enable_memory_barriers && _fbo_multisample == 0) { if (gl_enable_memory_barriers && _fbo_multisample == 0) {
CLP(GraphicsStateGuardian) *glgsg; CLP(GraphicsStateGuardian) *glgsg;
DCAST_INTO_R(glgsg, _gsg, false); DCAST_INTO_R(glgsg, _gsg, false);
@ -189,6 +190,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
} }
} }
} }
#endif
} }
_gsg->set_current_properties(&get_fb_properties()); _gsg->set_current_properties(&get_fb_properties());
@ -443,6 +445,7 @@ rebuild_bitplanes() {
if (_fbo[layer] == 0) { if (_fbo[layer] == 0) {
glgsg->_glGenFramebuffers(1, &_fbo[layer]); glgsg->_glGenFramebuffers(1, &_fbo[layer]);
#ifndef OPENGLES
if (glgsg->_use_object_labels) { if (glgsg->_use_object_labels) {
if (num_fbos > 1) { if (num_fbos > 1) {
GLchar name[128]; GLchar name[128];
@ -452,6 +455,7 @@ rebuild_bitplanes() {
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data()); glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data());
} }
} }
#endif
if (_fbo[layer] == 0) { if (_fbo[layer] == 0) {
report_my_gl_errors(); report_my_gl_errors();
@ -485,7 +489,7 @@ rebuild_bitplanes() {
_have_any_color = true; _have_any_color = true;
} }
#ifndef OPENGLES #ifndef OPENGLES_1
for (int i=0; i<_fb_properties.get_aux_rgba(); i++) { for (int i=0; i<_fb_properties.get_aux_rgba(); i++) {
bind_slot(layer, rb_resize, attach, (RenderTexturePlane)(RTP_aux_rgba_0+i), next++); bind_slot(layer, rb_resize, attach, (RenderTexturePlane)(RTP_aux_rgba_0+i), next++);
_have_any_color = true; _have_any_color = true;
@ -1630,6 +1634,7 @@ resolve_multisamples() {
PStatGPUTimer timer(glgsg, _resolve_multisample_pcollector); PStatGPUTimer timer(glgsg, _resolve_multisample_pcollector);
#ifndef OPENGLES
if (gl_enable_memory_barriers) { if (gl_enable_memory_barriers) {
// Issue memory barriers as necessary to make sure that the // Issue memory barriers as necessary to make sure that the
// texture memory is synchronized before we blit to it. // texture memory is synchronized before we blit to it.
@ -1644,6 +1649,7 @@ resolve_multisamples() {
} }
} }
} }
#endif
glgsg->report_my_gl_errors(); glgsg->report_my_gl_errors();
GLuint fbo = _fbo[0]; GLuint fbo = _fbo[0];
@ -1692,6 +1698,7 @@ resolve_multisamples() {
GL_NEAREST); GL_NEAREST);
} }
// Now handle the other color buffers. // Now handle the other color buffers.
#ifndef OPENGLES_1
int next = GL_COLOR_ATTACHMENT1_EXT; int next = GL_COLOR_ATTACHMENT1_EXT;
if (_fb_properties.is_stereo()) { if (_fb_properties.is_stereo()) {
glReadBuffer(next); glReadBuffer(next);
@ -1700,7 +1707,6 @@ resolve_multisamples() {
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
next += 1; next += 1;
} }
#ifndef OPENGLES
for (int i = 0; i < _fb_properties.get_aux_rgba(); ++i) { for (int i = 0; i < _fb_properties.get_aux_rgba(); ++i) {
glReadBuffer(next); glReadBuffer(next);
glDrawBuffer(next); glDrawBuffer(next);

View File

@ -552,6 +552,7 @@ reset() {
_supported_geom_rendering |= Geom::GR_point_sprite; _supported_geom_rendering |= Geom::GR_point_sprite;
} }
#ifndef OPENGLES
_glPrimitiveRestartIndex = NULL; _glPrimitiveRestartIndex = NULL;
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) { if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) {
@ -575,6 +576,7 @@ reset() {
_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) _glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
get_extension_func("glPrimitiveRestartIndexNV"); get_extension_func("glPrimitiveRestartIndexNV");
} }
#endif
_supports_vertex_blend = has_extension("GL_ARB_vertex_blend"); _supports_vertex_blend = has_extension("GL_ARB_vertex_blend");
@ -798,7 +800,6 @@ reset() {
} }
} }
_supports_2d_texture_array = false; _supports_2d_texture_array = false;
#ifndef OPENGLES #ifndef OPENGLES
_supports_2d_texture_array = has_extension("GL_EXT_texture_array"); _supports_2d_texture_array = has_extension("GL_EXT_texture_array");
@ -914,12 +915,10 @@ reset() {
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < num_compressed_formats; ++i) { for (int i = 0; i < num_compressed_formats; ++i) {
switch (formats[i]) { switch (formats[i]) {
#ifndef OPENGLES_1
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
_compressed_texture_formats.set_bit(Texture::CM_dxt1); _compressed_texture_formats.set_bit(Texture::CM_dxt1);
break; break;
#endif
#ifdef OPENGLES #ifdef OPENGLES
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
@ -1776,7 +1775,6 @@ reset() {
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < num_compressed_formats; ++i) { for (int i = 0; i < num_compressed_formats; ++i) {
switch (formats[i]) { switch (formats[i]) {
#ifndef OPENGLES_1
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
GLCAT.debug(false) << " GL_COMPRESSED_RGB_S3TC_DXT1_EXT\n"; GLCAT.debug(false) << " GL_COMPRESSED_RGB_S3TC_DXT1_EXT\n";
break; break;
@ -1784,7 +1782,6 @@ reset() {
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
GLCAT.debug(false) << " GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\n"; GLCAT.debug(false) << " GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\n";
break; break;
#endif
#ifdef OPENGLES #ifdef OPENGLES
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
GLCAT.debug(false) << " GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG\n"; GLCAT.debug(false) << " GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG\n";
@ -2431,6 +2428,7 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
_scissor_enabled = false; _scissor_enabled = false;
} }
#ifndef OPENGLES
if (_supports_viewport_arrays) { if (_supports_viewport_arrays) {
int count = dr->get_num_regions(); int count = dr->get_num_regions();
GLfloat *viewports = (GLfloat *)alloca(sizeof(GLfloat) * 4 * count); GLfloat *viewports = (GLfloat *)alloca(sizeof(GLfloat) * 4 * count);
@ -2450,7 +2448,9 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
_glScissorArrayv(0, count, scissors); _glScissorArrayv(0, count, scissors);
} }
} else { } else
#endif // OPENGLES
{
glViewport(x, y, width, height); glViewport(x, y, width, height);
if (dr->get_scissor_enabled()) { if (dr->get_scissor_enabled()) {
glScissor(x, y, width, height); glScissor(x, y, width, height);
@ -3845,9 +3845,11 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) {
if (reader->is_indexed() && if (reader->is_indexed() &&
(_supported_geom_rendering & GeomEnums::GR_strip_cut_index) != 0) { (_supported_geom_rendering & GeomEnums::GR_strip_cut_index) != 0) {
// One long triangle strip, connected by strip cut indices. // One long triangle strip, connected by strip cut indices.
#ifndef OPENGLES
if (_glPrimitiveRestartIndex != NULL) { if (_glPrimitiveRestartIndex != NULL) {
_glPrimitiveRestartIndex(reader->get_strip_cut_index()); _glPrimitiveRestartIndex(reader->get_strip_cut_index());
} }
#endif
int num_vertices = reader->get_num_vertices(); int num_vertices = reader->get_num_vertices();
_vertices_other_pcollector.add_level(num_vertices); _vertices_other_pcollector.add_level(num_vertices);
@ -5271,9 +5273,11 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
case GL_FLOAT: case GL_FLOAT:
GLCAT.spam(false) << "GL_FLOAT"; GLCAT.spam(false) << "GL_FLOAT";
break; break;
#ifndef OPENGLES_1
case GL_INT: case GL_INT:
GLCAT.spam(false) << "GL_INT"; GLCAT.spam(false) << "GL_INT";
break; break;
#endif
default: default:
GLCAT.spam(false) << "unknown"; GLCAT.spam(false) << "unknown";
break; break;
@ -5810,7 +5814,11 @@ do_issue_material() {
} }
#endif // NDEBUG #endif // NDEBUG
#ifdef OPENGLES
const GLenum face = GL_FRONT_AND_BACK;
#else
GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT; GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT;
#endif
call_glMaterialfv(face, GL_SPECULAR, material->get_specular()); call_glMaterialfv(face, GL_SPECULAR, material->get_specular());
call_glMaterialfv(face, GL_EMISSION, material->get_emission()); call_glMaterialfv(face, GL_EMISSION, material->get_emission());
@ -7045,7 +7053,9 @@ get_component_type(Texture::ComponentType component_type) {
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
} }
case Texture::T_int: case Texture::T_int:
#ifndef OPENGLES_1
return GL_INT; return GL_INT;
#endif
default: default:
GLCAT.error() << "Invalid Texture::Type value!\n"; GLCAT.error() << "Invalid Texture::Type value!\n";
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
@ -7133,18 +7143,19 @@ get_external_image_format(Texture *tex) const {
#endif #endif
break; break;
#ifndef OPENGLES_1
case Texture::CM_dxt1: case Texture::CM_dxt1:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
} else { } else {
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
} }
#endif
#ifndef OPENGLES #ifndef OPENGLES
case Texture::CM_dxt3: case Texture::CM_dxt3:
@ -7170,22 +7181,28 @@ get_external_image_format(Texture *tex) const {
#else #else
case Texture::CM_pvr1_2bpp: case Texture::CM_pvr1_2bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
} else { } else {
return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
} }
case Texture::CM_pvr1_4bpp: case Texture::CM_pvr1_4bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
} else { } else {
return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
@ -7425,18 +7442,19 @@ get_internal_image_format(Texture *tex) const {
return GL_COMPRESSED_SLUMINANCE_ALPHA; return GL_COMPRESSED_SLUMINANCE_ALPHA;
#endif #endif
#ifndef OPENGLES_1
case Texture::CM_dxt1: case Texture::CM_dxt1:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
} else { } else {
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
} }
#endif
#ifndef OPENGLES #ifndef OPENGLES
case Texture::CM_dxt3: case Texture::CM_dxt3:
@ -7461,22 +7479,28 @@ get_internal_image_format(Texture *tex) const {
} }
#else #else
case Texture::CM_pvr1_2bpp: case Texture::CM_pvr1_2bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
} else { } else {
return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
} }
case Texture::CM_pvr1_4bpp: case Texture::CM_pvr1_4bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
} else if (Texture::has_alpha(format)) { } else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
} else { } else {
return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
@ -7500,9 +7524,12 @@ get_internal_image_format(Texture *tex) const {
case Texture::F_depth_stencil: case Texture::F_depth_stencil:
if (_supports_depth_stencil) { if (_supports_depth_stencil) {
#ifndef OPENGLES_1
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_DEPTH32F_STENCIL8; return GL_DEPTH32F_STENCIL8;
} else { } else
#endif
{
return GL_DEPTH_STENCIL; return GL_DEPTH_STENCIL;
} }
} }
@ -7554,9 +7581,12 @@ get_internal_image_format(Texture *tex) const {
case Texture::F_rgba: case Texture::F_rgba:
case Texture::F_rgbm: case Texture::F_rgbm:
#ifndef OPENGLES_1
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_RGBA16F; return GL_RGBA16F;
} else { } else
#endif
{
return GL_RGBA; return GL_RGBA;
} }
@ -7568,17 +7598,13 @@ get_internal_image_format(Texture *tex) const {
return GL_RGBA8_OES; return GL_RGBA8_OES;
case Texture::F_rgba12: case Texture::F_rgba12:
return GL_RGBA; return GL_RGBA;
#ifndef OPENGLES_1
case Texture::F_rgba16:
return GL_RGBA16F;
#endif // OPENGLES_1
case Texture::F_rgba32:
return GL_RGBA32F;
#else #else
case Texture::F_rgba8: case Texture::F_rgba8:
return GL_RGBA8; return GL_RGBA8;
case Texture::F_rgba12: case Texture::F_rgba12:
return GL_RGBA12; return GL_RGBA12;
#endif // OPENGLES
#ifndef OPENGLES_1
case Texture::F_rgba16: case Texture::F_rgba16:
return GL_RGBA16F; return GL_RGBA16F;
case Texture::F_rgba32: case Texture::F_rgba32:
@ -7648,21 +7674,21 @@ get_internal_image_format(Texture *tex) const {
return GL_RG16; return GL_RG16;
} }
#endif #endif
#ifndef OPENGLES_1
case Texture::F_r32: case Texture::F_r32:
return GL_R32F; return GL_R32F;
case Texture::F_rg32: case Texture::F_rg32:
return GL_RG32F; return GL_RG32F;
case Texture::F_alpha:
return GL_ALPHA;
#ifndef OPENGLES_1
case Texture::F_red: case Texture::F_red:
case Texture::F_green: case Texture::F_green:
case Texture::F_blue: case Texture::F_blue:
return GL_RED; return GL_RED;
#endif #endif
case Texture::F_alpha:
return GL_ALPHA;
case Texture::F_luminance: case Texture::F_luminance:
return GL_LUMINANCE; return GL_LUMINANCE;
case Texture::F_luminance_alpha: case Texture::F_luminance_alpha:
@ -7723,10 +7749,8 @@ is_mipmap_filter(GLenum min_filter) {
bool CLP(GraphicsStateGuardian):: bool CLP(GraphicsStateGuardian)::
is_compressed_format(GLenum format) { is_compressed_format(GLenum format) {
switch (format) { switch (format) {
#ifndef OPENGLES_1
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
#endif
#ifdef OPENGLES #ifdef OPENGLES
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
@ -8811,20 +8835,17 @@ update_standard_texture_bindings() {
_glActiveTexture(GL_TEXTURE0 + i); _glActiveTexture(GL_TEXTURE0 + i);
// First, turn off the previous texture mode. // First, turn off the previous texture mode.
#ifndef OPENGLES_2
#ifndef OPENGLES
glDisable(GL_TEXTURE_1D);
#endif // OPENGLES
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
if (_supports_3d_texture) {
#ifndef OPENGLES_1
glDisable(GL_TEXTURE_3D);
#endif // OPENGLES_1
}
if (_supports_cube_map) { if (_supports_cube_map) {
glDisable(GL_TEXTURE_CUBE_MAP); glDisable(GL_TEXTURE_CUBE_MAP);
} }
#endif // OPENGLES_2
#ifndef OPENGLES
glDisable(GL_TEXTURE_1D);
if (_supports_3d_texture) {
glDisable(GL_TEXTURE_3D);
}
#endif // OPENGLES
int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); int view = get_current_tex_view_offset() + stage->get_tex_view_offset();
TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this);
@ -8833,7 +8854,6 @@ update_standard_texture_bindings() {
continue; continue;
} }
#ifndef OPENGLES_2
// Then, turn on the current texture mode. // Then, turn on the current texture mode.
GLenum target = get_texture_target(texture->get_texture_type()); GLenum target = get_texture_target(texture->get_texture_type());
if (target == GL_NONE) { if (target == GL_NONE) {
@ -8845,14 +8865,11 @@ update_standard_texture_bindings() {
// Cannot be applied via the FFP. // Cannot be applied via the FFP.
continue; continue;
} }
#endif #endif // OPENGLES
glEnable(target); glEnable(target);
#endif
if (!update_texture(tc, false)) { if (!update_texture(tc, false)) {
#ifndef OPENGLES_2
glDisable(target); glDisable(target);
#endif
continue; continue;
} }
apply_texture(tc); apply_texture(tc);
@ -8979,30 +8996,26 @@ update_standard_texture_bindings() {
} }
} }
#ifndef OPENGLES_2
// Disable the texture stages that are no longer used. // Disable the texture stages that are no longer used.
for (i = num_stages; i < _num_active_texture_stages; i++) { for (i = num_stages; i < _num_active_texture_stages; i++) {
_glActiveTexture(GL_TEXTURE0 + i); _glActiveTexture(GL_TEXTURE0 + i);
#ifndef OPENGLES
glDisable(GL_TEXTURE_1D);
#endif // OPENGLES
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
if (_supports_3d_texture) {
#ifndef OPENGLES_1
glDisable(GL_TEXTURE_3D);
#endif // OPENGLES_1
}
if (_supports_cube_map) { if (_supports_cube_map) {
glDisable(GL_TEXTURE_CUBE_MAP); glDisable(GL_TEXTURE_CUBE_MAP);
} }
#ifndef OPENGLES
glDisable(GL_TEXTURE_1D);
if (_supports_3d_texture) {
glDisable(GL_TEXTURE_3D);
}
#endif // OPENGLES
} }
#endif // OPENGLES_2
// Save the count of texture stages for next time. // Save the count of texture stages for next time.
_num_active_texture_stages = num_stages; _num_active_texture_stages = num_stages;
report_my_gl_errors(); report_my_gl_errors();
#endif #endif // OPENGLES_2
} }
@ -10226,16 +10239,6 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
_data_transferred_pcollector.add_level(view_size); _data_transferred_pcollector.add_level(view_size);
#endif #endif
switch (texture_target) { switch (texture_target) {
case GL_TEXTURE_1D:
if (image_compression == Texture::CM_off) {
glTexSubImage1D(page_target, n - mipmap_bias, 0, width,
external_format, component_type, image_ptr);
} else {
_glCompressedTexSubImage1D(page_target, n - mipmap_bias, 0, width,
external_format, view_size, image_ptr);
}
break;
#ifdef OPENGLES_2 #ifdef OPENGLES_2
case GL_TEXTURE_3D_OES: case GL_TEXTURE_3D_OES:
#endif #endif
@ -10256,6 +10259,16 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false; return false;
} }
break; break;
case GL_TEXTURE_1D:
if (image_compression == Texture::CM_off) {
glTexSubImage1D(page_target, n - mipmap_bias, 0, width,
external_format, component_type, image_ptr);
} else {
_glCompressedTexSubImage1D(page_target, n - mipmap_bias, 0, width,
external_format, view_size, image_ptr);
}
break;
#endif #endif
#ifndef OPENGLES #ifndef OPENGLES
case GL_TEXTURE_2D_ARRAY_EXT: case GL_TEXTURE_2D_ARRAY_EXT:
@ -10826,10 +10839,12 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
type = Texture::T_unsigned_int_24_8; type = Texture::T_unsigned_int_24_8;
format = Texture::F_depth_stencil; format = Texture::F_depth_stencil;
break; break;
#ifndef OPENGLES_1
case GL_DEPTH32F_STENCIL8: case GL_DEPTH32F_STENCIL8:
type = Texture::T_float; type = Texture::T_float;
format = Texture::F_depth_stencil; format = Texture::F_depth_stencil;
break; break;
#endif
case GL_RGBA: case GL_RGBA:
case 4: case 4:
format = Texture::F_rgba; format = Texture::F_rgba;
@ -11022,7 +11037,6 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
break; break;
#endif #endif
#ifndef OPENGLES_1
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
format = Texture::F_rgb; format = Texture::F_rgb;
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
@ -11031,6 +11045,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
format = Texture::F_rgbm; format = Texture::F_rgbm;
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
break; break;
#ifndef OPENGLES_1
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
format = Texture::F_srgb; format = Texture::F_srgb;
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
@ -11040,6 +11055,26 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
break; break;
#endif #endif
#ifdef OPENGLES_2
case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_4bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_4bpp;
break;
#endif // OPENGLES_2
#ifdef OPENGLES #ifdef OPENGLES
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
format = Texture::F_rgb; format = Texture::F_rgb;
@ -11058,22 +11093,6 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
compression = Texture::CM_pvr1_4bpp; compression = Texture::CM_pvr1_4bpp;
break; break;
case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_4bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_4bpp;
break;
#else #else
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
format = Texture::F_rgba; format = Texture::F_rgba;

View File

@ -598,7 +598,9 @@ public:
PFNGLPOINTPARAMETERFVPROC _glPointParameterfv; PFNGLPOINTPARAMETERFVPROC _glPointParameterfv;
bool _supports_point_sprite; bool _supports_point_sprite;
#ifndef OPENGLES
PFNGLPRIMITIVERESTARTINDEXPROC _glPrimitiveRestartIndex; PFNGLPRIMITIVERESTARTINDEXPROC _glPrimitiveRestartIndex;
#endif
bool _supports_vertex_blend; bool _supports_vertex_blend;
PFNGLWEIGHTPOINTERARBPROC _glWeightPointer; PFNGLWEIGHTPOINTERARBPROC _glWeightPointer;
@ -710,11 +712,13 @@ public:
PFNGLGETQUERYIVPROC _glGetQueryiv; PFNGLGETQUERYIVPROC _glGetQueryiv;
PFNGLGETQUERYOBJECTUIVPROC _glGetQueryObjectuiv; PFNGLGETQUERYOBJECTUIVPROC _glGetQueryObjectuiv;
#ifndef OPENGLES
PFNGLQUERYCOUNTERPROC _glQueryCounter; PFNGLQUERYCOUNTERPROC _glQueryCounter;
PFNGLGETQUERYOBJECTI64VPROC _glGetQueryObjecti64v; PFNGLGETQUERYOBJECTI64VPROC _glGetQueryObjecti64v;
PFNGLGETQUERYOBJECTUI64VPROC _glGetQueryObjectui64v; PFNGLGETQUERYOBJECTUI64VPROC _glGetQueryObjectui64v;
PFNGLGETINTEGER64VPROC _glGetInteger64v; PFNGLGETINTEGER64VPROC _glGetInteger64v;
#endif
PFNGLACTIVESTENCILFACEEXTPROC _glActiveStencilFaceEXT; PFNGLACTIVESTENCILFACEEXTPROC _glActiveStencilFaceEXT;

View File

@ -23,12 +23,14 @@ TypeHandle CLP(TextureContext)::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
CLP(TextureContext):: CLP(TextureContext)::
~CLP(TextureContext)() { ~CLP(TextureContext)() {
#ifndef OPENGLES
if (gl_enable_memory_barriers) { if (gl_enable_memory_barriers) {
_glgsg->_textures_needing_fetch_barrier.erase(this); _glgsg->_textures_needing_fetch_barrier.erase(this);
_glgsg->_textures_needing_image_access_barrier.erase(this); _glgsg->_textures_needing_image_access_barrier.erase(this);
_glgsg->_textures_needing_update_barrier.erase(this); _glgsg->_textures_needing_update_barrier.erase(this);
_glgsg->_textures_needing_framebuffer_barrier.erase(this); _glgsg->_textures_needing_framebuffer_barrier.erase(this);
} }
#endif
glDeleteTextures(1, &_index); glDeleteTextures(1, &_index);
_index = 0; _index = 0;
@ -53,12 +55,15 @@ void CLP(TextureContext)::
evict_lru() { evict_lru() {
dequeue_lru(); dequeue_lru();
#ifndef OPENGLES
if (_handle != 0) { if (_handle != 0) {
if (_handle_resident) { if (_handle_resident) {
_glgsg->_glMakeTextureHandleNonResident(_handle); _glgsg->_glMakeTextureHandleNonResident(_handle);
} }
_handle_resident = false; _handle_resident = false;
} else { } else
#endif
{
reset_data(); reset_data();
} }
@ -74,9 +79,11 @@ evict_lru() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(TextureContext):: void CLP(TextureContext)::
reset_data() { reset_data() {
#ifndef OPENGLES
if (_handle != 0 && _handle_resident) { if (_handle != 0 && _handle_resident) {
_glgsg->_glMakeTextureHandleNonResident(_handle); _glgsg->_glMakeTextureHandleNonResident(_handle);
} }
#endif
// Free the texture resources. // Free the texture resources.
glDeleteTextures(1, &_index); glDeleteTextures(1, &_index);
@ -108,6 +115,7 @@ reset_data() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(TextureContext):: void CLP(TextureContext)::
make_handle_resident() { make_handle_resident() {
#ifndef OPENGLES
if (_handle != 0) { if (_handle != 0) {
if (!_handle_resident) { if (!_handle_resident) {
_glgsg->_glMakeTextureHandleResident(_handle); _glgsg->_glMakeTextureHandleResident(_handle);
@ -115,6 +123,7 @@ make_handle_resident() {
} }
set_resident(true); set_resident(true);
} }
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////