[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd gl_helpers.h
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd/cvd gl_helpers.h |
Date: |
Fri, 18 Feb 2011 11:39:34 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 11/02/18 11:39:34
Modified files:
cvd : gl_helpers.h
Log message:
Compute alignment in glDrawPixels to work around buggy drivers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/gl_helpers.h?cvsroot=libcvd&r1=1.47&r2=1.48
Patches:
Index: gl_helpers.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/gl_helpers.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- gl_helpers.h 12 Nov 2010 14:07:31 -0000 1.47
+++ gl_helpers.h 18 Feb 2011 11:39:34 -0000 1.48
@@ -23,6 +23,7 @@
#include <iostream>
#include <map>
+#include <utility>
#include <cvd/image_ref.h>
#include <cvd/image.h>
@@ -523,13 +524,31 @@
glColor4f(c.red, c.green, c.blue, c.alpha);
}
+ namespace Internal{
+ static inline int alignof(const void* ptr)
+ {
+ size_t p = (size_t)ptr;
+
+ if(p&3)
+ if(p&1)
+ return 1;
+ else
+ return 2;
+ else
+ if(p&4)
+ return 4;
+ else
+ return 8;
+ }
+ }
+
/// Draw an image to the frame buffer at the current raster position.
/// Use glRasterPos to set the current raster position
/// @param i The image to draw
///@ingroup gGL
template<class C> inline void glDrawPixels(const SubImage<C>& i)
{
- ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ ::glPixelStorei(GL_UNPACK_ALIGNMENT,
std::min(Internal::alignof(i[0]), Internal::alignof(i[1])));
::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.row_stride());
::glDrawPixels(i.size().x, i.size().y, gl::data<C>::format,
gl::data<C>::type, i.data());
::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd/cvd gl_helpers.h,
Edward Rosten <=