libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] Bugfixes for libCVD when building on OSX 10.6


From: Robert Castle
Subject: [libcvd-members] Bugfixes for libCVD when building on OSX 10.6
Date: Fri, 30 Sep 2011 15:42:13 +0100

Hi,

I have been working on getting libCVD to build on OSX 10.6 and have
found a few bugs. Apologies for the horribly mangled code.
With the following changes libCVD builds happily.
I am using the latest CVS version, checked out today (Sept 30th 2011).
I am using 10.6.8 and have Xcode 4 installed, so I only have
MacOSX10.6.sdk installed


1) pnm_src/pnm_grok.cxx line 634
change 'n' to 'n_shorts'

----------------------------

2) cvd_src/Linux/dvbuffer3_dc1394v2.cc
lines 131 and 158
add ULL to the long numbers
0x814436200006075ULL

----------------------------

3) cvd/gl_helpers.h
As libCVD is now linking to the Apple OpenGL framework and not the X11
headers the #includes need to be updated. I specify a define of _OSX
in the configure, as this ties up with PTAM. I don't know if there is
already a define for OSX in libCVD (I could not find one)

change
#include <GL/gl.h>
#include <GL/glu.h>

to

#ifdef _OSX
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif

----------------------------

The last two changes are required by the OpenGL change. Apple's gl
files do not have GL_TEXTURE_RECTANGLE_NV defined so we need to make
this a bit more platform agnostic. I have not tested these changes on
Linux or Windows, but I think they should be fine.

progs/calibrate.cxx line 813

Replace the block of gl code between the GL_BLENDs with this. All it
changes is GL_TEXTURE_RECTANGLE_NV into texTarget and adds the #ifdefs
to the top.


GLenum texTarget;
#ifdef GL_TEXTURE_RECTANGLE_ARB
texTarget=GL_TEXTURE_RECTANGLE_ARB;
#else
#ifdef GL_TEXTURE_RECTANGLE_NV
texTarget=GL_TEXTURE_RECTANGLE_NV;
#else
texTarget=GL_TEXTURE_RECTANGLE_EXT;
#endif
#endif
glEnable(texTarget);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf( texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameterf( texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(temp, 0, texTarget);
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0,0);
glTexCoord2i(temp.size().x, 0);
glVertex2i(disp.size().x,0);
glTexCoord2i(temp.size().x,temp.size().y);
glVertex2i(disp.size().x,disp.size().y);
glTexCoord2i(0, temp.size().y);
glVertex2i(0, disp.size().y);
glEnd ();
glDisable(texTarget);


----------------------------


progs/video_play_source.cc line 73

This is a similar change to the last, replacing the
GL_TEXTURE_RECTANGLE_NV entries

GLenum texTarget;
#ifdef GL_TEXTURE_RECTANGLE_ARB
texTarget=GL_TEXTURE_RECTANGLE_ARB;
#else
#ifdef GL_TEXTURE_RECTANGLE_NV
texTarget=GL_TEXTURE_RECTANGLE_NV;
#else
texTarget=GL_TEXTURE_RECTANGLE_EXT;
#endif
#endif
glEnable(texTarget);
for(;;)
{
display.get_events(e);
if(e.should_quit())
break;
VideoFrame<C>* frame = buffer->get_frame();
glViewport(0, 0, display.size().x, display.size().y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glRasterPos2f(-1, 1);
glOrtho(-0.375, display.size().x-0.375, display.size().y-0.375,
-0.375, -1 , 1); //offsets to make (0,0) the top left pixel (rather
than off the display)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf( texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameterf( texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(*frame, 0, texTarget);
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0,0);
glTexCoord2i(frame->size().x, 0);
glVertex2i(display.size().x,0);
glTexCoord2i(frame->size().x,frame->size().y);
glVertex2i(display.size().x,display.size().y);
glTexCoord2i(0, frame->size().y);
glVertex2i(0, display.size().y);
glEnd ();

if(f)
{
cout << "frame size: " << frame->size() << endl;
f=0;
}
buffer->put_frame(frame);
glFlush();
display.swap_buffers();
}
glDisable(texTarget);


----------------------------

Finally, to anyone who is interested, this is the configure script i
use to built libCVD and GVars as 32-bit on a Mac. Change the two
MacOSX10.6.sdk entries to match the SDK you have installed. I have
only tested this on 10.5 and 10.6.

#!/bin/bash
#This script forces Snow Leopard (10.6) to build using Leopard (10.5)
and to build a 32 bit build.
# Use it when building livCVD, GVars, and lib3ds
#
# Originally wirrten by Damian Stewart
# http://lists.nongnu.org/archive/html/libcvd-members/2010-05/msg00000.html
# Modified by Robert Castle

SDK="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
SDKLIB="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
export MACOSX_DEPLOYMENT_TARGET="10.5"

ARCH="-arch i386"

export CFLAGS="$ARCH $SDK -mmacosx-version-min=10.5 -m32 -D_OSX"
export CXXFLAGS="$ARCH $SDK -mmacosx-version-min=10.5 -m32 -D_OSX"
export CPPFLAGS="$ARCH $SDK -mmacosx-version-min=10.5 -m32 -D_OSX"
export LDFLAGS="$ARCH $SDKLIB -mmacosx-version-min=10.5 -m32"

CC="/usr/bin/gcc-4.2"
CXX="/usr/bin/g++-4.2"
OBJC="/usr/bin/gcc-4.2"

./configure $1 $2 $3 $4 $5 $6 $7 $8 $9


----------------------------


Regards,
Robert.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]