more iphone work

This commit is contained in:
David Rose 2009-04-21 00:48:51 +00:00
parent d6eecfef6c
commit 172171eec4
21 changed files with 117 additions and 130 deletions

View File

@ -131,46 +131,6 @@
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] $[install_dash_p] $[notdir $[local]] $[dest]/
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] $[install_dash_p] $[notdir $[local]] $[dest]/
// Variable definitions for building with the Irix MIPSPro compiler.
#if $[eq $[USE_COMPILER], MIPS]
#define CC cc -n32 -mips3
#define CXX CC -n32 -mips3
// Turn off a few annoying warning messages.
// 1174 - function 'blah' was declared but never used
// 1201 - trailing comma is nonstandard.
// 1209 - controlling expression is constant, e.g. if (0) { ... }
// 1234 - access control not specified, 'public' by default
// 1355 - extra ";" ignored
// 1375 - destructor for base class is not virtual.
// this one actually is bad. But we got alot of them from the classes
// that we've derived from STL collections. Beware of this.
// 3322 - omission of explicit type is nonstandard ("int" assumed)
#define WOFF_LIST -woff 1174,1201,1209,1234,1355,1375,3322
// Linker warnings
// 85 - definition of SOMESYMBOL in SOMELIB preempts that of definition in
// SOMEOTHERLIB.
#define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
#defer OPTFLAGS -O2 -OPT:Olimit=2500
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] $[WOFF_LIST] -g
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] $[WOFF_LIST]
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[WOFF_LIST]
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[WOFF_LIST]
#defer CFLAGS_SHARED
#defer STATIC_LIB_C $[CC] -ar -o $[target] $[sources]
#defer STATIC_LIB_C++ $[CXX] -ar -o $[target] $[sources]
#defer RANLIB
#defer SHARED_FLAGS -Wl,-none -Wl,-update_registry,$[SO_LOCATIONS]
#defer SHARED_LIB_C $[cc_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
#endif
// Assume that OSX has OpenGL available.
#define HAVE_GL 1

View File

@ -8,8 +8,8 @@
#define IPH_VERSION 2.0
#if $[eq $[IPH_PLATFORM], iPhoneOS]
#define ARCH_FLAGS -arch armv6
#define osflags -miphoneos-version-min=2.0
#define ARCH_FLAGS -arch armv6 -mapcs-frame
#define osflags -miphoneos-version-min=2.0 -mno-sched-prolog
#elif $[eq $[IPH_PLATFORM], iPhoneSimulator]
#define ARCH_FLAGS -arch i386
#define osflags -mmacosx-version-min=10.5
@ -22,7 +22,8 @@
#define CC $[env] $[dev]/usr/bin/gcc-4.0
#define CXX $[env] $[dev]/usr/bin/g++-4.0
#define OSX_CDEFS __IPHONE_OS_VERSION_MIN_REQUIRED=20000
#define OSX_CFLAGS -isysroot $[dev]/SDKs/$[IPH_PLATFORM]$[IPH_VERSION].sdk $[osflags] -gdwarf-2
#define OSX_CFLAGS -isysroot $[dev]/SDKs/$[IPH_PLATFORM]$[IPH_VERSION].sdk $[osflags]
#define DEBUGFLAGS -gdwarf-2
#defer ODIR_SUFFIX -$[IPH_PLATFORM]

View File

@ -29,7 +29,7 @@
#ifdef __APPLE__
// This is for _NSGetExecutablePath() and _NSGetEnviron().
#include <mach-o/dyld.h>
#ifndef BUILDING_IPHONE
#ifndef BUILD_IPHONE
#include <crt_externs.h> // For some reason, not in the IPhone SDK.
#endif
#define environ (*_NSGetEnviron())

View File

@ -1993,6 +1993,38 @@ do_issue_light() {
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::framebuffer_copy_to_texture
// Access: Public, Virtual
// Description: Copy the pixels within the indicated display
// region from the framebuffer into texture memory.
//
// If z > -1, it is the cube map index into which to
// copy.
////////////////////////////////////////////////////////////////////
bool GraphicsStateGuardian::
framebuffer_copy_to_texture(Texture *, int, const DisplayRegion *,
const RenderBuffer &) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::framebuffer_copy_to_ram
// Access: Public, Virtual
// Description: Copy the pixels within the indicated display region
// from the framebuffer into system memory, not texture
// memory. Returns true on success, false on failure.
//
// This completely redefines the ram image of the
// indicated texture.
////////////////////////////////////////////////////////////////////
bool GraphicsStateGuardian::
framebuffer_copy_to_ram(Texture *, int, const DisplayRegion *,
const RenderBuffer &) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::bind_light
// Access: Public, Virtual

View File

@ -285,6 +285,11 @@ public:
void do_issue_color_scale();
virtual void do_issue_light();
virtual bool framebuffer_copy_to_texture
(Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb);
virtual bool framebuffer_copy_to_ram
(Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb);
virtual void bind_light(PointLight *light_obj, const NodePath &light,
int light_id);
virtual void bind_light(DirectionalLight *light_obj, const NodePath &light,

View File

@ -240,7 +240,7 @@ underflow() {
bool eof;
_source->seek_read(_cur, gptr(), num_bytes, read_count, eof);
if (read_count != num_bytes) {
if (read_count != (streamsize)num_bytes) {
// Oops, we didn't read what we thought we would.
if (read_count == 0) {
_unused = buffer_size;

View File

@ -1590,7 +1590,7 @@ calc_projection_mat(const Lens *lens) {
// choice in the modelview matrix.
LMatrix4f result =
LMatrix4f::convert_mat(CS_yup_right, _current_lens->get_coordinate_system()) *
LMatrix4f::convert_mat(CS_yup_right, lens->get_coordinate_system()) *
lens->get_projection_mat(_current_stereo_channel);
if (_scene_setup->get_inverted()) {
@ -1598,7 +1598,7 @@ calc_projection_mat(const Lens *lens) {
// projection matrix.
result *= LMatrix4f::scale_mat(1.0f, -1.0f, 1.0f);
}
return TransformState::make_mat(result);
}

View File

@ -541,6 +541,9 @@ operator << (ostream &out, AutoTextureScale ats) {
case ATS_up:
return out << "up";
case ATS_UNSPECIFIED:
return out << "UNSPECIFIED";
}
return out << "**invalid AutoTextureScale (" << (int)ats << ")**";
@ -585,6 +588,9 @@ operator << (ostream &out, ShaderUtilization sgc) {
case SUT_advanced:
return out << "advanced";
case SUT_UNSPECIFIED:
return out << "UNSPECIFIED";
}
return out << "**invalid ShaderUtilization (" << (int)sgc << ")**";

View File

@ -202,8 +202,6 @@ GeomVertexData::
////////////////////////////////////////////////////////////////////
int GeomVertexData::
compare_to(const GeomVertexData &other) const {
Thread *current_thread = Thread::get_current_thread();
CDReader cdata(_cycler);
CDReader other_cdata(other._cycler);

View File

@ -1449,9 +1449,9 @@ Shader(const Filename &filename, const string &text, const string &vprofile, con
_filename(filename),
_text(text),
_header(""),
_loaded(false),
_error_flag(true),
_parse(0)
_parse(0),
_loaded(false)
{
string header;
parse_init();

View File

@ -596,6 +596,7 @@ estimate_texture_memory() const {
break;
case Texture::F_depth_stencil:
case Texture::F_depth_component:
bpp = 32;
break;
@ -1350,6 +1351,9 @@ write(ostream &out, int indent_level) const {
case F_depth_stencil:
out << "depth_stencil";
break;
case F_depth_component:
out << "depth_component";
break;
case F_rgba:
out << "rgba";
@ -1844,6 +1848,7 @@ adjust_size(int &x_size, int &y_size, const string &name) {
break;
case ATS_none:
case ATS_UNSPECIFIED:
break;
}
@ -1857,6 +1862,7 @@ adjust_size(int &x_size, int &y_size, const string &name) {
break;
case ATS_none:
case ATS_UNSPECIFIED:
break;
}
@ -2598,7 +2604,7 @@ do_read_dds(istream &in, const string &filename, bool header_only) {
TextureType texture_type;
if (header.caps.caps2 & DDSCAPS2_CUBEMAP) {
static const int all_faces =
static const unsigned int all_faces =
(DDSCAPS2_CUBEMAP_POSITIVEX |
DDSCAPS2_CUBEMAP_POSITIVEY |
DDSCAPS2_CUBEMAP_POSITIVEZ |
@ -3426,10 +3432,15 @@ do_compress_ram_image(Texture::CompressionMode compression,
case Texture::F_rgba:
case Texture::F_rgba8:
case Texture::F_rgba12:
case Texture::F_rgba16:
case Texture::F_rgba32:
if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt5)) {
compression = CM_dxt5;
}
break;
default:
break;
}
}
@ -3798,6 +3809,7 @@ do_set_format(Texture::Format format) {
switch (_format) {
case F_color_index:
case F_depth_stencil:
case F_depth_component:
case F_red:
case F_green:
case F_blue:
@ -4167,7 +4179,7 @@ get_ram_image_as(const string &requested_format) {
}
int imgsize = _x_size * _y_size;
nassertr(_num_components > 0 && _num_components <= 4, CPTA_uchar(get_class_type()));
nassertr(data.size() == _component_width * _num_components * imgsize, CPTA_uchar(get_class_type()));
nassertr(data.size() == (size_t)(_component_width * _num_components * imgsize), CPTA_uchar(get_class_type()));
// Check if the format is already what we have internally.
if ((_num_components == 1 && format.size() == 1) ||
@ -4942,7 +4954,7 @@ read_dds_level_dxt1(Texture *tex, const DDSHeader &header, int n, istream &in) {
if (n == 0) {
if (header.dds_flags & DDSD_LINEARSIZE) {
nassertr(linear_size == header.pitch, PTA_uchar());
nassertr(linear_size == (int)header.pitch, PTA_uchar());
}
}
@ -5015,7 +5027,7 @@ read_dds_level_dxt23(Texture *tex, const DDSHeader &header, int n, istream &in)
if (n == 0) {
if (header.dds_flags & DDSD_LINEARSIZE) {
nassertr(linear_size == header.pitch, PTA_uchar());
nassertr(linear_size == (int)header.pitch, PTA_uchar());
}
}
@ -5103,7 +5115,7 @@ read_dds_level_dxt45(Texture *tex, const DDSHeader &header, int n, istream &in)
if (n == 0) {
if (header.dds_flags & DDSD_LINEARSIZE) {
nassertr(linear_size == header.pitch, PTA_uchar());
nassertr(linear_size == (int)header.pitch, PTA_uchar());
}
}
@ -6265,6 +6277,8 @@ operator << (ostream &out, Texture::Format f) {
switch (f) {
case Texture::F_depth_stencil:
return out << "depth_stencil";
case Texture::F_depth_component:
return out << "depth_component";
case Texture::F_color_index:
return out << "color_index";
case Texture::F_red:

View File

@ -94,6 +94,7 @@ TexturePeeker(Texture *tex) {
switch (_format) {
case Texture::F_depth_stencil:
case Texture::F_depth_component:
case Texture::F_color_index:
// Not supported.
_image.clear();

View File

@ -44,5 +44,5 @@
#define APIENTRYP *
#include "glstuff_src.h"
#endif // GLESGSG_H

View File

@ -14,7 +14,6 @@
#ifndef IPHONEGRAPHICSSTATEGUARDIAN_H
#define IPHONEGRAPHICSSTATEGUARDIAN_H
//#include <ApplicationServices/ApplicationServices.h>
#include "pandabase.h"
#include "glesgsg.h"
@ -34,9 +33,6 @@ public:
virtual ~IPhoneGraphicsStateGuardian();
virtual void reset();
void draw_resize_box();
protected:
virtual void *get_extension_func(const char *prefix, const char *name);

View File

@ -21,8 +21,6 @@
#include "pnmImage.h"
#include "glesgsg.h"
#import <mach-o/dyld.h>
TypeHandle IPhoneGraphicsStateGuardian::_type_handle;
////////////////////////////////////////////////////////////////////
@ -74,20 +72,6 @@ reset() {
GLESGraphicsStateGuardian::reset();
}
////////////////////////////////////////////////////////////////////
// Function: IPhoneGraphicsStateGuardian::draw_resize_box
// Access: Public, Virtual
// Description: Draws an OSX-style resize icon in the bottom right
// corner of the current display region. This is
// normally done automatically at the end of each frame
// when the window is indicated as resizable, since the
// 3-D graphics overlay the normal, OS-drawn resize icon
// and the user won't be able see it.
////////////////////////////////////////////////////////////////////
void IPhoneGraphicsStateGuardian::
draw_resize_box() {
}
////////////////////////////////////////////////////////////////////
// Function: IPhoneGraphicsStateGuardian::describe_pixel_format
// Access: Private

View File

@ -20,28 +20,10 @@
extern "C" int main(int argc, char *argv[]);
int main(int argc, char *argv[]) {
// This is weird and hacky. We have our main application not link
// statically with any Panda code. Instead, it dynamically loads in
// the required Panda code during main().
int
main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// We need to do this to avoid static-init ordering issues. Cocoa
// doesn't fully initialize all its low-level memory-allocation
// stuff until main begins or NSApplicationLoad() is called, but
// unfortunately NSApplicationLoad() doesn't exist on the IPhone.
// So on the IPhone, we have to be sure we don't make any calls into
// Panda (which might make a low-level Cocoa call) until after we
// have started main().
setenv("DYLD_LIBRARY_PATH", "/Applications/pview.app", 1);
void *answer = dlopen("/Applications/pview.app/libiphone_pview.dylib", RTLD_NOW | RTLD_LOCAL);
if (answer == (void *)NULL) {
std::cerr << "Couldn't load dylib\n";
exit(1);
}
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
/* Call with the name of our application delegate class */
int retVal = UIApplicationMain(argc, argv, nil, @"ControllerDemoAppDelegate");
[pool release];

View File

@ -24,22 +24,9 @@
@synthesize animationInterval;
PandaFramework framework;
int startup = 0;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
int argc = 0;
char **argv = NULL;
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window();
if (window != (WindowFramework *)NULL) {
window->enable_keyboard();
window->setup_trackball();
framework.get_models().instance_to(window->get_render());
window->load_default_model(framework.get_models());
window->center_trackball(framework.get_models());
}
animationInterval = 1.0 / 60.0;
[self startAnimation];
}
@ -70,9 +57,29 @@ PandaFramework framework;
}
- (void)drawView {
Thread *current_thread = Thread::get_current_thread();
framework.do_frame(current_thread);
}
if (startup == 0) {
int argc = 0;
char **argv = NULL;
framework.open_framework(argc, argv);
startup = 1;
} else if (startup == 1) {
WindowFramework *window = framework.open_window();
if (window != (WindowFramework *)NULL) {
window->enable_keyboard();
window->setup_trackball();
framework.get_models().instance_to(window->get_render());
window->load_default_model(framework.get_models());
window->center_trackball(framework.get_models());
}
startup = 2;
} else {
Thread *current_thread = Thread::get_current_thread();
framework.do_frame(current_thread);
}
}
- (void)dealloc {
[self stopAnimation];

View File

@ -58,7 +58,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
xy = normalize(xy);
// Compute the rotation about the +Z (back) axis. This is roll.
FLOATTYPE roll = rad_2_deg(((FLOATTYPE)atan2(xy[1], xy[0])));
FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
// Unwind the roll from the axes, and continue.
Matrix rot_z;
@ -75,7 +75,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
// Compute the rotation about the +Y (up) axis. This is yaw, or
// "heading".
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)-atan2(xz[1], xz[0])));
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)-catan2(xz[1], xz[0])));
// Unwind the heading, and continue.
Matrix rot_y;
@ -91,7 +91,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
yz = normalize(yz);
// Compute the rotation about the +X (right) axis. This is pitch.
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)-atan2(yz[0], yz[1])));
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)-catan2(yz[0], yz[1])));
// Unwind the pitch.
Matrix rot_x;
@ -139,7 +139,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
xz = normalize(xz);
// Compute the rotation about the -Y (back) axis. This is roll.
FLOATTYPE roll = rad_2_deg(((FLOATTYPE)atan2(xz[1], xz[0])));
FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0])));
if (y[1] < 0.0f) {
if (roll < 0.0f) {
@ -164,7 +164,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
// Compute the rotation about the +Z (up) axis. This is yaw, or
// "heading".
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)atan2(xy[1], xy[0])));
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
// Unwind the heading, and continue.
Matrix rot_z;
@ -180,7 +180,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
yz = normalize(yz);
// Compute the rotation about the +X (right) axis. This is pitch.
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)atan2(yz[1], yz[0])));
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
// Unwind the pitch.
Matrix rot_x;
@ -369,7 +369,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
// Compute the rotation about the +Y (up) axis. This is yaw, or
// "heading".
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)atan2(xz[0], xz[1])));
FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xz[0], xz[1])));
// Unwind the heading, and continue.
Matrix rot_y;
@ -385,7 +385,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
yz = normalize(yz);
// Compute the rotation about the +X (right) axis. This is pitch.
FLOATTYPE pitch = rad_2_deg((FLOATTYPE)(-atan2(yz[0], yz[1])));
FLOATTYPE pitch = rad_2_deg((FLOATTYPE)(-catan2(yz[0], yz[1])));
// Unwind the pitch.
Matrix rot_x;
@ -401,7 +401,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
xy = normalize(xy);
// Compute the rotation about the +Z (back) axis. This is roll.
FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)atan2(xy[1], xy[0])));
FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
// Unwind the roll from the axes, and continue.
Matrix rot_z;
@ -449,7 +449,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
// Compute the rotation about the +Z (up) axis. This is yaw, or
// "heading".
FLOATTYPE heading = -rad_2_deg(((FLOATTYPE)atan2(xy[0], xy[1])));
FLOATTYPE heading = -rad_2_deg(((FLOATTYPE)catan2(xy[0], xy[1])));
// Unwind the heading, and continue.
Matrix rot_z;
@ -465,7 +465,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
yz = normalize(yz);
// Compute the rotation about the +X (right) axis. This is pitch.
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)atan2(yz[1], yz[0])));
FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
// Unwind the pitch.
Matrix rot_x;
@ -481,7 +481,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
xz = normalize(xz);
// Compute the rotation about the -Y (back) axis. This is roll.
FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)atan2(xz[1], xz[0])));
FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0])));
// Unwind the roll from the axes, and continue.
Matrix rot_y;

View File

@ -29,6 +29,7 @@ TypeHandle MovieVideoCursor::_type_handle;
////////////////////////////////////////////////////////////////////
MovieVideoCursor::
MovieVideoCursor(MovieVideo *src) :
_conversion_buffer(0),
_source(src),
_size_x(1),
_size_y(1),
@ -39,7 +40,6 @@ MovieVideoCursor(MovieVideo *src) :
_aborted(false),
_last_start(-1.0),
_next_start(0.0),
_conversion_buffer(0),
_streaming(false),
_ready(false)
{

View File

@ -28,8 +28,8 @@ UserDataAudio(int rate, int channels) :
MovieAudio("User Data Audio"),
_desired_rate(rate),
_desired_channels(channels),
_aborted(false),
_cursor(NULL)
_cursor(NULL),
_aborted(false)
{
}

View File

@ -20,6 +20,7 @@
#include "conditionVarImpl.h"
#include "thread.h"
#include "namable.h"
#include "pmap.h"
#ifdef DEBUG_THREADS