我想boost::posix_time::ptime通过网络传输一个boost::int64_t.根据将boost :: posix_time :: ptime转换为__int64的方法,我可以轻松定义自己的纪元,并且仅time_duration将该参考纪元作为64位整数传输.但是如何转换回来ptime呢?
#include <iostream>
#include <cassert>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/greg_month.hpp>
using namespace std;
using boost::posix_time::ptime;
using boost::posix_time::time_duration;
using boost::gregorian::date;
int main(int argc, char ** argv){
ptime t = boost::posix_time::microsec_clock::local_time();
// convert to int64_t
ptime myEpoch(date(1970,boost::gregorian::Jan,1));
time_duration myTimeFromEpoch = t - myEpoch;
boost::int64_t myTimeAsInt = myTimeFromEpoch.ticks();
// convert back to ptime
ptime test = myEpoch + time_duration(myTimeAsInt);
assert(test == t);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为将time_durationtick计数作为参数的构造函数是私有的.我也对 …
我试图在Mac OSX上使用cmake我既安装了二进制版本,又安装了源代码.但是,在尝试创建Makefile时,我仍然会收到以下错误.
cpc1-dumb4-2-0-cust166:build bcrowhurst $ cmake.CMake错误:错误要求内部CMake变量未设置,cmake可能无法正确构建.
缺少的变量是:
CMAKE_On_COMPILER_ENV_VAR
CMake错误:错误要求内部CMake变量未设置,cmake可能无法正确构建.
缺少的变量是:
CMAKE_On_COMPILER
CMake Error: Could not find cmake module file:/Users/bcrowhurst/NetBeansProjects/appon/build/CMakeFiles/CMakeOnCompiler.cmake
CMake Error: Could not find cmake module file:CMakeOnInformation.cmake
CMake Error: CMAKE_On_COMPILER not set, after EnableLanguage
-- Boost version: 1.43.0
-- Found the following Boost libraries:
-- system
-- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)
我的CMakeLists.txt如下:
cmake_minimum_required( VERSION 2.6 )
project( Application On )
find_package( Boost COMPONENTS system REQUIRED )
link_directories( ${Boost_LIBRARY_DIRS} )
if(Boost_FOUND)
include_directories( ${Boost_INCLUDE_DIRS} )
add_library( object ../source/object.cpp ../source/object.h )
target_link_libraries( object …Run Code Online (Sandbox Code Playgroud) 我有一个简单的程序来使用深度测试.它没有按预期工作.程序绘制X,Y轴和原点附近的球体.如果我没有打开GL_DEPTH_TEST,则会在轴上绘制球体.如果我打开GL_DEPTH_TEST,轴将被绘制在我不期望的球体上.谁能告诉我我做错了什么?
void
glwid::initializeGL()
{
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
}
void
glwid::resizeGL(int width, int height)
{
glViewport( 0, 0, (GLint)width, (GLint)height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective ( 90, (GLint)width/ (GLint)height, 0.0, 200.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glEnable (GL_DEPTH_TEST);
}
void
glwid::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
gluLookAt (0, 0, 100, 0, 0, 0, 0, 1, 0);
//
// X axis
//
glBegin( GL_LINES );
qglColor( green );
glVertex3f (-100.0, 0, 0. );
glVertex3f (100.0, 0, 0. …Run Code Online (Sandbox Code Playgroud) 我试图显示"透明"表面(不是封闭的体积),正面和背面都是可见的(没有剔除).
例如,显示在两侧都应用透明度的圆锥或圆柱体.有一些可见的工件,表面的某些部分似乎没有正确处理alpha值.
似乎问题是当我(opengl)试图将alpha从表面的正面应用到表面的背面时.(当表面的内部/外部都可见时).
void init()
{
glMatrixMode(GL_PROJECTION);
gluPerspective( /* field of view in degree */ 40.0,
/* aspect ratio */ 1.0,
/* Z near */ 1.0, /* Z far */ 10.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */
0.0, 0.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.); /* up is in positive Y direction */
glTranslatef(0.0, 0.6, -1.0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
glLightfv(GL_LIGHT2, GL_DIFFUSE, …Run Code Online (Sandbox Code Playgroud)