Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
+197
View File
@@ -0,0 +1,197 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_GL_gl_functions
#define toolx_GL_gl_functions
#ifndef GL_VERSION_1_1
#error You have to include OpenGL header(s) before including this file.
#endif
namespace toolx {
namespace GL {
#ifdef TOOLS_USE_GL_VERSION_3_2
class gl_functions {
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {return true;}
public:
/*GL_VERSION_1_1*/
void gl__BindTexture(GLenum target, GLuint texture) {::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {::glClear(mask);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {::glDisable(cap);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {::glEnable(cap);}
void gl__FrontFace(GLenum mode) {::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {::glGenTextures(n,textures);}
GLenum gl__GetError() {return ::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {::glGetIntegerv(pname,params);}
const GLubyte * gl__GetString(GLenum name) {return ::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return ::glIsTexture(texture);}
void gl__LineWidth(GLfloat width) {::glLineWidth(width);}
void gl__PixelStorei(GLenum pname, GLint param) {::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {::glTexParameteri(target,pname,param);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {::glDepthMask(flag);}
/*GL_VERSION_1_5*/
void gl__GenBuffers(GLsizei n, GLuint *buffers) {::glGenBuffers(n,buffers);}
void gl__BindBuffer(GLenum target, GLuint buffer) {::glBindBuffer(target,buffer);}
void gl__DeleteBuffers(GLsizei n, const GLuint *buffers) {::glDeleteBuffers(n,buffers);}
void gl__BufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {::glBufferData(target,size,data,usage);}
void gl_EnableVertexAttribArray(GLuint index) {::glEnableVertexAttribArray(index);}
void gl__DisableVertexAttribArray(GLuint index) {::glDisableVertexAttribArray(index);}
void gl__EnableVertexAttribArray(GLuint index) {::glEnableVertexAttribArray(index);}
GLboolean gl__IsBuffer(GLuint buffer) {return ::glIsBuffer(buffer);}
/*GL_VERSION_2_0*/
GLuint gl__CreateProgram() {return ::glCreateProgram();}
void gl__DeleteProgram(GLuint program) {::glDeleteProgram(program);}
void gl__UseProgram(GLuint program) {::glUseProgram(program);}
void gl__LinkProgram(GLuint program) {::glLinkProgram(program);}
void gl__GetProgramiv(GLuint program, GLenum pname, GLint *params) {::glGetProgramiv(program,pname,params);}
void gl__Uniform1i(GLint location, GLint v0) {::glUniform1i(location,v0);}
void gl__Uniform1f(GLint location, GLfloat v0) {::glUniform1f(location,v0);}
void gl__Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {::glUniform3f(location,v0,v1,v2);}
void gl__Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {::glUniform4f(location,v0,v1,v2,v3);}
void gl__UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {::glUniformMatrix4fv(location,count,transpose,value);}
void gl__glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {::glUniformMatrix4fv(location,count,transpose,value);}
GLint gl__GetUniformLocation(GLuint program, const GLchar *name) {return ::glGetUniformLocation(program,name);}
void gl__ShaderSource(GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length) {::glShaderSource(shader,count,string,length);}
GLboolean gl__IsShader(GLuint shader) {return ::glIsShader(shader);}
void gl__GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {return ::glGetShaderSource(shader,bufSize,length,source);}
void gl__GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {::glGetShaderInfoLog(shader,bufSize,length,infoLog);}
void gl__GetShaderiv(GLuint shader, GLenum pname, GLint *params) {::glGetShaderiv(shader,pname,params);}
void gl__GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) {::glGetAttachedShaders(program,maxCount,count,obj);}
void gl__DetachShader(GLuint program, GLuint shader) {::glDetachShader(program,shader);}
void gl__DeleteShader(GLuint shader) {::glDeleteShader(shader);}
GLuint gl__CreateShader(GLenum type) {return ::glCreateShader(type);}
void gl__CompileShader(GLuint shader) {::glCompileShader(shader);}
void gl__AttachShader(GLuint program, GLuint shader) {::glAttachShader(program,shader);}
void gl__VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) {::glVertexAttribPointer(index,size,type,normalized,stride,pointer);}
GLint gl__GetAttribLocation(GLuint program, const GLchar *name) {return ::glGetAttribLocation(program,name);}
/*GL_VERSION_3_0*/
void gl__BindVertexArray(GLuint array) {::glBindVertexArray(array);}
void gl__GenVertexArrays(GLsizei n, GLuint *arrays) {::glGenVertexArrays(n,arrays);}
void gl__DeleteVertexArrays(GLsizei n, const GLuint *arrays) {::glDeleteVertexArrays(n,arrays);}
GLboolean gl__IsVertexArray(GLuint array) {return ::glIsVertexArray(array);}
/*GL_VERSION_3_0*/
GLenum gl__CheckFramebufferStatus(GLenum target) {return ::glCheckFramebufferStatus(target);}
};
#else //not TOOLS_USE_GL_VERSION_3_2
class gl_functions {
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {return true;}
public:
/*GL_VERSION_1_1*/
void gl__Accum(GLenum op, GLfloat value) {::glAccum(op,value);}
void gl__Begin(GLenum mode) {::glBegin(mode);}
void gl__BindTexture(GLenum target, GLuint texture) {::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {::glClear(mask);}
void gl__ClearIndex(GLfloat c) {::glClearIndex(c);}
void gl__ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearAccum(red,green,blue,alpha);}
void gl__Color4fv(const GLfloat *v) {::glColor4fv(v);}
void gl__Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glColor4f(red,green,blue,alpha);}
void gl__ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glColorPointer(size,type,stride,pointer);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {::glDisable(cap);}
void gl__DisableClientState(GLenum array) {::glDisableClientState(array);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {::glEnable(cap);}
void gl__EnableClientState(GLenum array) {::glEnableClientState(array);}
void gl__End() {::glEnd();}
void gl__FrontFace(GLenum mode) {::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {::glGenTextures(n,textures);}
GLenum gl__GetError() {return ::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {::glGetIntegerv(pname,params);}
void gl__GetLightfv(GLenum light, GLenum pname, GLfloat *params) {::glGetLightfv(light,pname,params);}
void gl__GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) {::glGetMaterialfv(face,pname,params);}
const GLubyte * gl__GetString(GLenum name) {return ::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return ::glIsTexture(texture);}
void gl__Lightfv(GLenum light, GLenum pname, const GLfloat *params) {::glLightfv(light,pname,params);}
void gl__Lightf(GLenum light, GLenum pname, GLfloat param) {::glLightf(light,pname,param);}
void gl__LineWidth(GLfloat width) {::glLineWidth(width);}
void gl__LoadIdentity() {::glLoadIdentity();}
void gl__LoadMatrixf(const GLfloat *m) {::glLoadMatrixf(m);}
void gl__MatrixMode(GLenum mode) {::glMatrixMode(mode);}
void gl__Normal3fv(const GLfloat *v) {::glNormal3fv(v);}
void gl__Normal3f(GLfloat nx, GLfloat ny, GLfloat nz) {::glNormal3f(nx,ny,nz);}
void gl__NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) {::glNormalPointer(type,stride,pointer);}
void gl__PixelStorei(GLenum pname, GLint param) {::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__ShadeModel(GLenum mode) {::glShadeModel(mode);}
void gl__TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glTexCoordPointer(size,type,stride,pointer);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {::glTexParameteri(target,pname,param);}
void gl__Vertex3fv(const GLfloat *v) {::glVertex3fv(v);}
void gl__Vertex3f(GLfloat x, GLfloat y, GLfloat z) {::glVertex3f(x,y,z);}
void gl__VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glVertexPointer(size,type,stride,pointer);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {::glDepthMask(flag);}
void gl__NewList(GLuint list, GLenum mode) {::glNewList(list,mode);}
void gl__DeleteLists(GLuint list, GLsizei range) {::glDeleteLists(list,range);}
void gl__CallLists(GLsizei n, GLenum type, const GLvoid *lists) {::glCallLists(n,type,lists);}
void gl__CallList(GLuint list) {::glCallList(list);}
void gl__EndList() {::glEndList();}
GLuint gl__GenLists(GLsizei range) {return ::glGenLists(range);}
GLboolean gl__IsList(GLuint list) {return ::glIsList(list);}
/*GL_VERSION_3_0*/
#ifdef __APPLE__
#ifdef __COREFOUNDATION__ //Cocoa.h included: we build a Cocoa application.
GLenum gl__CheckFramebufferStatus(GLenum target) {return ::glCheckFramebufferStatus(target);}
#endif
#endif
};
#endif //not TOOLS_USE_GL_VERSION_3_2
}}
#endif
-28
View File
@@ -1,28 +0,0 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_OpenGL
#define toolx_OpenGL
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if TARGET_OS_IPHONE
#include <OpenGLES/ES1/gl.h>
#elif defined(ANDROID)
#include <GLES/gl.h>
#elif _WIN32
#include <windows.h>
#include <GL/gl.h>
#elif __APPLE__
#if defined(TOOLX_USE_GL_GL_H) || defined(TOOLS_USE_GL_GL_H)
#include <GL/gl.h> //Macports X11 GL.
#else
#include <OpenGL/gl.h> //Apple/OpenGL.
#endif
#else
#include <GL/gl.h>
#endif
#endif
+208
View File
@@ -0,0 +1,208 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_Qt_gl_functions
#define toolx_Qt_gl_functions
#include <QtCore/qglobal.h> //For QT_VERSION.
#ifdef TOOLS_USE_GL_VERSION_3_2
#if QT_VERSION < 0x060000
#include <QtGui/QOpenGLFunctions_3_2_Core>
#else
#include <QtOpenGL/QOpenGLFunctions_3_2_Core>
#endif
namespace toolx {namespace Qt {typedef QOpenGLFunctions_3_2_Core qopengl_functions;}}
namespace toolx {
namespace Qt {
class gl_functions: protected qopengl_functions {
typedef qopengl_functions parent;
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {return parent::initializeOpenGLFunctions();}
public:
/*GL_VERSION_1_1*/
void gl__BindTexture(GLenum target, GLuint texture) {parent::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {parent::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {parent::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {parent::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {parent::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {parent::glClear(mask);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {parent::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {parent::glDisable(cap);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {parent::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {parent::glEnable(cap);}
void gl__FrontFace(GLenum mode) {parent::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {parent::glGenTextures(n,textures);}
GLenum gl__GetError() {return parent::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {parent::glGetIntegerv(pname,params);}
const GLubyte * gl__GetString(GLenum name) {return parent::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return parent::glIsTexture(texture);}
void gl__LineWidth(GLfloat width) {parent::glLineWidth(width);}
void gl__PixelStorei(GLenum pname, GLint param) {parent::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {parent::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {parent::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {parent::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {parent::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {parent::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {parent::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {parent::glTexParameteri(target,pname,param);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {parent::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {parent::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {parent::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {parent::glDepthMask(flag);}
/*GL_VERSION_1_5*/
void gl__GenBuffers(GLsizei n, GLuint *buffers) {parent::glGenBuffers(n,buffers);}
void gl__BindBuffer(GLenum target, GLuint buffer) {parent::glBindBuffer(target,buffer);}
void gl__DeleteBuffers(GLsizei n, const GLuint *buffers) {parent::glDeleteBuffers(n,buffers);}
void gl__BufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {parent::glBufferData(target,size,data,usage);}
void gl_EnableVertexAttribArray(GLuint index) {parent::glEnableVertexAttribArray(index);}
void gl__DisableVertexAttribArray(GLuint index) {parent::glDisableVertexAttribArray(index);}
void gl__EnableVertexAttribArray(GLuint index) {parent::glEnableVertexAttribArray(index);}
GLboolean gl__IsBuffer(GLuint buffer) {return parent::glIsBuffer(buffer);}
/*GL_VERSION_2_0*/
GLuint gl__CreateProgram() {return parent::glCreateProgram();}
void gl__DeleteProgram(GLuint program) {parent::glDeleteProgram(program);}
void gl__UseProgram(GLuint program) {parent::glUseProgram(program);}
void gl__LinkProgram(GLuint program) {parent::glLinkProgram(program);}
void gl__GetProgramiv(GLuint program, GLenum pname, GLint *params) {parent::glGetProgramiv(program,pname,params);}
void gl__Uniform1i(GLint location, GLint v0) {parent::glUniform1i(location,v0);}
void gl__Uniform1f(GLint location, GLfloat v0) {parent::glUniform1f(location,v0);}
void gl__Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {parent::glUniform3f(location,v0,v1,v2);}
void gl__Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {parent::glUniform4f(location,v0,v1,v2,v3);}
void gl__UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {parent::glUniformMatrix4fv(location,count,transpose,value);}
void gl__glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {parent::glUniformMatrix4fv(location,count,transpose,value);}
GLint gl__GetUniformLocation(GLuint program, const GLchar *name) {return parent::glGetUniformLocation(program,name);}
void gl__ShaderSource(GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length) {parent::glShaderSource(shader,count,string,length);}
GLboolean gl__IsShader(GLuint shader) {return parent::glIsShader(shader);}
void gl__GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {return parent::glGetShaderSource(shader,bufSize,length,source);}
void gl__GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {parent::glGetShaderInfoLog(shader,bufSize,length,infoLog);}
void gl__GetShaderiv(GLuint shader, GLenum pname, GLint *params) {parent::glGetShaderiv(shader,pname,params);}
void gl__GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) {parent::glGetAttachedShaders(program,maxCount,count,obj);}
void gl__DetachShader(GLuint program, GLuint shader) {parent::glDetachShader(program,shader);}
void gl__DeleteShader(GLuint shader) {parent::glDeleteShader(shader);}
GLuint gl__CreateShader(GLenum type) {return parent::glCreateShader(type);}
void gl__CompileShader(GLuint shader) {parent::glCompileShader(shader);}
void gl__AttachShader(GLuint program, GLuint shader) {parent::glAttachShader(program,shader);}
void gl__VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) {parent::glVertexAttribPointer(index,size,type,normalized,stride,pointer);}
GLint gl__GetAttribLocation(GLuint program, const GLchar *name) {return parent::glGetAttribLocation(program,name);}
/*GL_VERSION_3_0*/
void gl__BindVertexArray(GLuint array) {parent::glBindVertexArray(array);}
void gl__GenVertexArrays(GLsizei n, GLuint *arrays) {parent::glGenVertexArrays(n,arrays);}
void gl__DeleteVertexArrays(GLsizei n, const GLuint *arrays) {parent::glDeleteVertexArrays(n,arrays);}
GLboolean gl__IsVertexArray(GLuint array) {return parent::glIsVertexArray(array);}
GLenum gl__CheckFramebufferStatus(GLenum target) {return parent::glCheckFramebufferStatus(target);}
};
}}
#else //not TOOLS_USE_GL_VERSION_3_2
#if QT_VERSION < 0x060000
#include <QtGui/QOpenGLFunctions_1_1>
#else
#include <QtOpenGL/QOpenGLFunctions_1_1>
#endif
namespace toolx {namespace Qt {typedef QOpenGLFunctions_1_1 qopengl_functions;}}
namespace toolx {
namespace Qt {
class gl_functions: protected qopengl_functions {
typedef qopengl_functions parent;
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {return parent::initializeOpenGLFunctions();}
public:
/*GL_VERSION_1_1*/
void gl__Accum(GLenum op, GLfloat value) {parent::glAccum(op,value);}
void gl__Begin(GLenum mode) {parent::glBegin(mode);}
void gl__BindTexture(GLenum target, GLuint texture) {parent::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {parent::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {parent::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {parent::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {parent::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {parent::glClear(mask);}
void gl__ClearIndex(GLfloat c) {parent::glClearIndex(c);}
void gl__ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {parent::glClearAccum(red,green,blue,alpha);}
void gl__Color4fv(const GLfloat *v) {parent::glColor4fv(v);}
void gl__Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {parent::glColor4f(red,green,blue,alpha);}
void gl__ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {parent::glColorPointer(size,type,stride,pointer);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {parent::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {parent::glDisable(cap);}
void gl__DisableClientState(GLenum array) {parent::glDisableClientState(array);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {parent::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {parent::glEnable(cap);}
void gl__EnableClientState(GLenum array) {parent::glEnableClientState(array);}
void gl__End() {parent::glEnd();}
void gl__FrontFace(GLenum mode) {parent::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {parent::glGenTextures(n,textures);}
GLenum gl__GetError() {return parent::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {parent::glGetIntegerv(pname,params);}
void gl__GetLightfv(GLenum light, GLenum pname, GLfloat *params) {parent::glGetLightfv(light,pname,params);}
void gl__GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) {parent::glGetMaterialfv(face,pname,params);}
const GLubyte * gl__GetString(GLenum name) {return parent::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return parent::glIsTexture(texture);}
void gl__Lightfv(GLenum light, GLenum pname, const GLfloat *params) {parent::glLightfv(light,pname,params);}
void gl__Lightf(GLenum light, GLenum pname, GLfloat param) {parent::glLightf(light,pname,param);}
void gl__LineWidth(GLfloat width) {parent::glLineWidth(width);}
void gl__LoadIdentity() {parent::glLoadIdentity();}
void gl__LoadMatrixf(const GLfloat *m) {parent::glLoadMatrixf(m);}
void gl__MatrixMode(GLenum mode) {parent::glMatrixMode(mode);}
void gl__Normal3fv(const GLfloat *v) {parent::glNormal3fv(v);}
void gl__Normal3f(GLfloat nx, GLfloat ny, GLfloat nz) {parent::glNormal3f(nx,ny,nz);}
void gl__NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) {parent::glNormalPointer(type,stride,pointer);}
void gl__PixelStorei(GLenum pname, GLint param) {parent::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {parent::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {parent::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {parent::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {parent::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__ShadeModel(GLenum mode) {parent::glShadeModel(mode);}
void gl__TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {parent::glTexCoordPointer(size,type,stride,pointer);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {parent::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {parent::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {parent::glTexParameteri(target,pname,param);}
void gl__Vertex3fv(const GLfloat *v) {parent::glVertex3fv(v);}
void gl__Vertex3f(GLfloat x, GLfloat y, GLfloat z) {parent::glVertex3f(x,y,z);}
void gl__VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {parent::glVertexPointer(size,type,stride,pointer);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {parent::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {parent::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {parent::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {parent::glDepthMask(flag);}
void gl__NewList(GLuint list, GLenum mode) {parent::glNewList(list,mode);}
void gl__DeleteLists(GLuint list, GLsizei range) {parent::glDeleteLists(list,range);}
void gl__CallLists(GLsizei n, GLenum type, const GLvoid *lists) {parent::glCallLists(n,type,lists);}
void gl__CallList(GLuint list) {parent::glCallList(list);}
void gl__EndList() {parent::glEndList();}
GLuint gl__GenLists(GLsizei range) {return parent::glGenLists(range);}
GLboolean gl__IsList(GLuint list) {return parent::glIsList(list);}
};
}}
#endif //not TOOLS_USE_GL_VERSION_3_2
#endif
+12 -12
View File
@@ -4,8 +4,6 @@
#ifndef toolx_Qt_glarea
#define toolx_Qt_glarea
#include "../sg/GL_viewer"
#include <QtCore/qglobal.h> //For QT_VERSION.
#if QT_VERSION < 0x060000
@@ -16,10 +14,19 @@
#include <QtGui/qevent.h>
#include "gl_functions"
#include "../sg/GL_action"
#include "../sg/GL_viewer"
namespace toolx {
namespace sg {
using GL_action = GL_action_T<toolx::Qt::gl_functions>;
using GL_manager = GL_manager_T<toolx::Qt::gl_functions>;
using GL_viewer = GL_viewer_T<GL_manager,GL_action>;
}}
#include <tools/sg/device_interactor>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
namespace toolx {
namespace Qt {
@@ -113,14 +120,8 @@ public:
public:
glarea(QWidget* a_parent,toolx::sg::GL_viewer& a_viewer):parent(a_parent),m_viewer(a_viewer),m_interactor(0){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~glarea(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
public:
void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;} //we do not have ownership.
@@ -133,5 +134,4 @@ protected:
}}
#endif
+1 -19
View File
@@ -18,10 +18,6 @@
#include <tools/sg/zb_viewer>
#include <tools/sg/device_interactor>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
namespace toolx {
namespace Qt {
@@ -31,19 +27,16 @@ class pixwin : public QWidget
TOOLS_SCLASS(toolx::Qt::pixwin)
public:
virtual void resizeEvent(QResizeEvent* a_event) {
//::printf("debug : toolx::Qt::pixwin::resizeEvent : %d, %d\n",a_event->size().width(),a_event->size().height());
parent::resizeEvent(a_event);
m_viewer.set_size(a_event->size().width(),a_event->size().height());
}
virtual void paintEvent(QPaintEvent* a_event) {
parent::paintEvent(a_event);
if(!m_viewer.render(tools::sg::zb_viewer::get_rgbas,false)) return; //rgbas because Qt wants an image 32 bits aligned.
//static size_t s_count = 0;::printf("debug : toolx::Qt::pixwin::paintEvent %d %d : %lu\n",parent::m_ww,parent::m_wh,s_count);s_count++;
QImage image(tools::vec_data(m_viewer.out_buffer()),m_viewer.width(),m_viewer.height(),QImage::Format_RGBA8888);
QImage image(m_viewer.out_buffer().data(),m_viewer.width(),m_viewer.height(),QImage::Format_RGBA8888);
QPixmap pixmap = QPixmap::fromImage(image);
QPainter painter(this);
painter.drawPixmap(0,0,pixmap);
//parent::after_render();
m_viewer.out_buffer_clear();
}
@@ -96,11 +89,6 @@ public:
#endif
m_interactor->mouse_move(_event);
}
//virtual void mouseDoubleClickEvent(QMouseEvent* a_event) {
// if(!m_interactor) return;
// tools::sg::mouse_double_click_event _event(a_event->x(),a_event->y());
// m_interactor->mouse_double_click(_event);
//}
virtual void wheelEvent(QWheelEvent* a_event) {
if(!m_interactor) return;
@@ -117,14 +105,8 @@ public:
public:
pixwin(QWidget* a_parent,tools::sg::zb_viewer& a_viewer):parent(a_parent),m_viewer(a_viewer),m_interactor(0){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~pixwin(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
public:
void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;} //we do not have ownership.
-3
View File
@@ -83,12 +83,9 @@ public:
top->setWindowFlags(::Qt::CustomizeWindowHint
| ::Qt::WindowTitleHint
| ::Qt::WindowMinMaxButtonsHint
// | ::Qt::WindowSystemMenuHint
// | ::Qt::WindowFullscreenButtonHint
);
top->setGeometry(a_x,a_y,a_width,a_height);
top->setWindowTitle(s2q(a_title));
//top->setAttribute(Qt::WA_DeleteOnClose,false);
return top;
}
void delete_window(QWidget* a_window) const {
+7 -3
View File
@@ -48,7 +48,6 @@ public:
if(m_glarea) m_glarea->set_device_interactor(0);
if(m_shell && m_own_shell) {
m_session.delete_window(m_shell);
//m_session.sync();
}
}
protected:
@@ -74,7 +73,13 @@ public:
void win_render() {
if(!m_glarea) return;
m_glarea->update();
m_glarea->repaint(); //immediate.
m_session.sync();
}
void emit_win_render() {
if(!m_glarea) return;
m_glarea->update(); //delayed.
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -110,4 +115,3 @@ protected:
}}
#endif
+6 -3
View File
@@ -76,8 +76,13 @@ public:
void win_render() {
if(!m_render_area) return;
//m_render_area->update(); //delayed.
m_render_area->repaint(); //immediate.
m_session.sync();
}
void emit_win_render() {
if(!m_render_area) return;
m_render_area->update(); //delayed.
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -112,6 +117,4 @@ protected:
}}
#endif
@@ -0,0 +1,351 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_Windows_gl_functions
#define toolx_Windows_gl_functions
#ifndef GL_VERSION_1_1
#error You have to include OpenGL header(s) before including this file.
#endif
#ifdef TOOLS_USE_GL_VERSION_3_2
#include <wingdi.h>
typedef LONG_PTR GLsizeiptr;
typedef char GLchar;
#define GL_ARRAY_BUFFER 0x8892
#define GL_STATIC_DRAW 0x88E4
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_FRAMEBUFFER 0x8D40
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_COMPILE_STATUS 0x8B81
#define GL_VERTEX_SHADER 0x8B31
#define GL_LINK_STATUS 0x8B82
#define GL_FRAGMENT_SHADER 0x8B30
#endif
namespace toolx {
namespace Windows {
#ifdef TOOLS_USE_GL_VERSION_3_2
class gl_functions {
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {
return true;
}
public:
/*GL_VERSION_1_1*/
void gl__BindTexture(GLenum target, GLuint texture) {::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {::glClear(mask);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {::glDisable(cap);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {::glEnable(cap);}
void gl__FrontFace(GLenum mode) {::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {::glGenTextures(n,textures);}
GLenum gl__GetError() {return ::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {::glGetIntegerv(pname,params);}
const GLubyte * gl__GetString(GLenum name) {return ::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return ::glIsTexture(texture);}
void gl__LineWidth(GLfloat width) {::glLineWidth(width);}
void gl__PixelStorei(GLenum pname, GLint param) {::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {::glTexParameteri(target,pname,param);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {::glDepthMask(flag);}
/*GL_VERSION_1_5*/
void gl__GenBuffers(GLsizei n, GLuint *buffers) {
PROC proc = ::wglGetProcAddress("glGenBuffers");if(proc==NULL) return;
typedef void (*function)(GLsizei n, GLuint *buffers);
(function(proc))(n,buffers);
}
void gl__BindBuffer(GLenum target, GLuint buffer) {
PROC proc = ::wglGetProcAddress("glBindBuffer");if(proc==NULL) return;
typedef void (*function)(GLenum target, GLuint buffer);
(function(proc))(target,buffer);
}
void gl__DeleteBuffers(GLsizei n, const GLuint *buffers) {
PROC proc = ::wglGetProcAddress("glDeleteBuffers");if(proc==NULL) return;
typedef void (*function)(GLsizei n, const GLuint *buffers);
(function(proc))(n,buffers);
}
void gl__BufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {
PROC proc = ::wglGetProcAddress("glBufferData");if(proc==NULL) return;
typedef void (*function)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
(function(proc))(target,size,data,usage);
}
GLboolean gl__IsBuffer(GLuint buffer) {
PROC proc = ::wglGetProcAddress("glIsBuffer(buffer");if(proc==NULL) return GL_FALSE;
typedef GLboolean (*function)(GLuint buffer);
return (function(proc))(buffer);
}
void gl__EnableVertexAttribArray(GLuint index) {
PROC proc = ::wglGetProcAddress("glEnableVertexAttribArray");if(proc==NULL) return;
typedef void (*function)(GLuint index);
(function(proc))(index);
}
void gl__DisableVertexAttribArray(GLuint index) {
PROC proc = ::wglGetProcAddress("glDisableVertexAttribArray");if(proc==NULL) return;
typedef void (*function)(GLuint index);
(function(proc))(index);
}
/*GL_VERSION_2_0*/
GLuint gl__CreateProgram() {
PROC proc = ::wglGetProcAddress("glCreateProgram");if(proc==NULL) return 0;
typedef GLuint (*function)();
return (function(proc))();
}
void gl__DeleteProgram(GLuint program) {
PROC proc = ::wglGetProcAddress("glDeleteProgram");if(proc==NULL) return;
typedef void (*function)(GLuint program);
(function(proc))(program);
}
void gl__UseProgram(GLuint program) {
PROC proc = ::wglGetProcAddress("glUseProgram");if(proc==NULL) return;
typedef void (*function)(GLuint program);
(function(proc))(program);
}
void gl__LinkProgram(GLuint program) {
PROC proc = ::wglGetProcAddress("glLinkProgram");if(proc==NULL) return;
typedef void (*function)(GLuint program);
(function(proc))(program);
}
void gl__GetProgramiv(GLuint program, GLenum pname, GLint *params) {
PROC proc = ::wglGetProcAddress("glGetProgramiv");if(proc==NULL) return;
typedef void (*function)(GLuint program, GLenum pname, GLint *params);
(function(proc))(program,pname,params);
}
void gl__Uniform1i(GLint location, GLint v0) {
PROC proc = ::wglGetProcAddress("glUniform1i");if(proc==NULL) return;
typedef void (*function)(GLint location, GLint v0);
(function(proc))(location,v0);
}
void gl__Uniform1f(GLint location, GLfloat v0) {
PROC proc = ::wglGetProcAddress("glUniform1f");if(proc==NULL) return;
typedef void (*function)(GLint location, GLfloat v0);
(function(proc))(location,v0);
}
void gl__Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
PROC proc = ::wglGetProcAddress("glUniform3f");if(proc==NULL) return;
typedef void (*function)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
(function(proc))(location,v0,v1,v2);
}
void gl__Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
PROC proc = ::wglGetProcAddress("glUniform4f");if(proc==NULL) return;
typedef void (*function)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
(function(proc))(location,v0,v1,v2,v3);
}
void gl__UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
PROC proc = ::wglGetProcAddress("glUniformMatrix4fv");if(proc==NULL) return;
typedef void (*function)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
(function(proc))(location,count,transpose,value);
}
GLint gl__GetUniformLocation(GLuint program, const GLchar *name) {
PROC proc = ::wglGetProcAddress("glGetUniformLocation");if(proc==NULL) return -1;
typedef GLint (*function)(GLuint program, const GLchar *name);
return (function(proc))(program,name);
}
void gl__ShaderSource(GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length) {
PROC proc = ::wglGetProcAddress("glShaderSource");if(proc==NULL) return;
typedef void (*function)(GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
(function(proc))(shader,count,string,length);
}
GLboolean gl__IsShader(GLuint shader) {
PROC proc = ::wglGetProcAddress("glIsShader");if(proc==NULL) return GL_FALSE;
typedef GLboolean (*function)(GLuint shader);
return (function(proc))(shader);
}
void gl__GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {
PROC proc = ::wglGetProcAddress("glGetShaderSource");if(proc==NULL) return;
typedef void (*function)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
(function(proc))(shader,bufSize,length,source);
}
void gl__GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
PROC proc = ::wglGetProcAddress("glGetShaderInfoLog");if(proc==NULL) return;
typedef void (*function)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
(function(proc))(shader,bufSize,length,infoLog);
}
void gl__GetShaderiv(GLuint shader, GLenum pname, GLint *params) {
PROC proc = ::wglGetProcAddress("glGetShaderiv");if(proc==NULL) return;
typedef void (*function)(GLuint shader, GLenum pname, GLint *params);
(function(proc))(shader,pname,params);
}
void gl__GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) {
PROC proc = ::wglGetProcAddress("glGetAttachedShaders");if(proc==NULL) return;
typedef void (*function)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
(function(proc))(program,maxCount,count,obj);
}
void gl__DetachShader(GLuint program, GLuint shader) {
PROC proc = ::wglGetProcAddress("glDetachShader");if(proc==NULL) return;
typedef void (*function)(GLuint program, GLuint shader);
(function(proc))(program,shader);
}
void gl__DeleteShader(GLuint shader) {
PROC proc = ::wglGetProcAddress("glDeleteShader");if(proc==NULL) return;
typedef void (*function)(GLuint shader);
(function(proc))(shader);
}
GLuint gl__CreateShader(GLenum type) {
PROC proc = ::wglGetProcAddress("glCreateShader");if(proc==NULL) return 0;
typedef GLuint (*function)(GLenum type);
return (function(proc))(type);
}
void gl__CompileShader(GLuint shader) {
PROC proc = ::wglGetProcAddress("glCompileShader");if(proc==NULL) return;
typedef void (*function)(GLuint shader);
(function(proc))(shader);
}
void gl__AttachShader(GLuint program, GLuint shader) {
PROC proc = ::wglGetProcAddress("glAttachShader");if(proc==NULL) return;
typedef void (*function)(GLuint program, GLuint shader);
(function(proc))(program,shader);
}
void gl__VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) {
PROC proc = ::wglGetProcAddress("glVertexAttribPointer");if(proc==NULL) return;
typedef void (*function)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
(function(proc))(index,size,type,normalized,stride,pointer);
}
GLint gl__GetAttribLocation(GLuint program, const GLchar *name) {
PROC proc = ::wglGetProcAddress("glGetAttribLocation");if(proc==NULL) return -1;
typedef GLint (*function)(GLuint program, const GLchar *name);
return (function(proc))(program,name);
}
/*GL_VERSION_3_0*/
void gl__BindVertexArray(GLuint array) {
PROC proc = ::wglGetProcAddress("glBindVertexArray");if(proc==NULL) return;
typedef void (*function)(GLuint array);
(function(proc))(array);
}
void gl__GenVertexArrays(GLsizei n, GLuint *arrays) {
PROC proc = ::wglGetProcAddress("glGenVertexArrays");if(proc==NULL) return;
typedef void (*function)(GLsizei n, GLuint *arrays);
(function(proc))(n,arrays);
}
void gl__DeleteVertexArrays(GLsizei n, const GLuint *arrays) {
PROC proc = ::wglGetProcAddress("glDeleteVertexArrays");if(proc==NULL) return;
typedef void (*function)(GLsizei n, const GLuint *arrays);
(function(proc))(n,arrays);
}
GLboolean gl__IsVertexArray(GLuint array) {
PROC proc = ::wglGetProcAddress("glIsVertexArray");if(proc==NULL) return GL_FALSE;
typedef GLboolean (*function)(GLuint array);
return (function(proc))(array);
}
GLenum gl__CheckFramebufferStatus(GLenum target) {
PROC proc = ::wglGetProcAddress("glCheckFramebufferStatus");if(proc==NULL) return 0;
typedef GLenum (*function)(GLenum target);
return (function(proc))(target);
}
};
#else //not TOOLS_USE_GL_VERSION_3_2
class gl_functions {
public:
gl_functions() {}
virtual ~gl_functions() {}
protected:
gl_functions(const gl_functions&) {}
gl_functions& operator=(const gl_functions&) {return *this;}
public:
virtual bool initialize() {
return true;
}
public:
/*GL_VERSION_1_1*/
void gl__Accum(GLenum op, GLfloat value) {::glAccum(op,value);}
void gl__Begin(GLenum mode) {::glBegin(mode);}
void gl__BindTexture(GLenum target, GLuint texture) {::glBindTexture(target,texture);}
void gl__BlendFunc(GLenum sfactor, GLenum dfactor) {::glBlendFunc(sfactor,dfactor);}
void gl__ClearDepth(GLdouble depth) {::glClearDepth(depth);}
void gl__ClearStencil(GLint s) {::glClearStencil(s);}
void gl__ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearColor(red,green,blue,alpha);}
void gl__Clear(GLbitfield mask) {::glClear(mask);}
void gl__ClearIndex(GLfloat c) {::glClearIndex(c);}
void gl__ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glClearAccum(red,green,blue,alpha);}
void gl__Color4fv(const GLfloat *v) {::glColor4fv(v);}
void gl__Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {::glColor4f(red,green,blue,alpha);}
void gl__ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glColorPointer(size,type,stride,pointer);}
void gl__DeleteTextures(GLsizei n, const GLuint *textures) {::glDeleteTextures(n,textures);}
void gl__Disable(GLenum cap) {::glDisable(cap);}
void gl__DisableClientState(GLenum array) {::glDisableClientState(array);}
void gl__DrawArrays(GLenum mode, GLint first, GLsizei count) {::glDrawArrays(mode,first,count);}
void gl__Enable(GLenum cap) {::glEnable(cap);}
void gl__EnableClientState(GLenum array) {::glEnableClientState(array);}
void gl__End() {::glEnd();}
void gl__FrontFace(GLenum mode) {::glFrontFace(mode);}
void gl__GenTextures(GLsizei n, GLuint *textures) {::glGenTextures(n,textures);}
GLenum gl__GetError() {return ::glGetError();}
void gl__GetIntegerv(GLenum pname, GLint *params) {::glGetIntegerv(pname,params);}
void gl__GetLightfv(GLenum light, GLenum pname, GLfloat *params) {::glGetLightfv(light,pname,params);}
void gl__GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) {::glGetMaterialfv(face,pname,params);}
const GLubyte * gl__GetString(GLenum name) {return ::glGetString(name);}
GLboolean gl__IsTexture(GLuint texture) {return ::glIsTexture(texture);}
void gl__Lightfv(GLenum light, GLenum pname, const GLfloat *params) {::glLightfv(light,pname,params);}
void gl__Lightf(GLenum light, GLenum pname, GLfloat param) {::glLightf(light,pname,param);}
void gl__LineWidth(GLfloat width) {::glLineWidth(width);}
void gl__LoadIdentity() {::glLoadIdentity();}
void gl__LoadMatrixf(const GLfloat *m) {::glLoadMatrixf(m);}
void gl__MatrixMode(GLenum mode) {::glMatrixMode(mode);}
void gl__Normal3fv(const GLfloat *v) {::glNormal3fv(v);}
void gl__Normal3f(GLfloat nx, GLfloat ny, GLfloat nz) {::glNormal3f(nx,ny,nz);}
void gl__NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) {::glNormalPointer(type,stride,pointer);}
void gl__PixelStorei(GLenum pname, GLint param) {::glPixelStorei(pname,param);}
void gl__PointSize(GLfloat size) {::glPointSize(size);}
void gl__PolygonOffset(GLfloat factor, GLfloat units) {::glPolygonOffset(factor,units);}
void gl__ReadBuffer(GLenum mode) {::glReadBuffer(mode);}
void gl__ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {::glReadPixels(x,y,width,height,format,type,pixels);}
void gl__ShadeModel(GLenum mode) {::glShadeModel(mode);}
void gl__TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glTexCoordPointer(size,type,stride,pointer);}
void gl__TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {::glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);}
void gl__TexParameteriv(GLenum target, GLenum pname, const GLint *params) {::glTexParameteriv(target,pname,params);}
void gl__TexParameteri(GLenum target, GLenum pname, GLint param) {::glTexParameteri(target,pname,param);}
void gl__Vertex3fv(const GLfloat *v) {::glVertex3fv(v);}
void gl__Vertex3f(GLfloat x, GLfloat y, GLfloat z) {::glVertex3f(x,y,z);}
void gl__VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {::glVertexPointer(size,type,stride,pointer);}
void gl__Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {::glViewport(x,y,width,height);}
void gl__Hint(GLenum target,GLenum mode) {::glHint(target,mode);}
void gl__DepthFunc(GLenum func) {::glDepthFunc(func);}
void gl__DepthMask(GLboolean flag) {::glDepthMask(flag);}
void gl__NewList(GLuint list, GLenum mode) {::glNewList(list,mode);}
void gl__DeleteLists(GLuint list, GLsizei range) {::glDeleteLists(list,range);}
void gl__CallLists(GLsizei n, GLenum type, const GLvoid *lists) {::glCallLists(n,type,lists);}
void gl__CallList(GLuint list) {::glCallList(list);}
void gl__EndList() {::glEndList();}
GLuint gl__GenLists(GLsizei range) {return ::glGenLists(range);}
GLboolean gl__IsList(GLuint list) {return ::glIsList(list);}
/*GL_VERSION_3_0*/
};
#endif //not TOOLS_USE_GL_VERSION_3_2
}}
#endif
-14
View File
@@ -10,7 +10,6 @@
#include <tools/sg/device_interactor>
#include <tools/sg/keys>
//#include <tools/log_file>
#include <string>
@@ -76,8 +75,6 @@ public:
register_class();
RECT rect;
::GetClientRect(m_parent,&rect);
//printf("debug : glarea : ca : %d %d\n",rect.right-rect.left,rect.bottom-rect.top);
//toolx::log_file::get().writef("debug : glarea : ca : %d %d\n",rect.right-rect.left,rect.bottom-rect.top);
m_hwnd = ::CreateWindow((PTSTR)s_class().c_str(),
NULL,
WS_CHILD | WS_VISIBLE,
@@ -101,7 +98,6 @@ public:
if((digitizer_status & (0x80 + 0x40)) == 0) {
m_touch_available = false;
} else {
//BYTE nInputs = (BYTE)::GetSystemMetrics(SM_MAXIMUMTOUCHES);
m_touch_available = true;
if(!::RegisterTouchWindow(m_hwnd,0)) m_touch_available = false;
}}
@@ -175,7 +171,6 @@ public:
}
void wm_paint() {
PAINTSTRUCT ps;
//HDC hDC =
BeginPaint(m_hwnd,&ps);
if(m_HDC && m_context) {
::wglMakeCurrent(m_HDC,m_context);
@@ -185,9 +180,6 @@ public:
unsigned int w = rect.right-rect.left;
unsigned int h = rect.bottom-rect.top;
//printf("debug : glarea : paint : %d %d\n",w,h);
//toolx::log_file::get().writef("debug : glarea : paint : %d %d\n",w,h);
paint(w,h);
::SwapBuffers(m_HDC);
@@ -318,12 +310,10 @@ protected:
glarea* _this = (glarea*)::GetWindowLongPtr(a_hwnd,GWLP_USERDATA);
if(_this && _this->m_touch_available) {
RECT rect;
//::GetWindowRect(hwnd,&rect); ???
::GetClientRect(a_hwnd,&rect);
unsigned int h = rect.bottom-rect.top;
unsigned int num_inputs = (int)a_wparam;
//::printf("debug : WM_TOUCH : 001 : %d\n",num_inputs);
TOUCHINPUT* ti = new TOUCHINPUT[num_inputs];
POINT p;
if(::GetTouchInputInfo((HTOUCHINPUT)a_lparam,num_inputs,ti,sizeof(TOUCHINPUT))) {
@@ -332,14 +322,11 @@ protected:
p.y = TOUCH_COORD_TO_PIXEL(ti[i].y);
if(!::ScreenToClient(a_hwnd,&p)) {}
if(ti[i].dwFlags & TOUCHEVENTF_DOWN) {
//::printf("debug : TOUCHEVENTF_DOWN %lu %lu\n",p.x,p.y);
_this->left_button_down(p.x,h-p.y);
} else if (ti[i].dwFlags & TOUCHEVENTF_UP) {
//::printf("debug : TOUCHEVENTF_UP %lu %lu\n",p.x,p.y);
_this->left_button_up(p.x,h-p.y);
} else if (ti[i].dwFlags & TOUCHEVENTF_MOVE) {
bool ldown = true; //we assume that a TOUCHEVENT_DOWN had been done.
//::printf("debug : TOUCHEVENTF_MOVE %lu %lu\n",p.x,p.y);
_this->mouse_move(p.x,h-p.y,ldown);
}
}
@@ -407,7 +394,6 @@ protected:
if(_this) { //How to be sure that we have a glarea* ???
_this->close();
if(_this->m_hwnd!=a_hwnd) {
//::printf("WinTk::Component::wm_destroy : HWND mismatch !\n");
}
_this->m_hwnd = 0;
}
+8 -10
View File
@@ -10,7 +10,6 @@
#include <tools/sg/device_interactor>
#include <tools/sg/keys>
//#include <tools/log_file>
#include <string>
@@ -58,7 +57,6 @@ class pixwin {
}
public:
virtual void resize(unsigned int,unsigned int){}
//virtual void paint(HDC) {}
virtual void paint() {}
virtual void close(){}
@@ -74,7 +72,6 @@ public:
{
register_class();
m_hwnd = ::CreateWindow((PTSTR)s_class().c_str(),
//m_hwnd = ::CreateWindowEx(WS_EX_LAYERED,s_class().c_str(),
NULL,
WS_CHILD | WS_VISIBLE,
0,0,
@@ -90,7 +87,6 @@ public:
if((digitizer_status & (0x80 + 0x40)) == 0) {
m_touch_available = false;
} else {
//BYTE nInputs = (BYTE)::GetSystemMetrics(SM_MAXIMUMTOUCHES);
m_touch_available = true;
if(!::RegisterTouchWindow(m_hwnd,0)) m_touch_available = false;
}}
@@ -142,6 +138,14 @@ public:
::MoveWindow(m_hwnd,rect.left,rect.top,a_w,a_h,TRUE);
}
HWND hwnd() const {return m_hwnd;}
void post_WM_PAINT() const {
if(!m_hwnd) return;
::PostMessage(m_hwnd,WM_PAINT,(WPARAM)0,(LPARAM)0);
}
void send_WM_PAINT() const {
if(!m_hwnd) return;
::SendMessage(m_hwnd,WM_PAINT,(WPARAM)0,(LPARAM)0);
}
void wm_paint() {paint();}
public:
void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;} //we do not have ownership.
@@ -266,12 +270,10 @@ protected:
pixwin* _this = (pixwin*)::GetWindowLongPtr(a_hwnd,GWLP_USERDATA);
if(_this && _this->m_touch_available) {
RECT rect;
//::GetWindowRect(hwnd,&rect); ???
::GetClientRect(a_hwnd,&rect);
unsigned int h = rect.bottom-rect.top;
unsigned int num_inputs = (int)a_wparam;
//::printf("debug : WM_TOUCH : 001 : %d\n",num_inputs);
TOUCHINPUT* ti = new TOUCHINPUT[num_inputs];
POINT p;
if(::GetTouchInputInfo((HTOUCHINPUT)a_lparam,num_inputs,ti,sizeof(TOUCHINPUT))) {
@@ -280,14 +282,11 @@ protected:
p.y = TOUCH_COORD_TO_PIXEL(ti[i].y);
if(!::ScreenToClient(a_hwnd,&p)) {}
if(ti[i].dwFlags & TOUCHEVENTF_DOWN) {
//::printf("debug : TOUCHEVENTF_DOWN %lu %lu\n",p.x,p.y);
_this->left_button_down(p.x,h-p.y);
} else if (ti[i].dwFlags & TOUCHEVENTF_UP) {
//::printf("debug : TOUCHEVENTF_UP %lu %lu\n",p.x,p.y);
_this->left_button_up(p.x,h-p.y);
} else if (ti[i].dwFlags & TOUCHEVENTF_MOVE) {
bool ldown = true; //we assume that a TOUCHEVENT_DOWN had been done.
//::printf("debug : TOUCHEVENTF_MOVE %lu %lu\n",p.x,p.y);
_this->mouse_move(p.x,h-p.y,ldown);
}
}
@@ -355,7 +354,6 @@ protected:
if(_this) { //How to be sure that we have a pixwin* ???
_this->close();
if(_this->m_hwnd!=a_hwnd) {
//::printf("WinTk::Component::wm_destroy : HWND mismatch !\n");
}
_this->m_hwnd = 0;
}
@@ -62,9 +62,6 @@ public:
::MoveWindow(a_hwnd,0,0,a_width,a_height,TRUE);
}
//void post(HWND a_hwnd,LPARAM a_msg){
// ::PostMessage(a_hwnd,WM_USER,(WPARAM)0,a_msg);
//}
public:
bool tmp_dir(std::string& a_dir) {
char* env = ::getenv("TEMP");
+19 -5
View File
@@ -8,8 +8,20 @@
#include "window"
#include "glarea"
#include <GL/gl.h>
#include "gl_functions"
#include "../sg/GL_action"
#include "../sg/GL_viewer"
namespace toolx {
namespace sg {
using GL_action = GL_action_T<Windows::gl_functions>;
using GL_manager = GL_manager_T<Windows::gl_functions>;
using GL_viewer = GL_viewer_T<GL_manager,GL_action>;
}}
// disable the warning about the usage of "this" in the constructor.
#pragma warning(disable:4355)
@@ -19,8 +31,6 @@ namespace Windows {
class sg_viewer : public window, public sg::GL_viewer {
typedef window parent_window;
typedef sg::GL_viewer parent_viewer;
public:
virtual void close() {}
public:
sg_viewer(session& a_session,
int a_x = 0,int a_y = 0,
@@ -56,7 +66,12 @@ public:
return true;
}
void win_render() {m_glarea.wm_paint();}
void win_render() {
m_glarea.wm_paint();
m_session.sync();
}
void emit_win_render() {m_glarea.post_WM_PAINT();}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
if(!m_glarea.hwnd()) {a_w = 0;a_h = 0;return false;}
@@ -70,7 +85,7 @@ public:
a_w = parent_viewer::width();
a_h = parent_viewer::height();
}
public:
void set_device_interactor(tools::sg::device_interactor* a_interactor) { //we do not have ownership.
m_glarea.set_device_interactor(a_interactor);
@@ -98,5 +113,4 @@ protected:
}}
#endif
+1 -19
View File
@@ -41,7 +41,6 @@ public:
virtual void key_right(){}
virtual void key_escape(){}
virtual void close(){
//if(m_hwnd) ::PostMessage(m_hwnd,WM_QUIT,0,0);
::PostQuitMessage(0);
}
public:
@@ -79,23 +78,7 @@ protected:
,m_key_shift(a_from.m_key_shift)
,m_key_ctrl(a_from.m_key_ctrl)
,m_focus_hwnd(0)
{
/*
if(!a_from.m_hwnd) return;
int w,h;
get_size(a_from.m_hwnd,w,h);
register_class();
m_hwnd = ::CreateWindow(s_class().c_str(),
NULL,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
w,h,
NULL,NULL,
::GetModuleHandle(NULL),
NULL);
if(!m_hwnd) return;
::SetWindowLongPtr(m_hwnd,GWLP_USERDATA,LONG_PTR(this));
*/
{
}
window& operator=(const window& a_from){
m_key_shift = a_from.m_key_shift;
@@ -225,7 +208,6 @@ protected:
window* _this = (window*)::GetWindowLongPtr(a_hwnd,GWLP_USERDATA);
if(_this) { //How to be sure that we have a window* ???
if(_this->m_hwnd!=a_hwnd) {
//::printf("WinTk::Component::wm_destroy : HWND mismatch !\n");
}
_this->m_hwnd = 0;
}
+7 -4
View File
@@ -22,11 +22,10 @@ class zb_viewer : public window, protected pixwin, public tools::sg::zb_viewer {
typedef tools::sg::zb_viewer parent_viewer;
protected:
virtual void paint() {
//parent_viewer::m_out << "toolx::Windows::zb_viewer::paint " << parent_viewer::m_ww << " " << parent_viewer::m_wh << std::endl;
if(!render(get_bgras,false)) return;
HDC hDC = ::GetDC(parent_render_area::m_hwnd);
HDC bitmap_DC = ::CreateCompatibleDC(hDC);
HBITMAP bitmap = ::CreateBitmap(parent_viewer::m_ww,parent_viewer::m_wh, 1, 32, tools::vec_data(m_out_buffer));
HBITMAP bitmap = ::CreateBitmap(parent_viewer::m_ww,parent_viewer::m_wh, 1, 32, m_out_buffer.data());
HBITMAP old_bitmap = (HBITMAP)::SelectObject(bitmap_DC, bitmap);
::BitBlt(hDC,0,0,parent_viewer::m_ww,parent_viewer::m_wh,bitmap_DC,0,0,SRCCOPY);
::SelectObject(bitmap_DC, old_bitmap);
@@ -37,7 +36,6 @@ protected:
m_out_buffer.clear();
}
virtual void resize(unsigned int a_w,unsigned int a_h){ //NOTE: it is not called at startup.
//parent_viewer::m_out << "toolx::Windows::zb_viewer::resize " << a_w << " " << a_h << std::endl;
set_size(a_w,a_h);
}
public:
@@ -77,7 +75,12 @@ public:
return true;
}
void win_render() {parent_render_area::wm_paint();}
void win_render() {
parent_render_area::wm_paint();
m_session.sync();
}
void emit_win_render() {parent_render_area::post_WM_PAINT();}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
if(!parent_render_area::m_hwnd) {a_w = 0;a_h = 0;return false;}
+24 -39
View File
@@ -20,15 +20,6 @@ namespace toolx {
namespace X11 {
class base_session {
public:
//virtual bool make_current(Window) const {
// if(!m_display) return false;
// return true;
//}
//virtual bool swap_buffers(Window) const {
// if(!m_display) return false;
// return true;
//}
public:
base_session(std::ostream& a_out,unsigned int a_monitor = 0)
:m_out(a_out)
@@ -74,7 +65,6 @@ public:
clear_dispatchers();
if(m_display) ::XCloseDisplay(m_display);
m_display = 0;
//std::cout << "debug : ~base_session" << std::endl;
}
protected:
base_session(const base_session& a_from)
@@ -116,7 +106,6 @@ public:
bool sync() {
if(!m_display) return false;
//::glXWaitX();
::XSync(m_display,False);
while(true) {
XEvent xevent;
@@ -277,7 +266,6 @@ public:
unsigned long status;
} prop;
//unsigned long mwm_hints_functions = 1L << 0;
unsigned long mwm_hints_decorations = 1L << 1;
Atom atom = ::XInternAtom(m_display,"_MOTIF_WM_HINTS",False);
@@ -308,10 +296,8 @@ public:
event.xclient.data.l[2] = a_2;
event.xclient.data.l[3] = a_3;
event.xclient.data.l[4] = a_4;
//lock();
Status stat = ::XSendEvent(m_display,a_win,False,0L,&event);
::XFlush(m_display);
//unlock();
return (stat==0?false:true);
}
@@ -319,6 +305,27 @@ public:
return post(a_win,SESSION_EXIT_STEER_atom());
}
bool post_expose(Window a_win) const {
int width,height;
if(!window_size(a_win,width,height)) return false;
XEvent event;
event.type = Expose;
event.xexpose.serial = 0;
event.xexpose.send_event = True;
event.xexpose.display = m_display;
event.xexpose.window = a_win;
event.xexpose.x = 0;
event.xexpose.y = 0;
event.xexpose.width = width;
event.xexpose.height = height;
event.xexpose.count = 0;
//locks
Status stat = ::XSendEvent(m_display,a_win,False,0L,&event);
::XFlush(m_display);
//unlock();
return (stat==0?false:true);
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
@@ -333,7 +340,7 @@ public:
}
void remove_dispatchers_with_window(Window a_win){
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
if((*it)->window()==a_win) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
@@ -345,7 +352,7 @@ public:
}
bool dispatch(XEvent& a_event) {
{tools_vforit_npp(dispatcher*,m_dispatchers,it) {
{for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
if(!(*it)->is_valid()) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
@@ -369,30 +376,8 @@ protected:
return (a_event->type == UnmapNotify) && (a_event->xmap.window == (Window)a_arg);
}
/*
void wait_xxx(Window a_window) {
if(!m_display) return;
{wait_what arg;
arg.m_event_type = ConfigureNotify;
arg.m_window = a_window;
XEvent event;
::XIfEvent(m_display,&event,wait_for,(char*)&arg);
dispatch(event);}
}
struct wait_what {
int m_event_type;
Window m_window;
};
static Bool wait_for(Display*,XEvent* a_event,char* a_arg){
wait_what* arg = (wait_what*)a_arg;
return (a_event->type == arg->m_event_type) &&
(a_event->xmap.window == arg->m_window);
}
*/
void clear_dispatchers() {
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
delete obj;
-20
View File
@@ -6,41 +6,21 @@
#include <X11/Xlib.h>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
namespace toolx {
namespace X11 {
class dispatcher {
protected:
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::X11::dispatcher");
return s_v;
}
#endif
public:
virtual bool dispatch(XEvent&) = 0;
virtual Window window() const = 0;
virtual dispatcher* copy() const = 0;
public:
dispatcher():m_is_valid(true){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~dispatcher(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
public:
dispatcher(const dispatcher& a_from):m_is_valid(a_from.m_is_valid){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
dispatcher& operator=(const dispatcher& a_from) { m_is_valid = a_from.m_is_valid;return *this;}
public:
-4
View File
@@ -6,7 +6,6 @@
#include "colors"
#include <tools/sg/zb_viewer>
//#include <tools/sys/atime>
#include <X11/Xlib.h>
#include <X11/Xutil.h> //XPutPixel
@@ -53,7 +52,6 @@ public:
if(!m_GC) return;
if(!m_image) alloc_XImage(a_ww,a_wh);
if(!m_image) return;
//tools::atime start = tools::atime::now();
const unsigned int* pos = (const unsigned int*)a_rgbas;
unsigned int row,col;
toolx::X11::Pixel pixel;
@@ -63,9 +61,7 @@ public:
pos++;
XPutPixel(m_image,col,row,pixel);
}}
//::printf("debug : map::colors %lu, pixels %lu\n",m_colors.size(),m_pixels.size());
::XPutImage(m_display,a_win,m_GC,m_image,0,0,0,0,a_ww,a_wh);
//m_out << "pu_buffer : XImage " << tools::atime::elapsed(start) << std::endl;
}
void set_size(unsigned int a_ww,unsigned int a_wh) {
free_XImage();
-27
View File
@@ -13,20 +13,6 @@ namespace X11 {
class session : public base_session {
typedef base_session parent;
public:
//virtual bool make_current(Window a_window) const {
// if(!m_display) return false;
// if(::glXMakeCurrent(m_display,a_window,m_ctx)==False) {
// m_out << "toolx::X11::session::make_current : glXMakeCurrent failed." << std::endl;
// return false;
// }
// return true;
//}
//virtual bool swap_buffers(Window a_window) const {
// if(!m_display) return false;
// ::glXSwapBuffers(m_display,a_window);
// return true;
//}
public:
session(std::ostream& a_out,unsigned int a_monitor = 0)
:parent(a_out,a_monitor)
@@ -60,13 +46,6 @@ public:
//NOTE : macOS : glXChooseVisual leaks 640 bytes.
m_vinfo = ::glXChooseVisual(m_display,m_monitor,(int*)atbs_alpha);
if(!m_vinfo) {
//m_out << "toolx::X11::session::initialize :"
// << " can't get a visual with alpha on screen " << m_monitor << ". Try without alpha..."
// << std::endl;
//m_out << "toolx::X11::session::initialize :"
// << " DefaultScreen(m_display): " << DefaultScreen(m_display) << "."
// << std::endl;
static const int atbs[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
@@ -105,15 +84,10 @@ public:
m_ctx = 0;
return;
}
//} else {
//m_out << "toolx::X11::session::session :"
// << " glX context with direct rendering created."
// << std::endl;
}
// It is better to create a colormap adapted to the visual.
m_colormap = ::XCreateColormap(m_display,::XRootWindow(m_display,m_monitor),m_vinfo->visual,AllocNone);
//m_colormap = ::XDefaultColormap(m_display,m_monitor);
if(m_colormap==0L) {
m_out << "toolx::X11::session::session : XCreateColormap failed." << std::endl;
::XCloseDisplay(m_display);
@@ -140,7 +114,6 @@ public:
::XFree(m_vinfo);
m_vinfo = 0;
}
//std::cout << "debug : ~session" << std::endl;
}
protected:
session(const session& a_from)
+74 -13
View File
@@ -4,44 +4,95 @@
#ifndef toolx_X11_sg_viewer
#define toolx_X11_sg_viewer
// not pure X11 version. The class inherits tools::sg::viewer that uses GL.
#ifndef GL_GLEXT_LEGACY
#define GL_GLEXT_LEGACY
#endif
#include <GL/gl.h>
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#endif
#include <GL/glext.h>
#include "session"
#include "../GL/gl_functions"
#include "../sg/GL_action"
#include "../sg/GL_viewer"
namespace toolx {
namespace sg {
using GL_action = GL_action_T<GL::gl_functions>;
using GL_manager = GL_manager_T<GL::gl_functions>;
using GL_viewer = GL_viewer_T<GL_manager,GL_action>;
}}
#include "simple_dispatcher"
namespace tools{namespace sg{class device_interactor;}}
#include <tools/sg/device_interactor>
namespace toolx {
namespace X11 {
class sg_viewer : public sg::GL_viewer {
class sg_viewer: public sg::GL_viewer {
typedef sg::GL_viewer parent;
private:
class dispatcher : public simple_dispatcher {
typedef simple_dispatcher parent;
public:
virtual void win_render() {m_sg_viewer.win_render();}
virtual void set_size(unsigned int a_width,unsigned int a_height) {m_sg_viewer.set_size(a_width,a_height);}
virtual bool dispatch(XEvent& a_event) {
if(parent::dispatch(a_event)) return true;
bool shift_modifier = a_event.xkey.state & ShiftMask;
bool control_modifier = a_event.xkey.state & ControlMask;
if(a_event.type==ButtonPress && a_event.xbutton.button==1) {
if(!m_viewer.device_interactor()) return false;
tools::sg::mouse_down_event event(a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier);
m_viewer.device_interactor()->mouse_press(event);
return true;
} else if(a_event.type==ButtonRelease && a_event.xbutton.button==1) {
if(!m_viewer.device_interactor()) return false;
tools::sg::mouse_up_event event(a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier);
m_viewer.device_interactor()->mouse_release(event);
return true;
} else if(a_event.type==MotionNotify) {
if(!m_viewer.device_interactor()) return false;
if((a_event.xmotion.state & Button1MotionMask)==Button1MotionMask) {
tools::sg::mouse_move_event event(a_event.xmotion.x,a_event.xmotion.y,shift_modifier,control_modifier,0,0,false);
m_viewer.device_interactor()->mouse_move(event);
}
} else if((a_event.type==ButtonPress)&&(a_event.xbutton.button==4)) { // mouse scrollwheel down :
if(!m_viewer.device_interactor()) return false;
tools::sg::wheel_rotate_event event(8,a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier); //8=cooking.
m_viewer.device_interactor()->wheel_rotate(event);
return true;
} else if((a_event.type==ButtonPress)&&(a_event.xbutton.button==5)) { // mouse scrollwheel up :
if(!m_viewer.device_interactor()) return false;
tools::sg::wheel_rotate_event event(-8,a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier); //8=cooking.
m_viewer.device_interactor()->wheel_rotate(event);
return true;
}
return false;
}
virtual void win_render() {m_viewer.win_render();}
virtual void set_size(unsigned int a_width,unsigned int a_height) {m_viewer.set_size(a_width,a_height);}
virtual dispatcher* copy() const {return new dispatcher(*this);}
public:
dispatcher(sg_viewer& a_sg_viewer)
:parent(a_sg_viewer.m_session,a_sg_viewer.m_win)
,m_sg_viewer(a_sg_viewer){}
dispatcher(sg_viewer& a_viewer)
:parent(a_viewer.m_session,a_viewer.m_win)
,m_viewer(a_viewer){}
virtual ~dispatcher(){}
protected:
dispatcher(const dispatcher& a_from)
:parent(a_from)
,m_sg_viewer(a_from.m_sg_viewer)
,m_viewer(a_from.m_viewer)
{}
dispatcher& operator=(const dispatcher& a_from) {
parent::operator=(a_from);
return *this;
}
protected:
sg_viewer& m_sg_viewer;
sg_viewer& m_viewer;
};
public:
@@ -52,6 +103,7 @@ public:
:parent(a_session.out(),a_width,a_height)
,m_session(a_session)
,m_win(0)
,m_interactor(0)
{
if(!m_session.display()) return; //throw
m_win = m_session.create_window(a_win_title.c_str(),a_x,a_y,a_width,a_height);
@@ -65,11 +117,12 @@ public:
m_session.sync();
}
}
public:
protected:
sg_viewer(const sg_viewer& a_from)
:parent(a_from)
,m_session(a_from.m_session)
,m_win(a_from.m_win)
,m_interactor(0)
{}
sg_viewer& operator=(const sg_viewer& a_from){
parent::operator=(a_from);
@@ -98,6 +151,12 @@ public:
if(::glXMakeCurrent(m_session.display(),None,NULL)==False){
m_session.out() << "toolx::X11::sg_viewer::win_render : glXMakeCurrent(None,NULL) failed." << std::endl;
}
m_session.sync();
}
void emit_win_render() {
if(!m_win) return;
m_session.post_expose(m_win);
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -113,14 +172,16 @@ public:
a_h = parent::height();
}
void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;}
public:
void set_device_interactor(tools::sg::device_interactor*) {}
tools::sg::device_interactor* device_interactor() {return m_interactor;}
protected:
session& m_session;
Window m_win;
tools::sg::device_interactor* m_interactor;
};
}}
#endif
@@ -6,8 +6,6 @@
#include "base_session"
#include <tools/saui>
namespace toolx {
namespace X11 {
+7 -1
View File
@@ -133,8 +133,14 @@ public:
void win_render() {
if(!m_win) return;
if(!render(get_rgbas,false)) return;
put_buffer(m_win,m_ww,m_wh,tools::vec_data(m_out_buffer));
put_buffer(m_win,m_ww,m_wh,m_out_buffer.data());
m_out_buffer.clear();
m_session.sync();
}
void emit_win_render() {
if(!m_win) return;
m_session.post_expose(m_win);
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
-33
View File
@@ -9,12 +9,6 @@
#include <X11/CompositeP.h>
#include <X11/StringDefs.h>
//#define TOOLX_XT_IMAGEAREA_DEBUG
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
#include <stdio.h>
#endif
namespace toolx {
namespace Xt {
@@ -81,37 +75,20 @@ public:
}
protected:
static void initialize_class(void) {
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: initialize_class.\n");
#endif
}
static void initialize_widget(Widget a_request,Widget a_this,ArgList,Cardinal*) {
if(a_request->core.width<=0) a_this->core.width = 100;
if(a_request->core.height<=0) a_this->core.height = 100;
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: initialize_widget: %s\n",::XtName(a_this));
#endif
::XtAddEventHandler
(a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: initialize_widget: end\n");
#endif
}
static void destroy_widget(Widget) {
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: destroy_widget.\n");
#endif
}
static void change_widget_size(Widget a_this) {
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: change_widget_size: %s\n",XtName(a_this));
#endif
if(widget_class()->core_class.superclass->core_class.resize!=NULL)
(widget_class()->core_class.superclass->core_class.resize)(a_this);
@@ -121,15 +98,9 @@ protected:
value.event = 0;
::XtCallCallbacks(a_this,XoN_resizeCallback(),(XtPointer)&value);
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: change_widget_size: end\n");
#endif
}
static void draw_widget(Widget a_this,XEvent* a_event,Region a_region) {
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: draw_widget: %s\n",XtName(a_this));
#endif
if(widget_class()->core_class.superclass->core_class.expose!=NULL)
(widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
@@ -138,10 +109,6 @@ protected:
value.reason = XoCR_PAINT();
value.event = a_event;
::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
::printf("debug: toolx::Xt::ImageArea: draw_widget: end\n");
#endif
}
protected:
+10 -42
View File
@@ -9,6 +9,16 @@
#include <X11/CompositeP.h>
#include <X11/StringDefs.h>
#ifndef GL_GLEXT_LEGACY
#define GL_GLEXT_LEGACY
#endif
#include <GL/gl.h>
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#endif
#include <GL/glext.h>
#include <GL/glx.h>
#include <stdio.h>
@@ -97,10 +107,6 @@ protected:
if(a_request->core.width<=0) a_this->core.width = 100;
if(a_request->core.height<=0) a_this->core.height = 100;
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
::printf ("debug : OpenGLArea : InitializeWidget : %s\n",::XtName(a_this));
#endif
OpenGLAreaPart& athis = _athis(a_this);
athis.visual = CopyFromParent;
athis.installColormap = False;
@@ -196,16 +202,9 @@ protected:
::XtAddEventHandler
(a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : InitializeWidget : end\n");
#endif
}
static void realize_widget(Widget a_this,XtValueMask* a_mask,XSetWindowAttributes* a_watbs) {
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : realize_widget : %s\n",XtName(a_this));
#endif
// Have to create window ourselves due to OpenGL that compells it's visual.
// In principle colormap is correctly set in a_watbsy.
@@ -221,17 +220,9 @@ protected:
// If window is delete, all seems ok :
if(athis.installColormap==True) install_colormap(a_this);
//make_current(a_this);
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : realize_widget : end\n");
#endif
}
static void destroy_widget(Widget a_this) {
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : destroy_widget : begin\n");
#endif
OpenGLAreaPart& athis = _athis(a_this);
if(athis.installColormap==True) {
uninstall_colormap (a_this);
@@ -243,9 +234,6 @@ protected:
::glXDestroyContext(XtDisplay(a_this),athis.glContext);
athis.glContext = NULL;
}
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : destroy_widget : end\n");
#endif
}
static Boolean set_values(Widget a_current,Widget,Widget a_this,ArgList,Cardinal*) {
@@ -264,31 +252,16 @@ protected:
}
static void change_widget_size(Widget a_this) {
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : change_widget_size : %s\n",XtName(a_this));
#endif
// Call the Resize procedure (XtInheritResize) :
if(widget_class()->core_class.superclass->core_class.resize!=NULL)
(widget_class()->core_class.superclass->core_class.resize)(a_this);
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : change_widget_size : end\n");
#endif
}
static void draw_widget(Widget a_this,XEvent* a_event,Region a_region) {
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : draw_widget : %s\n",XtName(a_this));
#endif
if(widget_class()->core_class.superclass->core_class.expose!=NULL)
(widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
if(make_current(a_this)==1) {
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : draw_widget : %s : make_current ok : call paintCallback...\n",XtName(a_this));
#endif
XoAnyCallbackStruct value;
value.reason = XoCR_PAINT;
value.event = a_event;
@@ -296,10 +269,6 @@ protected:
::glXSwapBuffers(XtDisplay(a_this),XtWindow(a_this));
::glXMakeCurrent(XtDisplay(a_this),None,NULL);
}
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
printf("debug : OpenGLArea : draw_widget : end\n");
#endif
}
protected:
@@ -485,5 +454,4 @@ public:
}}
#endif
+26 -3
View File
@@ -61,9 +61,6 @@ public:
return true;
}
bool sync() {
//if(!m_app_widget) return false;
//Display* display = XtDisplay(m_app_widget);
//::XSync(display,False);
if(!m_app_context) return false;
while(true) {
XtInputMask input = ::XtAppPending(m_app_context);
@@ -85,5 +82,31 @@ protected:
}}
#include <X11/IntrinsicP.h>
namespace toolx {
namespace Xt {
inline bool post_expose(Widget a_widget) {
if(!XtIsRealized(a_widget)) return false;
XEvent event;
event.type = Expose;
event.xexpose.serial = 0;
event.xexpose.send_event = True;
event.xexpose.display = XtDisplay(a_widget);
event.xexpose.window = XtWindow(a_widget);
event.xexpose.x = 0;
event.xexpose.y = 0;
event.xexpose.width = a_widget->core.width;
event.xexpose.height = a_widget->core.height;
event.xexpose.count = 0;
//locks
Status stat = ::XSendEvent(event.xexpose.display,event.xexpose.window,False,0L,&event);
::XFlush(event.xexpose.display);
//unlock();
return (stat==0?false:true);
}
}}
#endif
+43 -15
View File
@@ -6,8 +6,30 @@
#include "session"
#ifndef GL_GLEXT_LEGACY
#define GL_GLEXT_LEGACY
#endif
#include <GL/gl.h>
#ifdef TOOLS_USE_GL_VERSION_3_2
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#endif
#include <GL/glext.h>
#endif
#include "../GL/gl_functions"
#include "../sg/GL_action"
#include "../sg/GL_viewer"
namespace toolx {
namespace sg {
using GL_action = GL_action_T<GL::gl_functions>;
using GL_manager = GL_manager_T<GL::gl_functions>;
using GL_viewer = GL_viewer_T<GL_manager,GL_action>;
}}
#include "OpenGLArea"
#include <X11/Shell.h>
@@ -62,9 +84,6 @@ public:
::XtAddCallback(m_shell,XtNdestroyCallback,destroy_shell_callback,(XtPointer)this);
::XtRealizeWidget(m_shell);
//Atom WM_DELETE_WINDOW_atom = ::XInternAtom(XtDisplay(m_shell),"WM_DELETE_WINDOW",False);
//::XSetWMProtocols(XtDisplay(m_shell),XtWindow(m_shell),&WM_DELETE_WINDOW_atom,1);
}
virtual ~sg_viewer() {
if(m_shell) {
@@ -105,7 +124,14 @@ public:
}
void win_render() {
if(m_glarea) OpenGLArea::paint(m_glarea);
if(!m_glarea) return;
OpenGLArea::paint(m_glarea);
m_session.sync();
}
void emit_win_render() {
if(!m_glarea) return;
if(!post_expose(m_glarea)) {}
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -125,7 +151,6 @@ protected:
static void paint_cbk(Widget a_widget,XtPointer a_tag,XtPointer){
unsigned int width = a_widget->core.width;
unsigned int height = a_widget->core.height;
//::printf("debug : toolx::Xt::sg_viewer::paint_cbk : %d %d\n",width,height);
sg_viewer* _this = (sg_viewer*)a_tag;
_this->set_size(width,height);
_this->render();
@@ -157,22 +182,26 @@ protected:
} else if(xevent->xbutton.button==Button5) { //5=wheel up, or move up double touch on trackpad = zoom out.
tools::sg::wheel_rotate_event event(-8,xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier); //8=cooking.
_this->m_interactor->wheel_rotate(event);
} else {
} else if(xevent->xbutton.button==Button1) {
tools::sg::mouse_down_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
_this->m_interactor->mouse_press(event);
}
}return;
case ButtonRelease:{
bool shift_modifier = xevent->xkey.state & ShiftMask;
bool control_modifier = xevent->xkey.state & ControlMask;
tools::sg::mouse_up_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
_this->m_interactor->mouse_release(event);
if(xevent->xbutton.button==Button1) {
bool shift_modifier = xevent->xkey.state & ShiftMask;
bool control_modifier = xevent->xkey.state & ControlMask;
tools::sg::mouse_up_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
_this->m_interactor->mouse_release(event);
}
}return;
case MotionNotify:{
bool shift_modifier = xevent->xkey.state & ShiftMask;
bool control_modifier = xevent->xkey.state & ControlMask;
tools::sg::mouse_move_event event(xevent->xmotion.x,xevent->xmotion.y,shift_modifier,control_modifier,0,0,false);
_this->m_interactor->mouse_move(event);
if((xevent->xmotion.state & Button1MotionMask)==Button1MotionMask) {
bool shift_modifier = xevent->xkey.state & ShiftMask;
bool control_modifier = xevent->xkey.state & ControlMask;
tools::sg::mouse_move_event event(xevent->xmotion.x,xevent->xmotion.y,shift_modifier,control_modifier,0,0,false);
_this->m_interactor->mouse_move(event);
}
}return;
default:return;}
}
@@ -197,4 +226,3 @@ protected:
}}
#endif
+9 -8
View File
@@ -69,9 +69,6 @@ public:
iscreen = XScreenNumberOfScreen(screen);
m_pixwin = new toolx::X11::pixwin(a_session.out(),iscreen,XtDisplay(app_widget));
m_pixwin->set_size(m_image_area->core.width,m_image_area->core.height);}
//Atom WM_DELETE_WINDOW_atom = ::XInternAtom(XtDisplay(m_shell),"WM_DELETE_WINDOW",False);
//::XSetWMProtocols(XtDisplay(m_shell),XtWindow(m_shell),&WM_DELETE_WINDOW_atom,1);
}
virtual ~zb_viewer() {
delete m_pixwin;
@@ -113,7 +110,14 @@ public:
}
void win_render() {
if(m_image_area) ImageArea::paint(m_image_area);
if(!m_image_area) return;
ImageArea::paint(m_image_area);
m_session.sync();
}
void emit_win_render() {
if(!m_image_area) return;
if(!post_expose(m_image_area)) {}
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -133,7 +137,6 @@ protected:
if(!XtIsRealized(a_widget)) return;
unsigned int width = a_widget->core.width;
unsigned int height = a_widget->core.height;
//::printf("debug: toolx::Xt::zb_viewer::resize_cbk: %d %d\n",width,height);
zb_viewer* _this = (zb_viewer*)a_tag;
_this->set_size(width,height);
_this->m_pixwin->set_size(width,height);
@@ -142,11 +145,9 @@ protected:
if(!XtIsRealized(a_widget)) return;
unsigned int width = a_widget->core.width;
unsigned int height = a_widget->core.height;
//::printf("debug: toolx::Xt::zb_viewer::paint_cbk: %d %d\n",width,height);
zb_viewer* _this = (zb_viewer*)a_tag;
if(!_this->render(tools::sg::zb_viewer::get_rgbas,false)) return; //rgbas because Qt wants an image 32 bits aligned.
_this->m_pixwin->put_buffer(XtWindow(a_widget),width,height,tools::vec_data(_this->out_buffer()));
//parent::after_render();
_this->m_pixwin->put_buffer(XtWindow(a_widget),width,height,_this->out_buffer().data());
_this->out_buffer_clear();
}
static void event_cbk(Widget,XtPointer a_tag,XtPointer a_data){
-29
View File
@@ -1,29 +0,0 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_glbuf
#define toolx_glbuf
//define of TOOLX_HAS_GL_VBO decided in the build systems.
// To have prototypes of glGenBuffers,etc...
#ifdef TOOLX_HAS_GL_VBO
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if TARGET_OS_IPHONE
#elif defined(ANDROID)
#elif _WIN32
#include <GL/glext.h>
#elif __APPLE__
#include <OpenGL/glext.h> //Cocoa
#else
#include <GL/glext.h>
#endif
#endif //TOOLX_HAS_GL_VBO
#endif
+3 -303
View File
@@ -9,8 +9,6 @@
#include <tools/typedefs>
#include <tools/forit>
#include <tools/num2s>
#include <tools/vdata>
//#include <map>
namespace toolx {
namespace hdf5 {
@@ -205,7 +203,6 @@ inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
return false;
}
hsize_t cdims[1];
//cdims[0] = (a_size<=32?a_size:32);
cdims[0] = a_chunked;
if(H5Pset_chunk(cpt,1,cdims)<0) {
::H5Pclose(cpt);
@@ -326,7 +323,6 @@ inline bool write_append_array_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid
{hsize_t exts[1];
exts[0] = old_size+a_number;
// if(H5Dextend(dataset,exts)<0) {
if(H5Dset_extent(a_dataset,exts)<0) return false;}
hid_t file_space = H5Dget_space(a_dataset);
@@ -378,7 +374,6 @@ inline bool write_append_vlen_dataset(hid_t a_dataset,hid_t /*a_file_type*/,hid_
{hsize_t exts[1];
exts[0] = old_size+1;
// if(H5Dextend(dataset,exts)<0) {
if(H5Dset_extent(a_dataset,exts)<0) return false;}
hid_t file_space = H5Dget_space(a_dataset);
@@ -431,40 +426,6 @@ inline bool write_append_array(hid_t a_loc,const std::string& a_name,hid_t a_fil
return status;
}
/*
template <class T>
inline bool write_array_struct(
hid_t a_loc
,const std::string& a_name
,hid_t a_create_type
,hid_t aWriteType
,unsigned int a_size
,const T a_array[]
){
hsize_t dims[1];
dims[0] = a_size;
hid_t dataspace = ::H5Screate_simple(1,dims,NULL);
if(dataspace<0) return false;
hid_t dataset = toolx_H5Dcreate(a_loc,a_name.c_str(),a_create_type,dataspace,H5P_DEFAULT);
if(dataset<0) {
::H5Sclose(dataspace);
return false;
}
if(H5Dwrite(dataset,aWriteType,H5S_ALL,H5S_ALL,H5P_DEFAULT,a_array)<0) {
::H5Dclose(dataset);
::H5Sclose(dataspace);
return false;
}
::H5Dclose(dataset);
::H5Sclose(dataspace);
return true;
}
*/
template <class T>
inline bool read_scalar(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,T& a_data) {
hid_t dataset = toolx_H5Dopen(a_loc,a_name.c_str());
@@ -529,7 +490,6 @@ inline bool read_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,un
if(a_alloc) a_array = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
}
hsize_t dims[1];
@@ -578,106 +538,6 @@ inline bool read_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,un
return true;
}
/*
template <class T>
inline bool read_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,unsigned int& a_size,T*& a_array) {
hid_t dataset = toolx_H5Dopen(a_loc,a_name.c_str());
if(dataset<0) {
a_size = 0;
a_array = 0;
return false; // data set not found.
}
hid_t file_space = H5Dget_space(dataset);
if(file_space<0) {
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
{int dimn = H5Sget_simple_extent_ndims(file_space);
if(dimn<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
if(dimn!=1) {
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
}
hsize_t dims[1];
{if(H5Sget_simple_extent_dims(file_space,dims,NULL)<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}}
unsigned int _size = (unsigned int)dims[0];
if(_size!=1) {
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
hid_t mem_space = ::H5Screate_simple(1,dims,NULL);
if(mem_space<0) {
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
hid_t mem_type = ::H5Tvlen_create(a_mem_type);
hvl_t rdata[1];
if(H5Dread(dataset,mem_type,mem_space,file_space,H5P_DEFAULT,rdata)<0) {
//::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata); ???
::H5Tclose(mem_type);
::H5Sclose(mem_space);
::H5Sclose(file_space);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
hsize_t len = rdata[0].len;
if(!len) {
//a_array = new T[1];
a_array = 0; //it is ok.
} else {
a_array = new T[len];
T* _data = (T*)rdata[0].p;
T* pos = a_array;
for(hsize_t index=0;index<len;index++,pos++,_data++) *pos = *_data;
}
a_size = len;
::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata);
::H5Tclose(mem_type);
::H5Sclose(mem_space);
::H5Sclose(file_space);
::H5Dclose(dataset);
return true;
}
*/
template <class T>
inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,
unsigned int a_offset,unsigned int a_number,
@@ -712,7 +572,6 @@ inline bool read_sub_array(hid_t a_loc,const std::string& a_name,hid_t a_mem_typ
a_array = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
}
hsize_t dims[1];
@@ -828,7 +687,6 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
a_array = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
}
hsize_t dims[1];
@@ -886,7 +744,6 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
hvl_t rdata[1];
if(H5Dread(dataset,mem_type,mem_space,file_space,H5P_DEFAULT,rdata)<0) {
//::H5Dvlen_reclaim(mem_type,mem_space,H5P_DEFAULT,rdata); ???
::H5Tclose(mem_type);
::H5Sclose(mem_space);
::H5Sclose(file_space);
@@ -898,7 +755,6 @@ inline bool read_sub_vlen(hid_t a_loc,const std::string& a_name,hid_t a_mem_type
hsize_t len = rdata[0].len;
if(!len) {
//a_array = new T[1];
a_array = 0; //it is ok.
} else {
a_array = new T[len];
@@ -929,7 +785,7 @@ inline bool read_std_vec(hid_t a_loc,const std::string& a_name,hid_t a_mem_type,
if(!read_scalar<tools::uint64>(a_loc,a_name+"_size",sz)) return false;
if(!sz) {a_vec.clear();return true;} //it is ok.
a_vec.resize((size_t)sz);
T* data = tools::vec_data(a_vec);
T* data = a_vec.data();
unsigned int _sz;
if(!read_array(a_loc,a_name,a_mem_type,_sz,data,false)) return false; //false = do not alloc.
if(tools::uint64(_sz)!=sz) {a_vec.clear();return false;}
@@ -949,91 +805,6 @@ inline bool read_std_vec_vec(hid_t a_loc,const std::string& a_name,hid_t a_mem_t
return true;
}
/*
template <class T>
inline bool read_array_struct(
hid_t a_loc
,const std::string& a_name
,hid_t aReadType
,unsigned int& a_size
,T*& a_array
){
hid_t dataset = toolx_H5Dopen(a_loc,a_name.c_str());
if(dataset<0) {
a_size = 0;
a_array = 0;
return false; // data set not found.
}
hid_t dataspace = H5Dget_space(dataset);
if(dataspace<0) {
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
int dimn = H5Sget_simple_extent_ndims(dataspace);
if(dimn<0) {
::H5Sclose(dataspace);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
hsize_t* dims = new hsize_t[dimn];
{int rdimn = H5Sget_simple_extent_dims(dataspace,dims,NULL);
if(rdimn<0) {
delete [] dims;
::H5Sclose(dataspace);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}}
hid_t memspace = ::H5Screate_simple(dimn,dims,NULL);
if(memspace<0) {
delete [] dims;
::H5Sclose(dataspace);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
a_size = (unsigned int)dims[0];
delete [] dims;
if(!a_size) {
::H5Sclose(memspace);
::H5Sclose(dataspace);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
a_array = new T[a_size];
if(H5Dread(dataset,aReadType,memspace,dataspace,H5P_DEFAULT,a_array)<0) {
delete [] a_array;
::H5Sclose(memspace);
::H5Sclose(dataspace);
::H5Dclose(dataset);
a_size = 0;
a_array = 0;
return false;
}
::H5Sclose(memspace);
::H5Sclose(dataspace);
::H5Dclose(dataset);
return true;
}
*/
template <class T>
inline bool read_struct(hid_t a_loc,const std::string& a_name,hid_t aReadType,T& a_data) {
hid_t dataset = toolx_H5Dopen(a_loc,a_name.c_str());
@@ -1166,7 +937,7 @@ inline bool write_std_vec(hid_t a_loc,const std::string& a_name,
const std::vector<T>& a_vec) {
if(!write_scalar<tools::uint64>(a_loc,a_name+"_size",a_vec.size())) return false;
if(a_vec.empty()) return true; //it is ok.
const T* data = tools::vec_data(a_vec);
const T* data = a_vec.data();
return write_array(a_loc,a_name,a_file_type,a_mem_type,a_chunked,a_compress,a_vec.size(),data);
}
@@ -1182,7 +953,7 @@ inline bool write_std_vec_vec(hid_t a_loc,const std::string& a_name,const std::v
if(!write_scalar<tools::uint64>(a_loc,a_name+"_size",a_vec_vec.size())) return false;
unsigned int count = 0; //uint for num2s.
std::string scount;
tools_typename_vforcit(std::vector<TYPE>,a_vec_vec,it) {
for(auto it = a_vec_vec.cbegin(); it != a_vec_vec.cend(); ++it) {
tools::num2s(count,scount);
if(!write_std_vec<TYPE>(a_loc,a_name+"_elem_"+scount,*it)) return false;
count++;
@@ -1190,21 +961,6 @@ inline bool write_std_vec_vec(hid_t a_loc,const std::string& a_name,const std::v
return true;
}
//template <class TKEY,class TVALUE>
//inline bool write_std_map(hid_t a_loc,const std::string& a_name,const std::map<TKEY,TVALUE>& a_map,
// unsigned int a_chunked = 0,unsigned int a_compress = 0) {
// if(!write_scalar<tools::uint64>(a_loc,a_name+"_size",a_map.size())) return false;
// unsigned int count = 0; //uint for num2s.
// std::string scount;
// tools_typename_mforcit(TKEY,TVALUE,a_map,it) {
// tools::num2s(count,scount);
// if(!write_scalar<TKEY>(a_loc,a_name+"_elem_"+scount+"_first",(*it).first)) return false;
// if(!write_scalar<TVALUE>(a_loc,a_name+"_elem_"+scount+"_secon",(*it).second)) return false;
// count++;
// }
// return true;
//}
template <class TYPE>
inline bool write_sub_array(hid_t a_loc,const std::string& a_name,
unsigned int a_size,unsigned int a_offset,unsigned int a_number,const TYPE a_array[],
@@ -1234,11 +990,6 @@ inline bool read_array(hid_t a_loc,const std::string& a_name,unsigned int& a_siz
return read_array<TYPE>(a_loc,a_name,to_T_mem_type(TYPE()),a_size,a_array);
}
//template <class TYPE>
//inline bool read_vlen(hid_t a_loc,const std::string& a_name,unsigned int& a_size,TYPE*& a_array) {
// return read_vlen<TYPE>(a_loc,a_name,to_T_mem_type(TYPE()),a_size,a_array);
//}
template <class TYPE>
inline bool read_std_vec(hid_t a_loc,const std::string& a_name,std::vector<TYPE>& a_vec) {
return read_std_vec<TYPE>(a_loc,a_name,to_T_mem_type(TYPE()),a_vec);
@@ -1312,55 +1063,4 @@ inline bool write_scalar_atb(hid_t aDS,const std::string& a_name,const TYPE& aDa
}}
/*
#include <tools/buf2lines>
namespace toolx {
namespace hdf5 {
inline bool write_strings(hid_t a_loc,const std::string& a_name,
size_t a_number,const char** a_strings,
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
size_t sz;char* buffer;
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
a_chunked,a_compress,(unsigned int)sz,buffer);
delete [] buffer;
return status;
}
inline bool write_strings(hid_t a_loc,const std::string& a_name,
const std::vector<std::string>& a_strings,
unsigned int a_chunked = 0,unsigned int a_compress = 0) {
size_t sz;char* buffer;
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),
a_chunked,a_compress,(unsigned int)sz,buffer);
delete [] buffer;
return status;
}
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,size_t a_number,const char** a_strings) {
size_t sz;char* buffer;
if(!tools::strings2buf(a_number,a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);
delete [] buffer;
return status;
}
inline bool write_append_strings(hid_t a_loc,const std::string& a_name,const std::vector<std::string>& a_strings) {
size_t sz;char* buffer;
if(!tools::strings2buf(a_strings,sz,buffer)) return false;
sz--;
bool status = hdf5::write_append_array<char>(a_loc,a_name,to_T_file_type(char()),to_T_mem_type(char()),(unsigned int)sz,buffer);
delete [] buffer;
return status;
}
}}
*/
#endif
@@ -30,7 +30,6 @@ inline herr_t group_exists_visit(hid_t a_id,const char* a_name,void* a_tag){ //a
switch(statbuf.type) {
case H5G_GROUP:{
if(a_name==visitor->m_what) {visitor->m_found=true;return 0;} //found
//::H5Giterate(a_id,a_name,NULL,group_exists_visit,visitor);
}break;
default:
break;
+1 -3
View File
@@ -26,7 +26,7 @@ inline bool write_std_map_ss(hid_t a_loc,const std::string& a_name,const std::ma
if(!write_scalar<tools::uint64>(a_loc,a_name+"_size",a_map.size())) return false;
unsigned int count = 0; //uint for num2s.
std::string scount;
tools_mforcit(std::string,std::string,a_map,it) {
for(auto it = a_map.cbegin(); it != a_map.cend(); ++it) {
tools::num2s(count,scount);
if(!write_string(a_loc,a_name+"_elem_"+scount+"_first",(*it).first)) return false;
if(!write_string(a_loc,a_name+"_elem_"+scount+"_secon",(*it).second)) return false;
@@ -208,8 +208,6 @@ template <class HISTO>
inline bool read_histo(std::ostream& a_out,hid_t a_loc,const std::string& a_name,HISTO*& a_histo,bool a_verb_class = true) {
a_histo = 0;
//if(::H5Gget_objinfo(a_loc,a_name.c_str(),0,NULL)<0) {return false;}
hid_t histo = toolx_H5Gopen(a_loc,a_name.c_str());
if(histo<0) {
a_out << "toolx::hdf5::read_histo : can't open group." << std::endl;
+4 -107
View File
@@ -6,7 +6,6 @@
#include "store"
#include <tools/vfind>
#include <tools/vmanip>
#include <tools/ntuple_binding>
#include <tools/ntuple_booking>
@@ -15,12 +14,6 @@
#include <tools/forit>
#include <tools/stype>
#include <tools/mnmx>
#include <tools/vdata>
#ifdef TOOLS_MEM
#include <tools/mem>
#include <tools/stype>
#endif
namespace toolx {
namespace hdf5 {
@@ -45,12 +38,6 @@ public:
template <class T>
class column_ref : public virtual icol {
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::column_ref<"+tools::stype(T())+">");
return s_v;
}
#endif
public:
static tools::cid id_class() {
static const T s_v = T(); //do that for T = std::string.
@@ -100,7 +87,7 @@ public:
m_want_new_basket_size = 0;
}
tools::uint64 remain = m_branch.entries()-m_branch.pos();
size_t n = tools::mn<size_t>((size_t)remain,m_basket_size);
size_t n = tools::min_of<size_t>((size_t)remain,m_basket_size);
if(!m_branch.read_page<T>(n,m_basket)) {
m_store.out() << "toolx::hdf5::ntuple::column_ref:fetch_entry : read_page() failed." << std::endl;
m_basket_pos = 0;
@@ -134,14 +121,11 @@ public:
,m_basket(0)
,m_want_new_basket_size(0)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
m_basket = new T[m_basket_size];
if(m_write) {
} else { //read.
tools::uint64 _entries = m_branch.entries();
size_t n = tools::mn<size_t>((size_t)_entries,m_basket_size);
size_t n = tools::min_of<size_t>((size_t)_entries,m_basket_size);
if(_entries) {
if(!m_branch.read_page<T>(n,m_basket)) {
m_store.out() << "toolx::hdf5::ntuple::column_ref:column_ref : read_page() failed." << std::endl;
@@ -161,9 +145,6 @@ public:
}
}
delete [] m_basket;
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
column_ref(const column_ref& a_from)
@@ -204,12 +185,6 @@ public:
template <class T>
class column : public column_ref<T> {
typedef column_ref<T> parent;
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::column<"+tools::stype(T())+">");
return s_v;
}
#endif
public:
static tools::cid id_class() {
static const T s_v = T(); //do that for T = std::string.
@@ -225,14 +200,8 @@ public:
:parent(a_store,a_pages,a_write,a_name,a_basket_size,m_tmp)
,m_tmp(T())
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~column(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
column(const column& a_from)
@@ -271,12 +240,6 @@ public:
template <class T>
class std_vector_column_ref : public virtual icol {
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::std_vector_column_ref<"+tools::stype(T())+">");
return s_v;
}
#endif
public:
static tools::cid id_class() {return tools::_cid_std_vector<T>()+10000;}
virtual void* cast(tools::cid a_class) const {
@@ -287,7 +250,7 @@ public:
public: //icol
virtual bool add() { //write.
if(!m_write) return false;
const T* _data = tools::vec_data(m_ref);
const T* _data = m_ref.data();
return m_branch.write_vlen<T>(m_ref.size(),_data);
}
virtual bool fetch_entry() { //read.
@@ -300,7 +263,7 @@ public:
}
m_ref.resize(n);
T* dpos = _data;
T* pos = tools::vec_data(m_ref);
T* pos = m_ref.data();
for(size_t index=0;index<n;index++,pos++,dpos++) *pos = *dpos;
delete [] _data;
return true;
@@ -318,14 +281,8 @@ public:
,m_name(a_name)
,m_ref(a_ref)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~std_vector_column_ref(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
std_vector_column_ref(const std_vector_column_ref& a_from)
@@ -352,12 +309,6 @@ public:
template <class T>
class std_vector_column : public std_vector_column_ref<T> {
typedef std_vector_column_ref<T> parent;
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::std_vector_column<"+tools::stype(T())+">");
return s_v;
}
#endif
public:
static tools::cid id_class() {return tools::_cid_std_vector<T>();}
virtual void* cast(tools::cid a_class) const {
@@ -386,9 +337,6 @@ public:
};
class column_string_ref : public virtual icol {
#ifdef TOOLS_MEM
TOOLS_SCLASS(toolx::hdf5::ntuple::column_string_ref)
#endif
public:
static tools::cid id_class() {
static const std::string s_v;
@@ -425,14 +373,8 @@ public:
,m_name(a_name)
,m_ref(a_ref)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~column_string_ref(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
column_string_ref(const column_string_ref& a_from)
@@ -458,9 +400,6 @@ public:
class column_string : public column_string_ref {
typedef column_string_ref parent;
#ifdef TOOLS_MEM
TOOLS_SCLASS(toolx::hdf5::ntuple::column_string)
#endif
public:
static tools::cid id_class() {
static const std::string s_v;
@@ -475,14 +414,8 @@ public:
column_string(store& a_store,pages& a_pages,bool a_write,const std::string& a_name,tools::uint32 a_basket_size)
:parent(a_store,a_pages,a_write,a_name,a_basket_size,m_tmp)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~column_string(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
column_string(const column_string& a_from)
@@ -504,12 +437,6 @@ public:
class std_vector_column_string_ref : public virtual icol {
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::std_vector_column_string_ref");
return s_v;
}
#endif
public:
static tools::cid id_class() {return tools::_cid_std_vector<std::string>()+10000;}
virtual void* cast(tools::cid a_class) const {
@@ -568,14 +495,8 @@ public:
,m_name(a_name)
,m_ref(a_ref)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~std_vector_column_string_ref(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
std_vector_column_string_ref(const std_vector_column_string_ref& a_from)
@@ -601,12 +522,6 @@ public:
class std_vector_column_string : public std_vector_column_string_ref {
typedef std_vector_column_string_ref parent;
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::hdf5::ntuple::std_vector_column_string");
return s_v;
}
#endif
public:
static tools::cid id_class() {return tools::_cid_std_vector<std::string>();}
virtual void* cast(tools::cid a_class) const {
@@ -629,10 +544,6 @@ public:
return *this;
}
public:
//bool get_entry(std::vector<T>& a_v) const {
// a_v = m_tmp;
// return true;
//}
const std::vector<std::string>& data() const {return m_tmp;}
protected:
std::vector<std::string> m_tmp;
@@ -683,8 +594,6 @@ public:
else TOOLX_HDF5_NTUPLE_READ_CREATE_COL(tools::uint32)
else TOOLX_HDF5_NTUPLE_READ_CREATE_COL(tools::uint64)
//else TOOLX_HDF5_NTUPLE_READ_CREATE_COL(bool) //use byte=uchar.
else
if((*it)->form()==s_string()) {
column_string* col = new column_string(*this,*(*it),false,(*it)->name(),0);
@@ -706,7 +615,6 @@ public:
else TOOLX_HDF5_NTUPLE_READ_CREATE_VEC_COL(uint64,tools::uint64)
else TOOLX_HDF5_NTUPLE_READ_CREATE_VEC_COL_STRING
// else TOOLX_HDF5_NTUPLE_READ_CREATE_VEC_COL(bool) //use byte=uchar.
else {
m_out << "toolx::hdf5::ntuple::ntuple(read) :"
@@ -811,8 +719,6 @@ public:
else TOOLX_HDF5_NTUPLE_CREATE_COL(tools::uint32)
else TOOLX_HDF5_NTUPLE_CREATE_COL(tools::uint64)
//else TOOLX_HDF5_NTUPLE_CREATE_COL(bool) //use byte=uchar.
else if((*it).cls_id()==tools::_cid(std::string())) {
if(!create_column_string((*it).name(),a_basket_size)) {
m_out << "toolx::hdf5::ntuple :"
@@ -836,8 +742,6 @@ public:
else TOOLX_HDF5_NTUPLE_CREATE_VEC_COL(tools::uint64)
else TOOLX_HDF5_NTUPLE_CREATE_VEC_COL_STRING
// else TOOLX_HDF5_NTUPLE_CREATE_VEC_COL(std::string)
// else TOOLX_HDF5_NTUPLE_CREATE_VEC_COL(bool) //use byte=uchar.
else {
m_out << "toolx::hdf5::ntuple :"
@@ -923,8 +827,6 @@ public:
else TOOLX_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::uint32)
else TOOLX_HDF5_NTUPLE_READ_BINDING_CREATE_COL(tools::uint64)
//else TOOLX_HDF5_NTUPLE_READ_BINDING_CREATE_COL(bool) //use byte=uchar.
else
if((*it)->form()==s_string()) {
std::string* user_var = a_bd.find_variable<std::string>((*it)->name());
@@ -954,8 +856,6 @@ public:
else TOOLX_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL_STRING
// else TOOLX_HDF5_NTUPLE_READ_BINDING_CREATE_VEC_COL(bool) //use byte=uchar.
else {
a_out << "toolx::hdf5::ntuple::ntuple(read with binding) :"
<< " for column " << tools::sout((*it)->name())
@@ -1096,9 +996,6 @@ public:
if(m_cols.empty()) return false;
bool status = true;
tools_vforit(icol*,m_cols,it) {if(!(*it)->add()) status = false;}
//tools::uint32 n;
//bool status = store::fill(n);
//tools_vforit(icol*,m_cols,it) (*it)->set_def();
return status;
}
-94
View File
@@ -9,10 +9,6 @@
#include <tools/S_STRING>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
#include <ostream>
namespace toolx {
@@ -33,9 +29,6 @@ public:
:m_out(a_out),m_name(a_name),m_form(a_form)
//,m_type(0),m_size(0)
,m_group(-1),m_dataset(-1),m_write(a_write),m_compress(a_compress),m_entries(0),m_pos(0){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
if(m_write) {
m_group = toolx_H5Gcreate(a_group,m_name.c_str(),0);
if(m_group<0) {
@@ -79,15 +72,9 @@ public:
if(m_dataset>=0) ::H5Dclose(m_dataset);
}
::H5Gclose(m_group);
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
pages(const pages& a_from):m_out(a_from.m_out){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
pages& operator=(const pages&){return *this;}
public:
@@ -95,8 +82,6 @@ public:
const std::string& name() const {return m_name;}
const std::string& form() const {return m_form;}
//int type() const {return m_type;}
//unsigned int size() const {return m_size;}
tools::uint64 entries() const {return m_entries;}
tools::uint64 pos() const {return m_pos;}
void reset_pos() {m_pos = 0;}
@@ -223,89 +208,10 @@ public:
return true;
}
/*
bool write_string(const std::string& a_string) {return write_vlen<char>(a_string.size(),a_string.c_str());}
bool read_string(std::string& a_string) {
size_t sz;char* _data;
if(!read_vlen<char>(sz,_data)) {a_string.clear();return false;}
a_string.resize(sz);
for(size_t index=0;index<sz;index++) a_string[index] = _data[index];
delete [] _data;
return true;
}
*/
/*
bool write_strings(size_t a_number,void* a_array) {
size_t sz = m_size*a_number;
char* buffer = new char[sz];
{char* pos = buffer;
for(size_t index=0;index<sz;index++,pos++) *pos = ' ';}
{char** strings = (char**)a_array;
char* pos = buffer;
size_t ls;
for(size_t index=0;index<a_number;index++) {
char* ss = strings[index];
ls = ::strlen(ss);
::memcpy(pos,ss,ls); //do not copy the ending 0.
*(pos+m_size-1) = 0;
pos += m_size;
}}
if(!m_pos) {
unsigned int chunked = 32*m_size; //<size>A strings.
if(!write_array<char>(m_group,s_pages(),sz,buffer,chunked,m_compress)) {
m_out << "pages::write_strings : write_strings() failed. Pos " << m_pos << std::endl;
return false;
}
m_dataset = toolx_H5Dopen(m_group,s_pages().c_str());
if(m_dataset<0) {
m_out << "pages::write_strings : H5Dopen failed. Pos " << m_pos << std::endl;
return false;
}
} else {
if(!write_append_array_dataset<char>(m_dataset,sz,buffer)) {
m_out << "pages::write_strings : write_append_strings() failed. Pos " << m_pos << std::endl;
return false;
}
}
m_pos += a_number;
m_entries = m_pos;
return true;
}
bool read_strings(size_t a_size,char* a_array) {
unsigned int _size = a_size*m_size;
unsigned int n = 0;
char* array = 0;
if(!read_sub_array<char>(m_group,s_pages(),m_pos,_size,n,array)) {
m_out << "pages::read_strings : read_sub_array<char>() failed." << std::endl;
return false;
}
if(n!=_size) {
m_out << "pages::read_strings : size mismatch. Requested " << _size << ", got "<< n << "." << std::endl;
delete [] array;
return false;
}
char* pos = array;
{char** strings = (char**)a_array;
for(size_t index=0;index<a_size;index++) {
::memcpy(strings[index],pos,m_size*sizeof(char));
pos += m_size;
}}
delete [] array;
m_pos += n;
return true;
}
*/
protected:
std::ostream& m_out;
std::string m_name;
std::string m_form;
//int m_type;
//unsigned int m_size;
hid_t m_group;
hid_t m_dataset;
bool m_write;
-24
View File
@@ -22,9 +22,6 @@ public:
,m_compress(a_compress) //used at write.
,m_group(-1)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
if(m_write) {
if(a_name.empty()) {
a_out << "toolx::hdf5::store::store : string a_name is empty." << std::endl;
@@ -115,15 +112,11 @@ public:
}
{std::vector<std::string> names;
tools_vforcit(pages*,m_pagess,it) names.push_back((*it)->name());
//{m_out << "debug : write : names :" << std::endl;
// tools_vforcit(std::string,names,it) m_out << *it << std::endl;}
if(!write_array_string(m_group,s_names(),names)) {
m_out << "toolx::hdf5::store::~store : write_array_string(names) failed." << std::endl;
}}
{std::vector<std::string> TFORMs;
tools_vforcit(pages*,m_pagess,it) TFORMs.push_back((*it)->form());
//{m_out << "debug : write : TFORMs :" << std::endl;
// tools_vforcit(std::string,TFORMs,it) m_out << *it << std::endl;}
if(!write_array_string(m_group,s_forms(),TFORMs)) {
m_out << "toolx::hdf5::store::~store : write_array_string(tforms) failed." << std::endl;
}}
@@ -134,9 +127,6 @@ public:
} else {
::H5Gclose(m_group);
}
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
store(const store& a_from)
@@ -145,14 +135,10 @@ protected:
,m_compress(a_from.m_compress)
,m_group(-1)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
store& operator=(const store&){return *this;}
public:
std::ostream& out() const {return m_out;}
//bool fill(tools::uint32 &a_n){a_n = 0;return true;}
bool entries(tools::uint64& a_entries) const {
if(m_pagess.empty()) {a_entries = 0;return true;}
@@ -169,7 +155,6 @@ public:
}
pages* create_pages(const std::string& a_name,const std::string& a_form) {
//::printf("debug : create_pages %s %s\n",a_name.c_str(),a_form.c_str());
pages* _pages = new pages(m_out,m_group,a_name,a_form,m_write,m_compress);
if(!_pages->is_valid()) {
m_out << "toolx::hdf5::store::create_column : can't create pages." << std::endl;
@@ -179,15 +164,6 @@ public:
m_pagess.push_back(_pages);
return _pages;
}
/*
pages* find_column(unsigned int a_index) {
if(a_index>=m_pagess.size()) {
m_out << "toolx::hdf5::store::find_column : out of range index." << std::endl;
return 0;
}
return m_pagess[a_index];
}
const std::vector<pages*>& columns() const {return m_pagess;}*/
hid_t group() const {return m_group;}
unsigned int compress_level() const {return m_compress;}
-15
View File
@@ -110,7 +110,6 @@ inline hid_t compound_mem_type(hid_t a_file_type){
if(t_class!=H5T_COMPOUND) return failure();
size_t sz = H5Tget_size(a_file_type);
//printf("debug : compound_mem_type : sz %lu\n",sz);
hid_t mem_type = ::H5Tcreate(H5T_COMPOUND,sz);
if(mem_type<0) return failure();
@@ -119,12 +118,10 @@ inline hid_t compound_mem_type(hid_t a_file_type){
int mn = H5Tget_nmembers(a_file_type);
std::vector<unsigned int> szs(mn);
//printf("debug : members : %d\n",mn);
for(int index=0;index<mn;index++) {
char* mname = H5Tget_member_name(a_file_type,index);
size_t moffset = H5Tget_member_offset(a_file_type,index);
hid_t mtype = H5Tget_member_type(a_file_type,index);
//printf("debug : members : %d (%d) : %s : begin\n",index,mn,mname);
{H5T_class_t mclass = H5Tget_class(mtype);
if( (mclass==H5T_INTEGER) ||
@@ -222,7 +219,6 @@ inline hid_t compound_mem_type(hid_t a_file_type){
return failure();
}}
::H5Tclose(mtype);
//printf("debug : compound_mem_type : %d (%d) : %s : end\n",index,mn,mname);
if(mname) toolx_H5free_memory(mname);
}
@@ -300,7 +296,6 @@ inline bool dataset_vec_size(hid_t a_loc,const std::string& a_name,hsize_t& a_si
a_size = 0;
return false;
}
//printf("debug : read dimn %d\n",dimn);
hsize_t dims[1];
{if(H5Sget_simple_extent_dims(file_space,dims,NULL)<0) {
@@ -537,7 +532,6 @@ inline bool write_append_string_dataset(hid_t a_dataset,const std::string& a_str
{hsize_t exts[1];
exts[0] = old_size+1;
// if(H5Dextend(dataset,exts)<0) {
if(H5Dset_extent(a_dataset,exts)<0) return false;}
hid_t file_space = H5Dget_space(a_dataset);
@@ -859,15 +853,6 @@ inline bool read_sub_string(hid_t a_loc,const std::string& a_name,unsigned int a
return false;
}
//size_t sz = H5Tget_size(file_type); //it gives the largest string size in the dataset.
//if(!sz) {
// ::H5Tclose(file_type);
// ::H5Sclose(file_space);
// ::H5Dclose(dataset);
// a_string.clear();
// return false;
//}
::H5Tclose(file_type);
hid_t mem_type = str_datatype();
-9
View File
@@ -223,14 +223,8 @@ public:
,m_verbose(a_verbose)
,m_wrmpi(a_out,a_comm)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~hmpi(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
hmpi(const hmpi& a_from)
@@ -242,9 +236,6 @@ protected:
,m_verbose(a_from.m_verbose)
,m_wrmpi(a_from.m_out,a_from.m_comm)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
hmpi& operator=(const hmpi& a_from){
m_rank = a_from.m_rank;
-20
View File
@@ -10,22 +10,11 @@
#include <mpi.h>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
namespace toolx {
namespace mpi {
class world : public virtual tools::impi_world {
typedef tools::impi_world parent;
#ifdef TOOLS_MEM
protected:
static const std::string& s_class() {
static const std::string s_v("toolx::mpi::world");
return s_v;
}
#endif
public:
virtual bool init(int* a_argc,char*** a_argv) {
if(::MPI_Init(a_argc,a_argv)!=MPI_SUCCESS) return false;
@@ -48,20 +37,11 @@ public:
}
public:
world() {
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~world(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
world(const world& a_from):parent(a_from) {
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
world& operator=(const world&) {return *this;}
};
+12 -37
View File
@@ -7,30 +7,19 @@
#include "wait_buffer"
#include <tools/impi>
#include <tools/vdata>
#include <tools/realloc>
#include <tools/cmemT>
#include <tools/mnmx>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
// the below must be in sync with tools/typedefs
#if defined(_MSC_VER) || defined(__MINGW32__)
//typedef __int64 int64;
//typedef unsigned __int64 uint64;
#define TOOLX_MPI_UINT64 MPI_UNSIGNED_LONG_LONG
#define TOOLX_MPI_INT64 MPI_LONG_LONG
#elif defined(_LP64)
// 64 Bit Platforms
//typedef long int64;
//typedef unsigned long uint64;
#define TOOLX_MPI_UINT64 MPI_UNSIGNED_LONG
#define TOOLX_MPI_INT64 MPI_LONG
#else
// 32-Bit Platforms
//typedef long long int64;
//typedef unsigned long long uint64;
#define TOOLX_MPI_UINT64 MPI_UNSIGNED_LONG_LONG
#define TOOLX_MPI_INT64 MPI_LONG_LONG
#endif
@@ -159,10 +148,10 @@ public: //tools::impi
tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(unsigned int));
if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
#if defined(TOOLX_USE_MPI_PACK_NOT_CONST) || defined(TOOLS_USE_MPI_PACK_NOT_CONST)
if(::MPI_Pack(const_cast<unsigned int*>(tools::vec_data(a_v)),a_v.size(),
if(::MPI_Pack(const_cast<unsigned int*>(a_v.data()),a_v.size(),
MPI_UNSIGNED,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#else
if(::MPI_Pack(tools::vec_data(a_v),a_v.size(),MPI_UNSIGNED,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
if(::MPI_Pack(a_v.data(),a_v.size(),MPI_UNSIGNED,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#endif
m_out << "toolx::mpi::wrmpi : MPI_Pack(std::vector<unsigned int>) failed." << std::endl;
return false;
@@ -175,9 +164,9 @@ public: //tools::impi
tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(int));
if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
#if defined(TOOLX_USE_MPI_PACK_NOT_CONST) || defined(TOOLS_USE_MPI_PACK_NOT_CONST)
if(::MPI_Pack(const_cast<int*>(tools::vec_data(a_v)),a_v.size(),MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
if(::MPI_Pack(const_cast<int*>(a_v.data()),a_v.size(),MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#else
if(::MPI_Pack(tools::vec_data(a_v),a_v.size(),MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
if(::MPI_Pack(a_v.data(),a_v.size(),MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#endif
m_out << "toolx::mpi::wrmpi : MPI_Pack(std::vector<int>) failed." << std::endl;
return false;
@@ -190,9 +179,9 @@ public: //tools::impi
tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(double));
if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
#if defined(TOOLX_USE_MPI_PACK_NOT_CONST) || defined(TOOLS_USE_MPI_PACK_NOT_CONST)
if(::MPI_Pack(const_cast<double*>(tools::vec_data(a_v)),a_v.size(),MPI_DOUBLE,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
if(::MPI_Pack(const_cast<double*>(a_v.data()),a_v.size(),MPI_DOUBLE,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#else
if(::MPI_Pack(tools::vec_data(a_v),a_v.size(),MPI_DOUBLE,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
if(::MPI_Pack(a_v.data(),a_v.size(),MPI_DOUBLE,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
#endif
m_out << "toolx::mpi::wrmpi : MPI_Pack(std::vector<double>) failed." << std::endl;
return false;
@@ -311,7 +300,7 @@ public: //tools::impi
num_t num;
if(!unpack(num)) {a_v.clear();return false;}
a_v.resize(num);
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,tools::vec_data(a_v),a_v.size(),MPI_UNSIGNED,m_comm)!=MPI_SUCCESS) {
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,a_v.data(),a_v.size(),MPI_UNSIGNED,m_comm)!=MPI_SUCCESS) {
m_out << "toolx::mpi::wrmpi : MPI_Unpack(std::vector<unsigned int>) failed." << std::endl;
a_v.clear();
return false;
@@ -322,7 +311,7 @@ public: //tools::impi
num_t num;
if(!unpack(num)) {a_v.clear();return false;}
a_v.resize(num);
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,tools::vec_data(a_v),a_v.size(),MPI_INT,m_comm)!=MPI_SUCCESS) {
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,a_v.data(),a_v.size(),MPI_INT,m_comm)!=MPI_SUCCESS) {
m_out << "toolx::mpi::wrmpi : MPI_Unpack(std::vector<int>) failed." << std::endl;
a_v.clear();
return false;
@@ -333,7 +322,7 @@ public: //tools::impi
num_t num;
if(!unpack(num)) {a_v.clear();return false;}
a_v.resize(num);
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,tools::vec_data(a_v),a_v.size(),MPI_DOUBLE,m_comm)!=MPI_SUCCESS) {
if(::MPI_Unpack(m_buffer,m_size,&m_ipos,a_v.data(),a_v.size(),MPI_DOUBLE,m_comm)!=MPI_SUCCESS) {
m_out << "toolx::mpi::wrmpi : MPI_Unpack(std::vector<double>) failed." << std::endl;
a_v.clear();
return false;
@@ -384,7 +373,6 @@ public: //tools::impi
delete [] m_buffer;
m_size = 128;
m_buffer = new char[m_size];
//if(!m_buffer) {}
m_max = m_buffer+m_size;
m_pos = m_buffer;
m_ipos = 0; //IMPORTANT
@@ -429,9 +417,6 @@ public:
,m_pos(0)
,m_ipos(0)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
m_size = a_size;
m_buffer = new char[m_size];
//if(!m_buffer) {}
@@ -447,17 +432,11 @@ public:
,m_pos(0)
,m_ipos(0)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
m_max = m_buffer+m_size;
m_pos = m_buffer;
}
virtual ~wrmpi(){
delete [] m_buffer;
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
wrmpi(const wrmpi& a_from)
@@ -470,9 +449,6 @@ protected:
,m_pos(0)
,m_ipos(0)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
wrmpi& operator=(const wrmpi&){return *this;}
public:
@@ -484,18 +460,17 @@ public:
#endif
protected:
bool expand2(tools::uint32 a_new_size) {return expand(tools::mx<tools::uint32>(2*m_size,a_new_size));} //CERN-ROOT logic.
bool expand2(tools::uint32 a_new_size) {return expand(tools::max_of<tools::uint32>(2*m_size,a_new_size));} //CERN-ROOT logic.
bool expand(tools::uint32 a_new_size) {
tools::diff_pointer_t len = m_pos-m_buffer;
if(!tools::realloc<char>(m_buffer,a_new_size,m_size)) {
if(!tools::cmem_realloc<char>(m_buffer,a_new_size,m_size)) {
m_out << "toolx::mpi::wrmpi::expand :"
<< " can't realloc " << a_new_size << " bytes."
<< std::endl;
m_size = 0;
m_max = 0;
m_pos = 0;
//m_wb.set_eob(m_max);
return false;
}
m_size = a_new_size;
-1
View File
@@ -52,7 +52,6 @@ public:
m_out << "toolx::raxml::load_file :"
<< " reader not found for " << tools::sout(_tag_name)
<< std::endl;
//m_objects.clear(); //keep already loaded objects.
return false;
} else {
tools::raxml_out ro = rder(*_tree,m_out,m_verbose,m_read_tag);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+20 -19
View File
@@ -6,26 +6,26 @@
#include <tools/sg/viewer>
#include "GL_manager"
#include "GL_action"
namespace tools{namespace sg{class render_manager;}}
namespace toolx {
namespace sg {
class GL_viewer : public tools::sg::viewer {
TOOLS_HEADER(GL_viewer,toolx::sg::GL_viewer,tools::sg::viewer)
template <class GL_MANAGER,class GL_ACTION>
class GL_viewer_T : public tools::sg::viewer {
TOOLS_T2_HEADER(GL_MANAGER,GL_ACTION,GL_viewer_T,toolx::sg::GL_viewer_T,tools::sg::viewer)
public:
void render() {
if(!m_ww) return;
if(!m_wh) return;
m_gl_mgr.begin_render(0,0,m_ww,m_wh,
m_clear_color.r(),
m_clear_color.g(),
m_clear_color.b(),
m_clear_color.a());
if(!m_gl_mgr.begin_render(0,0,m_ww,m_wh,
m_clear_color.r(),
m_clear_color.g(),
m_clear_color.b(),
m_clear_color.a())) return;
GL_action action(m_gl_mgr,m_out,m_ww,m_wh);
GL_ACTION action(m_gl_mgr,m_out,m_ww,m_wh);
action.state().m_use_gsto = m_use_gsto;
action.set_do_transparency(false);
@@ -33,44 +33,45 @@ public:
m_sg.render(action);
if(!action.end()) { //check that matrices stack are ok.
m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
m_out << "toolx::sg::GL_viewer_T : bad gl_action end." << std::endl;
} else {
if(action.have_to_do_transparency()) {
action.set_do_transparency(true);
m_sg.render(action);
if(!action.end()) { //check that matrices stack are ok.
m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
m_out << "toolx::sg::GL_viewer_T : bad gl_action end." << std::endl;
}
}
}
//after_render();
m_gl_mgr.end_render();
}
public:
GL_viewer(std::ostream& a_out,unsigned int a_width,unsigned int a_height)
GL_viewer_T(std::ostream& a_out,unsigned int a_width,unsigned int a_height)
:parent(a_out,a_width,a_height)
,m_gl_mgr(a_out)
{}
virtual ~GL_viewer(){
virtual ~GL_viewer_T(){
//WARNING : nodes may refer m_gl_mgr (to handle gstos/texs), then
// we have to delete them first.
m_sg.clear();
}
public:
GL_viewer(const GL_viewer& a_from)
GL_viewer_T(const GL_viewer_T& a_from)
:parent(a_from)
,m_gl_mgr(a_from.m_gl_mgr)
{}
GL_viewer& operator=(const GL_viewer& a_from){
GL_viewer_T& operator=(const GL_viewer_T& a_from){
parent::operator=(a_from);
m_gl_mgr = a_from.m_gl_mgr;
return *this;
}
public:
const tools::sg::render_manager& render_manager() const {return m_gl_mgr;}
tools::sg::render_manager& render_manager() {return m_gl_mgr;}
protected:
GL_manager m_gl_mgr;
GL_MANAGER m_gl_mgr;
};
}}
-114
View File
@@ -1,114 +0,0 @@
// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef toolx_sg_gl
#define toolx_sg_gl
#include "../OpenGL"
#include <tools/platform> //for APPLE TargetConditionals.h
#include <tools/img>
#include <ostream>
#include <sstream>
namespace toolx {
namespace sg {
//namespace gl : no, problem with g4tools.
inline void gl_clear_errors() {
GLenum glerror = ::glGetError();
while(glerror!=GL_NO_ERROR) {
glerror = ::glGetError();
}
}
inline bool gl_dump_if_errors(std::ostream& a_out,const std::string& a_head) {
bool retval = false;
GLenum glerror = ::glGetError();
if(glerror!=GL_NO_ERROR) {
a_out << a_head
<< " we have gl errors :"
<< std::endl;
retval = true;
}
while(glerror!=GL_NO_ERROR) {
//#define GL_NO_ERROR 0
//#define GL_INVALID_ENUM 0x0500
//#define GL_INVALID_VALUE 0x0501
//#define GL_INVALID_OPERATION 0x0502
//#define GL_STACK_OVERFLOW 0x0503
//#define GL_STACK_UNDERFLOW 0x0504
//#define GL_OUT_OF_MEMORY 0x0505
//#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
std::ostringstream oss;
oss << "0x" << std::hex << glerror;
a_out << oss.str() << std::endl;
glerror = ::glGetError();
}
return retval;
}
inline void gl_dump_infos(std::ostream& a_out) {
std::string gl_version;
{const char* _sv = (const char*)::glGetString(GL_VERSION);
if(_sv) gl_version = _sv;}
std::string gl_vendor;
{const char* _sv = (const char*)::glGetString(GL_VENDOR);
if(_sv) gl_vendor = _sv;}
std::string gl_renderer;
{const char* _sv = (const char*)::glGetString(GL_RENDERER);
if(_sv) gl_renderer = _sv;}
std::string gl_extensions;
{const char* _sv = (const char*)::glGetString(GL_EXTENSIONS);
if(_sv) gl_extensions = _sv;}
GLint gl_texture_size;
::glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_texture_size);
//GLint gl_buffer_size;
//::glGetIntegerv(GL_BUFFER_SIZE, &gl_buffer_size);
a_out << "toolx::sg::gl::dump_infos :" << std::endl;
a_out << " GL_VERSION " << gl_version << std::endl;
a_out << " GL_VENDOR " << gl_vendor << std::endl;
a_out << " GL_RENDERER " << gl_renderer << std::endl;
a_out << " GL_EXTENSIONS " << gl_extensions << std::endl;
a_out << " GL_MAX_TEXTURE_SIZE " << gl_texture_size << std::endl;
//a_out << " GL_BUFFER_SIZE " << gl_buffer_size << std::endl;
}
inline bool gl_tex_img(std::ostream& a_out,const tools::img_byte& a_img) {
if(a_img.bpp()==1) {
//to pass eiffel-tower.png
#if defined(ANDROID) || TARGET_OS_IPHONE
tools::img_byte res;
if(!a_img.bw2x(3,res)) {
a_out << "toolx::sg::gl::tex_img : tools::img.bw2x() failed." << std::endl;
return false;
}
::glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,res.width(),res.height(),0,GL_RGB,GL_UNSIGNED_BYTE,res.buffer());
#else
::glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,a_img.width(),a_img.height(),0,GL_LUMINANCE,GL_UNSIGNED_BYTE,a_img.buffer());
#endif
} else if(a_img.bpp()==3) {
::glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,a_img.width(),a_img.height(),0,GL_RGB,GL_UNSIGNED_BYTE,a_img.buffer());
} else if(a_img.bpp()==4) {
::glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,a_img.width(),a_img.height(),0,GL_RGBA,GL_UNSIGNED_BYTE,a_img.buffer());
} else {
a_out << "toolx::sg::gl::tex_img : img.bpp() " << a_img.bpp() << " not treated." << std::endl;
return false;
}
return true;
}
}}
#endif
+33 -280
View File
@@ -4,7 +4,6 @@
#ifndef toolx_sg_text_freetype
#define toolx_sg_text_freetype
//#define TOOLX_DONE_FACE
#include <tools/sg/base_freetype>
#include <tools/sg/render_action>
@@ -12,7 +11,7 @@
#include <tools/sg/bbox_action>
#include <tools/sg/enums>
#include <tools/lina/vec3d>
#include <tools/fmanip>
#include <tools/file>
#include <tools/nostream>
#include <tools/lina/box_3f>
@@ -20,7 +19,6 @@
#include <tools/sg/group>
#include <tools/sg/blend>
#include <tools/sg/tex_quadrilateral>
#include <tools/platform> //for APPLE TargetConditionals.h
#include <tools/glutess/glutess>
@@ -33,8 +31,6 @@
#include FT_OUTLINE_H
#endif
//#define TOOLX_SG_TEXT_FREETYPE_DEBUG
namespace toolx {
namespace sg {
@@ -66,7 +62,7 @@ protected: //gstos
continue; //do we have the case num = 1 ?
}
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
// data is a line_strip(), convert it to lines.
@@ -75,7 +71,7 @@ protected: //gstos
size_t ngsto = nsegs*2*3; //3 = have a z (Windows GL).
size_t sz = gsto_data.size();
gsto_data.resize(sz+ngsto);
float* pxyz = tools::vec_data<float>(gsto_data)+sz;
float* pxyz = gsto_data.data()+sz;
tools::gl::line_strip_to_lines_2to3(num,data,pxyz);
}}
@@ -95,7 +91,7 @@ protected: //gstos
continue;
}
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
if((*it).first==tools::gl::triangles()) {
@@ -104,7 +100,7 @@ protected: //gstos
size_t ngsto = ntri*3*3;
size_t sz = gsto_data.size();
gsto_data.resize(sz+ngsto);
float* pxyz = tools::vec_data<float>(gsto_data)+sz;
float* pxyz = gsto_data.data()+sz;
tools::gl::cvt_2to3(num,data,pxyz);
@@ -115,7 +111,7 @@ protected: //gstos
size_t ngsto = ntri*3*3;
size_t sz = gsto_data.size();
gsto_data.resize(sz+ngsto);
float* pxyz = tools::vec_data<float>(gsto_data)+sz;
float* pxyz = gsto_data.data()+sz;
tools::gl::triangle_fan_to_triangles_2to3(num,data,pxyz);
@@ -126,7 +122,7 @@ protected: //gstos
size_t ngsto = ntri*3*3;
size_t sz = gsto_data.size();
gsto_data.resize(sz+ngsto);
float* pxyz = tools::vec_data<float>(gsto_data)+sz;
float* pxyz = gsto_data.data()+sz;
tools::gl::triangle_strip_to_triangles_2to3(num,data,pxyz);
@@ -141,9 +137,6 @@ protected: //gstos
m_gsto_sz = gsto_data.size();
if(gsto_data.empty()) {
//a_out << "toolx::sg::text_freetype::create_gsto :"
// << " empty buffer."
// << std::endl;
return 0;
}
@@ -206,11 +199,8 @@ public:
size_t pos = item.first;
size_t num = item.second;
if(!num) continue;
//a_out << "toolx::sg::text_freetype::render :"
// << " num points " << num
// << std::endl;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
a_action.draw_vertex_array_xy(tools::gl::line_strip(),num*2,data);
}}
@@ -225,11 +215,8 @@ public:
size_t pos = item.second.first;
size_t num = item.second.second;
if(!num) continue;
//a_out << "toolx::sg::text_freetype::render :"
// << " num points " << num
// << std::endl;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
a_action.draw_vertex_array_xy((*it).first,num*2,data);
}}
@@ -241,18 +228,7 @@ public:
///////////////////////////////////////////////////////////
/// bitmap ////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#if defined(ANDROID) /*|| TARGET_OS_IPHONE*/
// we do not have transparent texture here (see also gl/tex_img() that does img/4-bytes => img/3-bytes) :
{tools::sg::state& _state = a_action.state();
tools::colorf old_color = _state.m_color;
_state.m_color = tools::colorf_white();
a_action.color4f(_state.m_color);
m_bitmaps.render(a_action);
_state.m_color = old_color;
a_action.color4f(_state.m_color);}
#else
m_bitmaps.render(a_action);
#endif
}
virtual void pick(tools::sg::pick_action& a_action) {
@@ -262,34 +238,6 @@ public:
reset_touched();
}}
/*
//OPTIMIZATION : pick on the bounding box ?
if(m_face) {
tools::box3f box;
get_bounds(m_face,height,strings.values(),box);
vec3f mn = box.mn();
vec3f mx = box.mx();
mn = mtx*mn;
mx = mtx*mx;
if(a_action.is_inside(b[0],b[1])) {
//we have a pick.
a_action.set_done(true);
a_action.set_node(this);
return;
}
if(a_action.intersect(p1[0],p1[1],p2[0],p2[1],p3[0],p3[1])) {
a_action.set_done(true);
a_action.set_node(this);
return;
}
}
return;
*/
///////////////////////////////////////////////////////////
/// lines /////////////////////////////////////////////////
///////////////////////////////////////////////////////////
@@ -298,7 +246,7 @@ public:
const line_t& item = *it;
size_t pos = item.first;
size_t num = item.second;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
if(a_action.add__line_strip_xy(*this,2*num,data,true)) return;
}}
@@ -310,7 +258,7 @@ public:
const std::pair<GLUenum,triangle_t>& item = *it;
size_t pos = item.second.first;
size_t num = item.second.second;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
if(a_action.add__primitive_xy(*this,item.first,2*num,data,true)) return;
}}
@@ -330,7 +278,7 @@ public:
{tools_vforcit(line_t,m_lines,it) {
const line_t& item = *it;
size_t num = item.second;
const float* data = tools::vec_data<float>(m_xys)+item.first;
const float* data = m_xys.data()+item.first;
float px,py,pz;
float* pos = (float*)data;
@@ -349,7 +297,7 @@ public:
{tools_vforcit(gl_triangle_t,m_triangles,it) {
const std::pair<GLUenum,triangle_t>& item = *it;
size_t num = item.second.second;
const float* data = tools::vec_data<float>(m_xys)+item.second.first;
const float* data = m_xys.data()+item.second.first;
float px,py,pz;
float* pos = (float*)data;
@@ -425,10 +373,6 @@ public: //tools::sg::base_text :
if(!m_face) return 0;
float value;
if(!ascent(out,self().m_face,a_height,value)) return 0;
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
self().m_face = 0;
#endif
return value;
}
@@ -438,10 +382,6 @@ public: //tools::sg::base_text :
if(!m_face) return 0;
float value;
if(!descent(out,self().m_face,a_height,value)) return 0;
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
self().m_face = 0;
#endif
return value;
}
@@ -451,10 +391,6 @@ public: //tools::sg::base_text :
if(!m_face) return 0;
float value;
if(!y_advance(out,self().m_face,a_height,value)) return 0;
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
self().m_face = 0;
#endif
return value;
}
@@ -469,10 +405,6 @@ public: //tools::sg::base_text :
} else if(unitext.values().size()) {
if(!get_bounds(out,self().m_face,a_height,unitext.values(),a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z)) return;
}
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
self().m_face = 0;
#endif
}
virtual bool truncate(const std::string& a_string,float a_height,float a_cut_width,std::string& a_out) const {
@@ -481,20 +413,14 @@ public: //tools::sg::base_text :
if(!m_face) self().load_face(out);
if(!m_face) return false;
if(!truncate(out,self().m_face,a_height,a_string,a_cut_width,a_out)) return false;
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
self().m_face = 0;
#endif
return true;
}
void dump_unitext(std::ostream& a_out) {
//unitext.values().size()
a_out << "unitext size : " << unitext.values().size() << std::endl;
tools_vforcit(uniline,unitext.values(),vit) {
const uniline& line = *vit;
a_out << "beg line :" << std::endl;
//a_out << line << std::endl;
tools_vforcit(unichar,line,it) {
a_out << ((unsigned int)*it) << std::endl;
}
@@ -506,9 +432,6 @@ protected:
bool initialize() { //called from constructors.
FT_Error error = ::FT_Init_FreeType(&m_library);
if(error) {
//m_out << "toolx::sg::text_freetype :"
// << " error : " << serror(error) << "."
// << std::endl;
m_library = 0;
return false;
}
@@ -562,8 +485,6 @@ protected:
float screen_height = ymx-ymn;
if(a_state.m_wh) screen_height *= a_state.m_wh; else screen_height = 100;
//::printf("debug : char_height_touched %g\n",screen_height);
if(screen_height==m_char_height) return false;
m_char_height = screen_height;
return true;
@@ -576,10 +497,6 @@ protected:
if(!m_face) return;
//a_out << "toolx::sg::text_freetype::update_sg :"
// << " font file opened."
// << std::endl;
m_encoding_offset = 0;
if(!encoding_offset(m_face,m_encoding_offset)) {
a_out << "toolx::sg::text_freetype::update_sg :"
@@ -607,7 +524,6 @@ protected:
if(!bitmap_2_gl(a_out)) {m_bitmaps.clear();m_tqs.clear();return;}
} else {
update_what _what = lines;
//if(modeling==tools::sg::font_filled) _what = faces_and_lines;
if(modeling==tools::sg::font_filled) _what = faces;
if((_what==faces)||(_what==faces_and_lines)) outline_triangles_2_gl(a_out);
if((_what==lines)||(_what==faces_and_lines)) outline_lines_2_gl(a_out);
@@ -624,7 +540,7 @@ protected:
line_t& item = *it;
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos+1;
float* data = m_xys.data()+pos+1;
for(size_t i=0;i<npt;i++,data+=2) *data -= 0.5F * szy;
}}
@@ -632,7 +548,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = *it;
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos+1;
float* data = m_xys.data()+pos+1;
for(size_t i=0;i<npt;i++,data+=2) *data -= 0.5F * szy;
}}
@@ -651,7 +567,7 @@ protected:
line_t& item = *it;
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos+1;
float* data = m_xys.data()+pos+1;
for(size_t i=0;i<npt;i++,data+=2) *data -= szy;
}}
@@ -659,7 +575,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = *it;
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos+1;
float* data = m_xys.data()+pos+1;
for(size_t i=0;i<npt;i++,data+=2) *data -= szy;
}}
@@ -671,11 +587,6 @@ protected:
}
m_tqs.clear();
#ifdef TOOLX_DONE_FACE
::FT_Done_Face(m_face);
m_face = 0;
#endif
}
void outline_lines_2_gl(std::ostream& a_out) {
@@ -692,7 +603,7 @@ protected:
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_lines.size(); //for hjust.
tools_sforcit(line,it) {
for(auto it = line.cbegin(); it != line.cend(); ++it) {
if(!char_outline_2_gl(a_out,*it + m_encoding_offset)) return;
}
yline += -float(face_height)*m_scale; //height >0
@@ -704,7 +615,7 @@ protected:
line_t& item = m_lines[index];
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= 0.5F * sx;
}
} else if(hjust==tools::sg::right) {
@@ -713,7 +624,7 @@ protected:
line_t& item = m_lines[index];
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx;
}
}}
@@ -723,7 +634,6 @@ protected:
float yline = 0;
tools_vforcit(uniline,unitext.values(),vit) {
const uniline& line = *vit;
//a_out << line << std::endl;
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_lines.size(); //for hjust.
@@ -739,7 +649,7 @@ protected:
line_t& item = m_lines[index];
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= 0.5F*sx;
}
} else if(hjust==tools::sg::center) {
@@ -748,7 +658,7 @@ protected:
line_t& item = m_lines[index];
size_t pos = item.first;
size_t npt = item.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx;
}
}}
@@ -851,18 +761,14 @@ protected:
::gluTessProperty(m_tobj,(GLUenum)GLU_TESS_WINDING_RULE,GLU_TESS_WINDING_ODD);
//::gluTessProperty(m_tobj, GLU_TESS_TOLERANCE, 0);
//::gluTessNormal(m_tobj, 0.0f, 0.0f, -1.0f);
if(strings.values().size()) {
float yline = 0;
tools_vforcit(std::string,strings.values(),vit) {
const std::string& line = *vit;
//a_out << line << std::endl;
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_triangles.size(); //for hjust.
tools_sforcit(line,it) {
for(auto it = line.cbegin(); it != line.cend(); ++it) {
if(!char_triangles_2_gl(a_out,*it + m_encoding_offset)) {
::gluDeleteTess(m_tobj);
m_tobj = 0;
@@ -878,7 +784,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = m_triangles[index];
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx*0.5f;
}
} else if(hjust==tools::sg::right) {
@@ -887,7 +793,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = m_triangles[index];
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx;
}
}}
@@ -896,7 +802,6 @@ protected:
float yline = 0;
tools_vforcit(uniline,unitext.values(),vit) {
const uniline& line = *vit;
//a_out << line << std::endl;
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_triangles.size(); //for hjust.
@@ -916,7 +821,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = m_triangles[index];
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx*0.5f;
}
} else if(hjust==tools::sg::right) {
@@ -925,7 +830,7 @@ protected:
std::pair<GLUenum,triangle_t>& item = m_triangles[index];
size_t pos = item.second.first;
size_t npt = item.second.second;
float* data = tools::vec_data<float>(m_xys)+pos;
float* data = m_xys.data()+pos;
for(size_t i=0;i<npt;i++,data+=2) *data -= sx;
}
}}
@@ -937,12 +842,6 @@ protected:
}
bool char_triangles_2_gl(std::ostream& a_out,unsigned int a_unichar) {
//if(m_verbose) {
// a_out << "toolx::sg::text_freetype::char_triangles_2_gl :"
// << " do " << a_unichar << "."
// << std::endl;
//}
FT_ULong charcode = a_unichar; //charcode is UTF-32.
FT_UInt glyph_index = ::FT_Get_Char_Index(m_face,charcode);
//NOTE : if not found -> glyph_index = 0 which is the "missing glyph".
@@ -1024,8 +923,6 @@ protected:
/// bitmap /////////////////////////////////////////////
////////////////////////////////////////////////////////
bool bitmap_2_gl(std::ostream& a_out) {
//if(!set_char_size(a_out,m_face,height.value(),m_scale)) return;
//::printf("debug : xxxxx %g\n",m_char_height);
FT_F26Dot6 wchar = (FT_F26Dot6)(m_char_height*64);
FT_F26Dot6 hchar = (FT_F26Dot6)(m_char_height*64);
FT_UInt hres = 72;
@@ -1042,16 +939,14 @@ protected:
m_scale = height.value()/float(hchar);
FT_Pos face_height = m_face->size->metrics.height; //FT_Pos (long)
//::printf("debug : face_height %lu\n",face_height);
if(strings.values().size()) {
float yline = 0;
tools_vforcit(std::string,strings.values(),vit) {
const std::string& line = *vit;
//a_out << line << std::endl;
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_tqs.size(); //for hjust.
tools_sforcit(line,it) {
for(auto it = line.cbegin(); it != line.cend(); ++it) {
if(!char_2_bitmap(a_out,*it + m_encoding_offset)) return false;
}
yline += -float(face_height)*m_scale; //height>0
@@ -1075,7 +970,6 @@ protected:
float yline = 0;
tools_vforcit(uniline,unitext.values(),vit) {
const uniline& line = *vit;
//a_out << line << std::endl;
m_trans_x = 0;
m_trans_y = yline;
size_t ibeg = m_tqs.size(); //for hjust.
@@ -1104,12 +998,6 @@ protected:
}
bool char_2_bitmap(std::ostream& a_out,unsigned int a_unichar) {
//if(m_verbose) {
// a_out << "toolx::sg::text_freetype::char_2_bitmap :"
// << " do " << a_unichar << "."
// << std::endl;
//}
FT_ULong charcode = a_unichar; //charcode is UTF-32.
FT_UInt glyph_index = ::FT_Get_Char_Index(m_face,charcode);
//NOTE : if not found -> glyph_index = 0 which is the "missing glyph".
@@ -1160,22 +1048,8 @@ protected:
return false;
}}
//typedef struct FT_Bitmap_ {
// int rows;
// int width;
// int pitch;
// unsigned char* buffer;
// short num_grays;
// char pixel_mode;
// char palette_mode;
// void* palette;
//} FT_Bitmap;
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
//::printf("debug : unichar %u : r %d w %d pitch %d : grays %d\n",
// a_unichar,bitmap->bitmap.rows,bitmap->bitmap.width,bitmap->bitmap.pitch,bitmap->bitmap.num_grays);
if( (bitmap->bitmap.pixel_mode!=ft_pixel_mode_mono) &&
(bitmap->bitmap.pixel_mode!=ft_pixel_mode_grays) ){
a_out << "toolx::sg::text_freetype::char_2_bitmap :"
@@ -1209,7 +1083,6 @@ protected:
if(bitmap->bitmap.pixel_mode==ft_pixel_mode_mono) {
a_out << "toolx::sg::text_freetype::char_2_bitmap : mode_mono : not yet handled." << std::endl;
//img_grays = 1;
img_h = bitmap->bitmap.rows;
//WARNING : bitmap->bitmap.pitch != int((bitmap->bitmap.width+7)/8) !!!
// OpenGL wants the below for cols.
@@ -1236,7 +1109,6 @@ protected:
img_w = bitmap->bitmap.width;
img_h = bitmap->bitmap.rows;
img_sz = img_w * img_h * img_bpp;
//img_grays = bitmap->bitmap.num_grays;
}
if(img_sz<=0) {
@@ -1274,19 +1146,13 @@ protected:
FT_BBox _bbox;
FT_Glyph_Get_CBox(glyph,ft_glyph_bbox_pixels,&_bbox);
//float _width = float(_bbox.xMax)-float(_bbox.xMin);
//float _height = float(_bbox.yMax)-float(_bbox.yMin);
//aAdvance = int(face->glyph->advance.x/64);
std::vector<tools::vec3f> vcs;
//::printf("debug : box : %d %d %d %d\n",_bbox.xMin,_bbox.xMax,_bbox.yMin,_bbox.yMax);
float scale = height.value()/m_char_height;
float x_min = float(_bbox.xMin)*scale+m_trans_x;
float x_max = float(_bbox.xMax)*scale+m_trans_x;
float y_min = float(_bbox.yMin)*scale+m_trans_y;
float y_max = float(_bbox.yMax)*scale+m_trans_y;
//::printf("debug : scale %g, trans %g %g\n",m_scale,m_trans_x,m_trans_y);
//::printf("debug : corners %g %g %g %g\n",x_min,x_max,y_min,y_max);
vcs.push_back(tools::vec3f(x_min,y_min,0));
vcs.push_back(tools::vec3f(x_max,y_min,0));
@@ -1303,33 +1169,6 @@ protected:
m_bitmaps.add(_node);
m_tqs.push_back(_node);
/*
if(bitmap->bitmap.pixel_mode==ft_pixel_mode_mono) {
if((aChar=='T')||(aChar=='a')||(aChar=='o')||(aChar=='L')) {
printf("bitmap for '%c' : w = %d h = %d cols %d : ptsize = %d\n",
aChar,a_raster.width,a_raster.rows,a_raster.cols,getPointSize());
for( int row = (a_raster.rows-1); row >=0; --row ) {
unsigned char* bline = (unsigned char*)a_raster.buffer + row * a_raster.cols;
int icol = 0;
int ibit = 0;
unsigned char byte = (unsigned char)bline[icol];
icol++;
for( int i= 0; i < a_raster.width; ++i ) {
unsigned char v = (byte & (1<<(7-ibit)));
printf("%c",(v?'x':' '));
ibit++;
if(ibit==8) {
ibit = 0;
byte = (unsigned char)bline[icol];
icol++;
}
}
printf("\n");
}
}
}*/
}
m_trans_x += float(m_face->glyph->advance.x)*m_scale;
@@ -1346,26 +1185,11 @@ protected:
text_freetype& self = *((text_freetype*)a_this);
self.m_mode = a_which;
self.m_pos = self.m_xys.size();
#ifdef TOOLX_SG_TEXT_FREETYPE_DEBUG
self.m_out << "toolx::sg::text_freetype::begin_cbk :"
<< " which " << a_which
<< " GL_TRIANGLE_STRIP " << GL_TRIANGLE_STRIP
<< " GL_TRIANGLE_FAN " << GL_TRIANGLE_FAN
<< " GL_TRIANGLES " << GL_TRIANGLES
<< std::endl;
#endif
}
static void GLUAPIENTRY vertex_cbk(void* a_vertex,void* a_this) {
text_freetype& self = *((text_freetype*)a_this);
double* vertex = (double*)a_vertex;
#ifdef TOOLX_SG_TEXT_FREETYPE_DEBUG
std::cout << "toolx::sg::text_freetype::vertex_cbk :"
<< " x " << vertex[0]
<< " y " << vertex[1]
<< " z " << vertex[2]
<< std::endl;
#endif
self.add_xy(float(vertex[0]),float(vertex[1]));
}
@@ -1390,10 +1214,6 @@ protected:
}
static void GLUAPIENTRY error_cbk(GLUenum,void*) {
//const GLubyte* estring = gluErrorString(aErrorCode);
//::fprintf(stderr, "Tessellation Error: %s\n", estring);
//SbTessContour* This = (SbTessContour*)aThis;
//This->setError(true);
}
////////////////////////////////////////////////////////
@@ -1410,11 +1230,6 @@ protected:
// the same magnitude (in [0,6400]).
text_freetype& self = *((text_freetype*)a_this);
//self.m_out << "toolx::sg::text_freetype::outline_move_to :"
// << " x " << a_to->x
// << " y " << a_to->y
// << std::endl;
float gx,gy;
self.set_g(gx,gy,float(a_to->x),float(a_to->y));
@@ -1442,12 +1257,6 @@ protected:
}
static int outline_line_to(const FT_Vector* a_to,void* a_this){
text_freetype& self = *((text_freetype*)a_this);
//self.m_out << "toolx::sg::text_freetype::outline_line_to :"
// << " x " << a_to->x
// << " y " << a_to->y
// << std::endl;
float gx,gy;
self.set_g(gx,gy,float(a_to->x),float(a_to->y));
@@ -1486,11 +1295,6 @@ protected:
// logic taken from OGLFT.
//OPTIMIZE :
//b = from - 2 * ctrl + to;
//c = -2 * from + 2 * ctrl;
//df = c * self.m_delta + b * self.m_delta2;
//df2 = 2 * b * self.m_delta2;
float bx = fromx - 2 * ctrlx + tox;
float by = fromy - 2 * ctrly + toy;
@@ -1529,7 +1333,6 @@ protected:
dfy += df2y;
}
//g = to;
self.set_g(gx,gy,tox,toy);
if(self.m_tobj) {
@@ -1554,15 +1357,6 @@ protected:
// it must be fast. We avoid vec3f manipulations.
//self.m_out << "toolx::sg::text_freetype::outline_cubic_to :"
// << " ctrl1 x " << a_ctrl1->x
// << " ctrl1 y " << a_ctrl1->y
// << " ctrl2 x " << a_ctrl2->x
// << " ctrl2 y " << a_ctrl2->y
// << " x " << a_to->x
// << " y " << a_to->y
// << std::endl;
float ctrl1x = float(a_ctrl1->x);
float ctrl1y = float(a_ctrl1->y);
@@ -1577,14 +1371,6 @@ protected:
// logic taken from OGLFT.
//OPTIMIZE :
//a = -from + 3 * ctrl1 - 3 * ctrl2 + to;
//b = 3 * from - 6 * ctrl1 + 3 * ctrl2;
//c = -3 * from + 3 * ctrl1;
//df = c * self.m_delta + b * self.m_delta2 + a * self.m_delta3;
//df2 = 2 * b * self.m_delta2 + 6 * a * self.m_delta3;
//df3 = 6 * a * self.m_delta3;
float ax = -fromx + 3 * ctrl1x - 3 * ctrl2x + tox;
float ay = -fromy + 3 * ctrl1y - 3 * ctrl2y + toy;
@@ -1768,7 +1554,7 @@ protected:
if(parent::find_font_with_finders(font.value(),file)) {
} else {
tools::find_with_env(a_out,s_TOOLS_FONT_PATH(),font.value(),file,false);
tools::file::find_with_env(a_out,s_TOOLS_FONT_PATH(),font.value(),file,false);
}
if(file.empty()) {
@@ -1806,8 +1592,6 @@ protected:
protected:
static int load_flags() {
return FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
//return FT_LOAD_DEFAULT;
//return FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
}
static bool set_char_size(std::ostream& a_out,FT_Face& a_face,float a_height,float& a_scale) {
@@ -1874,16 +1658,11 @@ protected:
unsigned short offset;
if(!encoding_offset(a_face,offset)) return false;
tools_sforcit(a_string,it) {
for(auto it = a_string.cbegin(); it != a_string.cend(); ++it) {
FT_ULong charcode = *it + offset; //charcode is UTF-32.
FT_UInt glyph_index = ::FT_Get_Char_Index(a_face,charcode);
//NOTE : if not found -> glyph_index = 0 which is the "missing glyph".
if((FT_Long)glyph_index>=a_face->num_glyphs) {
#ifdef TOOLX_SG_TEXT_FREETYPE_DEBUG
m_out << "toolx::sg::text_freetype::truncate :"
<< " FT_Get_Char_Index : failed for char : " << *it
<< std::endl;
#endif
a_sout.clear();
::FT_Done_Face(a_face);
a_face = 0;
@@ -1892,12 +1671,6 @@ protected:
{FT_Error error = ::FT_Load_Glyph(a_face,glyph_index,load_flags());
if(error) {
#ifdef TOOLX_SG_TEXT_FREETYPE_DEBUG
m_out << "toolx::sg::text_freetype::truncate :"
<< " for character " << *it
<< ",FT_Load_Glyph : error : " << serror(error)
<< std::endl;
#endif
a_sout.clear();
::FT_Done_Face(a_face);
a_face = 0;
@@ -1934,7 +1707,7 @@ protected:
const std::string& line = *vit;
float width = 0;
tools_sforcit(line,it) {
for(auto it = line.cbegin(); it != line.cend(); ++it) {
FT_ULong charcode = *it + offset; //charcode is UTF-32.
FT_UInt glyph_index = ::FT_Get_Char_Index(a_face,charcode);
//NOTE : if not found -> glyph_index = 0 which is the "missing glyph".
@@ -1951,12 +1724,11 @@ protected:
return false;
}}
//float cwidth = float(a_face->glyph->metrics.width)*scale;
float advance = float(a_face->glyph->advance.x)*scale;
width += advance;
}
xmx = tools::mx<float>(xmx,width);
xmx = tools::max_of<float>(xmx,width);
}
FT_Pos ascent = a_face->size->metrics.ascender; //FT_Pos (long)
@@ -2011,12 +1783,11 @@ protected:
return false;
}}
//float cwidth = float(a_face->glyph->metrics.width)*scale;
float advance = float(a_face->glyph->advance.x)*scale;
width += advance;
}
xmx = tools::mx<float>(xmx,width);
xmx = tools::max_of<float>(xmx,width);
}
FT_Pos ascent = a_face->size->metrics.ascender; //FT_Pos (long)
@@ -2057,10 +1828,6 @@ protected:
a_offset = 0;
//std::cout << "toolx::sg::text_freetype::encoding_offset :"
// << " num charmap " << a_face->num_charmaps << "."
// << std::endl;
// cooking to handle symbol.ttf and wingding.ttf :
FT_Int n = a_face->num_charmaps;
FT_Int i;
@@ -2069,15 +1836,8 @@ protected:
unsigned short platform = charmap->platform_id;
unsigned short encoding = charmap->encoding_id;
//std::cout << "toolx::sg::text_freetype::encoding_offset :"
// << " for charmap " << i
// << ", platform " << platform
// << ", encoding " << encoding << "."
// << std::endl;
if ( (platform == 3 && encoding == 1 ) ||
(platform == 3 && encoding == 0 ) ||
//(platform == 1 && encoding == 0 ) ||
(platform == 0 && encoding == 0 ) ) {
FT_Error error = FT_Set_Charmap(a_face,charmap);
if(error) {
@@ -2088,19 +1848,12 @@ protected:
}
// For symbol.ttf and wingding.ttf
if (platform == 3 && encoding == 0 ) a_offset = 0xF000;
//if (platform == 1 && encoding == 0 ) a_offset = 0xF000;
return true;
} else {
//SoDebugError::post("SbTextTTF2Face::loadFont",
// "for \"%s\", platform %d and encoding %d not taken into account",
// filename,platform,encoding);
}
}
//a_out << "toolx::sg::text_freetype::update_sg :"
// << " This font doesn't contain any Unicode mapping table."
// << std::endl;
::FT_Done_Face(a_face);
a_face = 0;
a_offset = 0;
@@ -51,7 +51,7 @@ public:
size_t pos = item.first;
size_t num = item.second;
if(!num) continue;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
a_action.draw_vertex_array_xy(tools::gl::line_strip(),num*2,data);
}}
@@ -67,7 +67,7 @@ public:
// << " num points " << num
// << std::endl;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
a_action.draw_vertex_array_xy((*it).first,num*2,data);
}}
@@ -75,18 +75,7 @@ public:
/// bitmap ////////////////////////////////////////////////
///////////////////////////////////////////////////////////
if(m_bitmaps.size()) {
#if defined(ANDROID) /*|| TARGET_OS_IPHONE*/
// we do not have transparent texture here (see also gl/tex_img() that does img/4-bytes => img/3-bytes) :
{tools::sg::state& _state = a_action.state();
tools::colorf old_color = _state.m_color;
_state.m_color = tools::colorf_white();
a_action.color4f(_state.m_color);
m_bitmaps.render(a_action);
_state.m_color = old_color;
a_action.color4f(_state.m_color);}
#else
m_bitmaps.render(a_action);
#endif
}
///////////////////////////////////////////////////////////
@@ -129,7 +118,7 @@ public:
size_t num = item.second;
if(!num) continue;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
float* vp = _trans2(num,data,x,y);
if(!vp) continue;
@@ -152,7 +141,7 @@ public:
size_t num = item.second.second;
if(!num) continue;
const float* data = tools::vec_data<float>(m_xys)+pos;
const float* data = m_xys.data()+pos;
float* vp = _trans2(num,data,x,y);
if(!vp) continue;
if(a_action.add__primitive_xy(*this,item.first,2*num,vp,true)){
@@ -183,46 +172,6 @@ public:
reset_touched();
}}
a_action.add_one_point(0,0,0);
/*
{tools_vforcit(line_t,m_lines,it) {
const line_t& item = *it;
size_t num = item.second;
const float* data = tools::vec_data<float>(m_xys)+item.first;
float px,py,pz;
float* pos = (float*)data;
for(size_t index=0;index<num;index++) {
px = *pos;pos++;
py = *pos;pos++;
pz = 0;
a_action.add_one_point(px,py,pz);
}
}}
///////////////////////////////////////////////////////////
/// triangles /////////////////////////////////////////////
///////////////////////////////////////////////////////////
{tools_vforcit(gl_triangle_t,m_triangles,it) {
const std::pair<GLUenum,triangle_t>& item = *it;
size_t num = item.second.second;
const float* data = tools::vec_data<float>(m_xys)+item.second.first;
float px,py,pz;
float* pos = (float*)data;
for(size_t index=0;index<num;index++) {
px = *pos;pos++;
py = *pos;pos++;
pz = 0;
a_action.add_one_point(px,py,pz);
}
}}
///////////////////////////////////////////////////////////
/// bitmap ////////////////////////////////////////////////
///////////////////////////////////////////////////////////
m_bitmaps.bbox(a_action);
*/
}
public:
@@ -239,8 +188,6 @@ protected:
float sy = 2.0f*float(height.value())/float(a_state.m_wh); //in [-1,1]
float old_height = height.value();
height.value_no_cmp(sy);
//update_what what = lines;
//if(modeling==tools::sg::font_filled) what = faces_and_lines;
parent::update_sg(a_out,a_load_font);
height.value_no_cmp(old_height);
}
+4 -86
View File
@@ -6,6 +6,7 @@
#include <tools/xml/tree>
#include <tools/file>
#include <tools/fileis>
#include <tools/mnmx>
#include <cstdio>
@@ -13,32 +14,10 @@
#include <expat.h>
#ifdef TOOLS_MEM
#include <tools/mem>
namespace toolx {
extern "C" {
inline void* xml_malloc(size_t a_size){
tools::mem::increment(tools::s_malloc().c_str());
return ::malloc(a_size);
}
inline void* xml_realloc(void* a_ptr,size_t a_size){
if(a_ptr==NULL) tools::mem::increment(tools::s_malloc().c_str());
return ::realloc(a_ptr,a_size);
}
inline void xml_free(void* a_ptr){
if(a_ptr!=NULL) tools::mem::decrement(tools::s_malloc().c_str());
::free(a_ptr);
}
}}
#endif
namespace toolx {
namespace xml {
class loader {
#ifdef TOOLS_MEM
TOOLS_SCLASS(toolx::xml::loader)
#endif
public:
loader(tools::xml::factory& a_factory,
std::ostream& a_out,bool a_verbose = false)
@@ -54,17 +33,11 @@ public:
,m_depth(0)
,m_abort(false)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~loader(){
delete m_compressed_reader;
clear();
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
protected:
@@ -81,9 +54,6 @@ protected:
,m_depth(0)
,m_abort(false)
{
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
loader& operator=(const loader& a_from){
if(&a_from==this) return *this;
@@ -188,25 +158,16 @@ protected:
m_depth = 0;
m_abort = false;
#ifdef TOOLS_MEM
XML_Memory_Handling_Suite mem;
mem.malloc_fcn = xml_malloc;
mem.realloc_fcn = xml_realloc;
mem.free_fcn = xml_free;
XML_Parser _parser = XML_ParserCreate_MM(NULL,&mem,NULL);
#else
XML_Parser _parser = XML_ParserCreate(NULL);
#endif
XML_SetUserData(_parser,a_tag);
XML_SetElementHandler(_parser,a_start,a_end);
XML_SetCharacterDataHandler(_parser,(XML_CharacterDataHandler)character_data_handler);
//XML_SetProcessingInstructionHandler(_parser,processingInstructionHandler);
char* buf = (char*)aBuffer;
size_t l = aSize;
int done = 0;
do {
size_t len = tools::mn<size_t>(l,BUFSIZ); //BUFSIZ in cstdio
size_t len = tools::min_of<size_t>(l,BUFSIZ); //BUFSIZ in cstdio
done = len < BUFSIZ ? 1 : 0;
if(XML_Parse(_parser, buf, (int)len, done)==XML_STATUS_ERROR) {
m_out << "parse_buffer :"
@@ -215,8 +176,8 @@ protected:
<< " at byte index " << (int)XML_GetCurrentByteIndex(_parser)
<< std::endl;
{XML_Index pos = XML_GetCurrentByteIndex(_parser);
XML_Index pmn = tools::mx<XML_Index>(pos-10,0);
XML_Index pmx = tools::mn<XML_Index>(pos+10,XML_Index(aSize)-1);
XML_Index pmn = tools::max_of<XML_Index>(pos-10,0);
XML_Index pmx = tools::min_of<XML_Index>(pos+10,XML_Index(aSize)-1);
std::string c = " ";
{for(XML_Index p=pmn;p<=pmx;p++) {c[0] = *(aBuffer+p);m_out << c;}
m_out << std::endl;}
@@ -290,24 +251,11 @@ protected:
m_depth = 0;
m_abort = false;
#ifdef TOOLS_MEM
XML_Memory_Handling_Suite mem;
mem.malloc_fcn = xml_malloc;
mem.realloc_fcn = xml_realloc;
mem.free_fcn = xml_free;
XML_Parser _parser = XML_ParserCreate_MM(NULL,&mem,NULL);
#else
XML_Parser _parser = XML_ParserCreate(NULL);
#endif
XML_SetUserData(_parser,a_tag);
XML_SetElementHandler(_parser,a_start,a_end);
XML_SetCharacterDataHandler(_parser,(XML_CharacterDataHandler)character_data_handler);
//XML_SetProcessingInstructionHandler(_parser,
// processingInstructionHandler);
//char buf[1024 * BUFSIZ];
char buf[BUFSIZ];
int done = 0;
do {
@@ -415,20 +363,8 @@ protected:
return;
}
//out << "start_element :" << std::endl;
//_tree->print_xml(*(This->m_printer),"debug : ");
if(parent) parent->add_child(_tree);
/*
if(This->m_current && !This->m_current->parent()) {
This->m_out << "start_element :"
<< " warning : current tree without parent."
<< " Potential mem leak."
<< std::endl;
}
*/
This->m_current = _tree;
_tree->set_depth(This->m_depth); // Internal only.
@@ -499,14 +435,6 @@ protected:
bool cont = This->visit_end_element(*tr,keep);
if(keep) {
if(parent) {
/*
if(!This->m_current->parent()) {
This->m_out << "end_element :"
<< " warning : current tree without parent (1)."
<< " Potential mem leak."
<< std::endl;
}
*/
This->m_current = parent;
}
} else {
@@ -519,15 +447,6 @@ protected:
delete tr;
}
/*
if(!This->m_current->parent()) {
This->m_out << "end_element :"
<< " warning : current tree without parent (2)."
<< " Potential mem leak."
<< std::endl;
}
*/
This->m_current = parent; //parent could be 0 : ok.
}
@@ -537,7 +456,6 @@ protected:
//FIXME : correct m_value ? (Can we pick the one of a sub item ?)
tr->add_element(std::string(a_name),This->m_atbs,This->m_value);
//This->m_value = "";
} else {
-17
View File
@@ -52,9 +52,6 @@ inline bool compress_buffer(std::ostream& a_out,
deflateEnd(&stream);
//a_out << "toolx::compress_buffer : ok "
// << stream.total_out << std::endl;
a_irep = (unsigned)stream.total_out;
return true;
@@ -94,9 +91,6 @@ inline bool decompress_buffer(std::ostream& a_out,
inflateEnd(&stream);
//a_out << "toolx::decompress_buffer : zlib : ok "
// << stream.total_out << std::endl;
a_irep = (unsigned)stream.total_out;
return true;
@@ -129,17 +123,6 @@ inline int gunzip_check_header(char*& a_buffer) {
/* Check the gzip magic header */
for (len = 0; len < 2; len++) {
c = gunzip_get_byte(a_buffer);
/*
if (c != gz_magic[len]) {
if (len != 0) s->stream.avail_in++, s->stream.next_in--;
if (c != EOF) {
s->stream.avail_in++, s->stream.next_in--;
s->transparent = 1;
}
s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
return;
}
*/
}
int method = gunzip_get_byte(a_buffer);
int flags = gunzip_get_byte(a_buffer);