[Igarden-commit] CommonSource/YAAFExtensions RGGLView.h, 1.9.2.1, 1.9.2.2 RGGLView.cpp, 1.11.2.1, 1
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2006-11-11 15:00:01
|
Update of /cvsroot/igarden/CommonSource/YAAFExtensions In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv23895 Modified Files: Tag: Release_branch_v1 RGGLView.h RGGLView.cpp Log Message: Split tessellation object off of RGGLView Index: RGGLView.cpp =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGGLView.cpp,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.2 diff -C2 -d -r1.11.2.1 -r1.11.2.2 *** RGGLView.cpp 5 Nov 2006 02:34:23 -0000 1.11.2.1 --- RGGLView.cpp 11 Nov 2006 14:59:56 -0000 1.11.2.2 *************** *** 42,65 **** typedef GLvoid (*CallBackFunc)(...); - static GLvoid beginCallback(GLenum which); - static void errorCallback(GLenum errorCode); - static GLvoid endCallback(void); - static GLvoid vertexCallback(GLvoid *vertex); - static GLvoid combineCallback(GLdouble coords[3], - GLdouble *vertex_data[4], - GLfloat weight[4], GLdouble **dataOut ); ! long RGGLView::_tessBufSize; ! long RGGLView::_tessBufFilled; ! GLdouble *RGGLView::_tessBuf; ! GLdouble *RGGLView::_tessPtr; ! GLdouble RGGLView::_xOrigin; ! GLdouble RGGLView::_yOrigin; ! GLdouble RGGLView::_xSize; ! GLdouble RGGLView::_ySize; ! GLint RGGLView::_list; ! ! ! GLUtesselator *RGGLView::_tessObj = NULL; // --------------------------------------------------------------------------- --- 42,48 ---- typedef GLvoid (*CallBackFunc)(...); ! XGArena RGTessellator::_tessBuf; ! GLUtesselator *RGTessellator::_tessObj = NULL; // --------------------------------------------------------------------------- *************** *** 497,501 **** } ! void RGGLView::BeginTesselation(GLint list, long numPoints, double xOrigin, double yOrigin, double xSize, double ySize) { if(_tessObj == NULL) --- 480,525 ---- } ! RGGLBitmapFont *RGGLView::CreateBitmapFont(XGFont *fontPtr) ! { ! long n, count; ! RGGLBitmapFont *test, *result = NULL; ! char fontName[512]; ! short style, pointSize; ! ! fontPtr->GetFontName(fontName); ! style = fontPtr->GetFontFlags(); ! pointSize = fontPtr->GetFontSize(); ! count = _allFonts.Length(); ! for(n = 0; (n < count) && result == NULL; n++) ! { ! test = _allFonts[n]; ! if(test->GetContext() == aglGetCurrentContext()) ! { ! if(test->Matches(fontName, style, pointSize)) ! result = test; ! } ! } ! ! if(result == NULL) ! { ! result = new RGGLBitmapFont::RGGLBitmapFont(fontPtr); ! _allFonts.push_back(result); ! } ! ! return result; ! } ! ! ! #pragma mark *** RGTessellator *** ! ! RGTessellator::RGTessellator() ! { ! } ! ! RGTessellator::~RGTessellator() ! { ! } ! ! void RGTessellator::Begin(GLint list, long numPoints, double xOrigin, double yOrigin, double xSize, double ySize) { if(_tessObj == NULL) *************** *** 511,520 **** _list = list; - _tessBufSize = numPoints; - _tessBufFilled = 0; - _tessBuf = new GLdouble[numPoints*5]; - _tessPtr = _tessBuf; gluTessBeginPolygon(_tessObj, NULL); ! glNewList(_list, GL_COMPILE); _xOrigin = xOrigin; _yOrigin = yOrigin; --- 535,541 ---- _list = list; gluTessBeginPolygon(_tessObj, NULL); ! if(_list != 0) ! glNewList(_list, GL_COMPILE); _xOrigin = xOrigin; _yOrigin = yOrigin; *************** *** 523,596 **** } ! void RGGLView::BeginTessContour() { gluTessBeginContour(_tessObj); } ! void RGGLView::AddTessPoint(double x, double y, double z) { ! GLdouble *start; ! PRECONDITION(_tessBufFilled < _tessBufSize); ! start = _tessPtr; ! *_tessPtr++ = x; ! *_tessPtr++ = y; ! *_tessPtr++ = z; ! *_tessPtr++ = (x - _xOrigin) / _xSize; ! *_tessPtr++ = (y - _yOrigin) / _ySize; ! gluTessVertex (_tessObj, start, start); ! _tessBufFilled++; } ! void RGGLView::EndTessContour() { gluTessEndContour(_tessObj); } ! void RGGLView::EndTesselation() { gluTessEndPolygon(_tessObj); ! glEndList(); ! delete [] _tessBuf; ! } ! ! RGGLBitmapFont *RGGLView::CreateBitmapFont(XGFont *fontPtr) ! { ! long n, count; ! RGGLBitmapFont *test, *result = NULL; ! char fontName[512]; ! short style, pointSize; ! ! fontPtr->GetFontName(fontName); ! style = fontPtr->GetFontFlags(); ! pointSize = fontPtr->GetFontSize(); ! count = _allFonts.Length(); ! for(n = 0; (n < count) && result == NULL; n++) ! { ! test = _allFonts[n]; ! if(test->GetContext() == aglGetCurrentContext()) ! { ! if(test->Matches(fontName, style, pointSize)) ! result = test; ! } ! } ! ! if(result == NULL) ! { ! result = new RGGLBitmapFont::RGGLBitmapFont(fontPtr); ! _allFonts.push_back(result); ! } ! ! return result; } ! ! static GLvoid beginCallback(GLenum which) { glBegin(which); } ! static void errorCallback(GLenum errorCode) { const GLubyte *estring; --- 544,586 ---- } ! void RGTessellator::BeginContour() { gluTessBeginContour(_tessObj); } ! void RGTessellator::AddPoint(double x, double y, double z) { ! MyVertexData_t *vertex; ! vertex = AllocVertex(); ! vertex->x = x; ! vertex->y = y; ! vertex->z = z; ! vertex->textureX = (x - _xOrigin) / _xSize; ! vertex->textureY = (y - _yOrigin) / _ySize; ! gluTessVertex (_tessObj, reinterpret_cast<GLdouble*>(vertex), vertex); } ! void RGTessellator::EndContour() { gluTessEndContour(_tessObj); } ! void RGTessellator::End() { + if(_list != 0) + glEndList(); gluTessEndPolygon(_tessObj); ! _tessBuf.FreeAll(); } + #pragma mark *** RGTessellator (PRIVATE) *** ! GLvoid RGTessellator::beginCallback(GLenum which) { glBegin(which); } ! void RGTessellator::errorCallback(GLenum errorCode) { const GLubyte *estring; *************** *** 601,615 **** } ! static GLvoid endCallback(void) { glEnd(); } ! static GLvoid vertexCallback(GLvoid *vertex) ! { ! double *vPtr = (double*)vertex; ! ! glTexCoord2f(vPtr[3], vPtr[4]); ! glVertex3dv(vPtr); } --- 591,603 ---- } ! GLvoid RGTessellator::endCallback(void) { glEnd(); } ! GLvoid RGTessellator::vertexCallback(MyVertexData_t *vertex) ! { ! glTexCoord2d(vertex->textureX, vertex->textureY); ! glVertex3d(vertex->x, vertex->y, vertex->z); } *************** *** 619,654 **** * coordinate data. In this program, color is weighted. */ ! static GLvoid combineCallback(GLdouble coords[3], ! GLdouble *vertex_data[4], ! GLfloat weight[4], GLdouble **dataOut ) { ! GLdouble *vertex, oneVert, oneDatum; ! GLfloat oneWeight; ! int i; ! ! vertex = (GLdouble *) malloc(5 * sizeof(GLdouble)); ! vertex[0] = coords[0]; ! vertex[1] = coords[1]; ! vertex[2] = coords[2]; ! for (i = 3; i < 5; i++) { ! oneWeight = weight[0]; ! oneDatum = vertex_data[0][i]; ! oneVert = oneWeight * oneDatum; ! /**/ ! oneWeight = weight[1]; ! oneDatum = vertex_data[1][i]; ! oneVert += oneWeight * oneDatum; ! /**/ ! oneWeight = weight[2]; ! oneDatum = vertex_data[2][i]; ! oneVert += oneWeight * oneDatum; ! /**/ ! oneWeight = weight[3]; ! oneDatum = vertex_data[3][i]; ! oneVert += oneWeight * oneDatum; ! /**/ ! vertex[i] = oneVert; } *dataOut = vertex; --- 607,630 ---- * coordinate data. In this program, color is weighted. */ ! GLvoid RGTessellator::combineCallback(GLdouble coords[3], ! MyVertexData_t *vertex_data[4], ! GLfloat weight[4], MyVertexData_t **dataOut ) { ! MyVertexData_t *vertex; ! long n; ! vertex = AllocVertex(); ! vertex->x = coords[0]; ! vertex->y = coords[1]; ! vertex->z = coords[2]; ! vertex->textureX = 0; ! vertex->textureY = 0; ! for(n = 0; n < 4; n++) { ! if(vertex_data[n] != NULL) ! { ! vertex->textureX += weight[n]*vertex_data[n]->textureX; ! vertex->textureY += weight[n]*vertex_data[n]->textureY; ! } } *dataOut = vertex; Index: RGGLView.h =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGGLView.h,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -C2 -d -r1.9.2.1 -r1.9.2.2 *** RGGLView.h 5 Nov 2006 02:34:23 -0000 1.9.2.1 --- RGGLView.h 11 Nov 2006 14:59:56 -0000 1.9.2.2 *************** *** 37,43 **** --- 37,45 ---- #include <AGL/agl.h> #include <XGView.h> + #include <XGArena.h> #include "RGGLBitmapFont.h" using yaaf::XGView; + using yaaf::XGArena; using yaaf::XGArgStream; using yaaf::XGSViewInitRecord; *************** *** 79,83 **** } glRectangle_t; ! class RGGLView : public XGView { public: --- 81,125 ---- } glRectangle_t; ! typedef struct ! { ! double x; ! double y; ! double z; ! double textureX; ! double textureY; ! } MyVertexData_t; ! ! class RGTessellator ! { ! public: ! RGTessellator(); ! ~RGTessellator(); ! void Begin(GLint list, long numPoints, double xOrigin, double yOrigin, double xSize, double ySize); ! void BeginContour(); ! void AddPoint(double x, double y, double z); ! void EndContour(); ! void End(); ! static MyVertexData_t *AllocVertex() { return static_cast<MyVertexData_t*>(_tessBuf.Alloc(sizeof(MyVertexData_t))); } ! ! private: ! static GLvoid beginCallback(GLenum which); ! static void errorCallback(GLenum errorCode); ! static GLvoid endCallback(void); ! static GLvoid vertexCallback(MyVertexData_t *vertex); ! static GLvoid combineCallback(GLdouble coords[3], ! MyVertexData_t *vertex_data[4], ! GLfloat weight[4], MyVertexData_t **dataOut ); ! GLdouble _xOrigin; ! GLdouble _yOrigin; ! GLdouble _xSize; ! GLdouble _ySize; ! GLint _list; ! long _tessBufSize; ! long _tessBufFilled; ! static GLUtesselator *_tessObj; ! static XGArena _tessBuf; ! }; ! ! class RGGLView : public XGView { public: *************** *** 86,94 **** virtual ~RGGLView(); private: ! RGGLView& RGGLView::operator=(const RGGLView& p); ! RGGLView(const RGGLView& p); // copy constructor ! void Init(); public: ! void Swap() { aglSwapBuffers (_winGLContext); } virtual void Activate(); virtual void Deactivate(); --- 128,136 ---- virtual ~RGGLView(); private: ! RGGLView& RGGLView::operator=(const RGGLView& p); ! RGGLView(const RGGLView& p); // copy constructor ! void Init(); public: ! void Swap() { aglSwapBuffers (_winGLContext); } virtual void Activate(); virtual void Deactivate(); *************** *** 111,150 **** AGLContext SetupOffscreen(Rect& printRect, CGWorld *world ); void FinishOffscreen( Rect& printRect, CGWorld *world, AGLContext saveContext ); ! void Draw(); void DrawSpecial( Rect& printRect ); void DrawToCGWorld( Rect& printRect, CGWorld *world ); ! ! static void BeginTesselation(GLint list, long numPoints, double xOrigin, double yOrigin, double xSize, double ySize); ! static void BeginTessContour(); ! static void AddTessPoint(double x, double y, double z); ! static void EndTessContour(); ! static void EndTesselation(); ! RGGLBitmapFont* CreateBitmapFont(XGFont *fontPtr); ! private: #if OPT_MACOS ! AGLPixelFormat _printFmt; AGLContext _printCtx; CGWorld *_printfOffscreen; #endif ! recCamera_t _camera; ! AGLPixelFormat _aglPixFmt; ! AGLContext _winGLContext; ! double _defaultScale; ! double _curScale; ! static long _tessBufSize; ! static long _tessBufFilled; ! static GLdouble *_tessBuf; ! static GLdouble *_tessPtr; ! static GLdouble _xOrigin; ! static GLdouble _yOrigin; ! static GLdouble _xSize; ! static GLdouble _ySize; ! static GLint _list; ! bool _active; ! static GLUtesselator *_tessObj; XGDynArray<RGGLBitmapFont *> _allFonts; }; --- 153,177 ---- AGLContext SetupOffscreen(Rect& printRect, CGWorld *world ); void FinishOffscreen( Rect& printRect, CGWorld *world, AGLContext saveContext ); ! void Draw(); void DrawSpecial( Rect& printRect ); void DrawToCGWorld( Rect& printRect, CGWorld *world ); ! RGGLBitmapFont* CreateBitmapFont(XGFont *fontPtr); ! RGTessellator tessellation; ! private: #if OPT_MACOS ! AGLPixelFormat _printFmt; AGLContext _printCtx; CGWorld *_printfOffscreen; #endif ! recCamera_t _camera; ! AGLPixelFormat _aglPixFmt; ! AGLContext _winGLContext; ! double _defaultScale; ! double _curScale; ! bool _active; XGDynArray<RGGLBitmapFont *> _allFonts; }; |