我写了这段代码:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glut.h>
void init()
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,200.0,0.0,150.0);
}
void lineSegment()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
glBegin(GL_TRIANGLES);
glVertex2i(40,120);
glVertex2i(40,20);
glVertex2i(80,20);
glEnd();
glFlush();
}
int main()
{
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(50,100);
glutInitWindowSize(400,300);
glutCreateWindow("An Example OpenGL....");
init();
glutDisplayFunc(lineSegment);
glutMainLoop();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的错误.
funfullson@funfullson:~$ gcc gl.cpp
/tmp/cchfRGT2.o: In function `init()':
gl.cpp:(.text+0x2a): undefined reference to `glClearColor'
gl.cpp:(.text+0x36): undefined reference to `glMatrixMode'
gl.cpp:(.text+0x5a): undefined reference to `gluOrtho2D'
/tmp/cchfRGT2.o: In function `lineSegment()':
gl.cpp:(.text+0x6e): undefined reference to `glClear'
gl.cpp:(.text+0x8d): undefined reference …
Run Code Online (Sandbox Code Playgroud) (这个问题最初发布在python-tkinter邮件列表中)
TL; TR如何在Windows上从HWND设置Tkinter窗口的主设备?
我在Windows上使用嵌入式Python解释器中的Tkinter.有一个桌面Win32应用程序打开了一个主窗口.嵌入式Python运行一个脚本,用于创建和显示Tkinter窗口.
有没有办法根据HWND
Win32窗口分配Tkinter窗口的主(父)?
我想使Tkinter窗口成为主Win32应用程序窗口的完全模态窗口.
我知道winfo_*
API winfo_id()
允许我查询HWND
Tkinter窗口的Win32 ,但似乎没有类似的功能来设置父级HWND
(或非Windows操作系统上的ID).
我得到的一个有用的想法是创建一个小的Python扩展,可以从我的嵌入式Python中获得HWND
,使用Win32 覆盖Tkinter窗口的父级,使用暴露的自定义函数SetParent
.
这是一个想法的伪代码:
PyObject * mywin32_set_parent(PyObject *self, PyObject *args)
{
/* unpack Tkinter HWND from args */
HWND hTkinterWindow = ... ;
/* returns main application window */
HWND hAppWindow = GetMyAppWindow();
/* make the main window parent of the Tkinter */
::SetParent(hTkinterWindow, hAppWindow)
Py_INCREF(Py_None);
return Py_None;
}
Run Code Online (Sandbox Code Playgroud)
然后在嵌入式Python执行的Python脚本代码中:
import mywin32
root = Tk()
hwnd = …
Run Code Online (Sandbox Code Playgroud) 更新:感谢Dan Guzman,问题已经解决了.我犯了一个错误并使用了旧的遗产,Driver={SQL Server};
假设它是新的驱动程序.相反,我应该使用Driver={ODBC Driver 11 for SQL Server}
哪个是实际的新ODBC驱动程序.我可以使用新驱动程序连接到(Localdb)\ v11.0.
TL; TR:为什么我不能使用new in连接字符串连接到(Localdb)\ v11.0Driver={SQL Server};
,但是如果我将驱动程序切换到旧的话,我可以连接Driver={SQL Server Native Client 11.0};
?
我使用的其余连接字符串参数是(如果在C++代码中使用,则反斜杠转义):
Server=(localdb)\v11.0;Integrated Security=True;
Run Code Online (Sandbox Code Playgroud)
我正在尝试通过ODBC访问SQL Server并SQLDriverConnect
使用无DSN连接字符串进行调用.如果我将驱动程序切换到SQL Server Native Client 11.0,那么我突然可以连接.
我还测试过生成FILEDSN %systemdrive%\Windows\System32\odbcad32.exe
,我观察到完全相同的问题.
我可以与新连接的唯一本地数据库Driver={SQL Server}
是Server=DEVBOX\SQLEXPRESS
(如果在C++代码中使用,则反斜杠转义,当然).
我找不到任何确认新的SQL Server ODBC驱动程序不支持LocalDB.
它仅在SQL Server for Linux的ODBC驱动程序的常见问题中指出
SQL Server 2012的哪些功能支持此版本的驱动程序?Linux上的ODBC驱动程序支持SQL Server 2012中除LocalDB之外的所有服务器功能.
如何使用Windows上的新ODBC驱动程序连接到LocalDB?
更新:我正在使用Windows 10 Pro + VS2015.我可以连接到两者,(localdb)\v11.0
并DEVBOX\SQLEXPRESS
使用SQL Server Management …
PVS-Studio,静态代码分析器,用于以下代码
size_t const n = 4;
int a[n] = {};
Run Code Online (Sandbox Code Playgroud)
报告:
V112使用的危险幻数
4
:...t const n = 4;. test.cpp 3
尽管PVS-Studio与Visual Studio 2017项目一起使用并报告32位和64位的相同警告,但分析器AFAIU不会考虑这些构建配置.
我本来期望更好地分析上下文并将上面的代码视为等同于此
int a[4] = {};
Run Code Online (Sandbox Code Playgroud)
PVS-Studio不会发出任何诊断信息.
在上面这种情况下使用了这个危险的幻数N,是假阳性?
上面两个代码示例没有被分析为等价的原因是什么?
我无法使用Windows Mobile(基于Windows CE)操作系统编译移动设备的C++项目,Visual Studio中的Visual C++编译器失败:
Error 1 fatal error C1083: Cannot open include file: 'io.h'
Run Code Online (Sandbox Code Playgroud)
编辑
我正在尝试编译SQLite合并,shell.c文件包含对此io.h的调用,但文件中缺少io.h.
我用谷歌搜索,我找不到如何得到这个.h文件.
有人能指出我正确的方向吗?
我正在用 C++ 编写 Python 3 扩展,并且正在尝试找到一种方法来检查 a 是否PyObject
与定义其实例布局的类型(结构)相关。我只对 static-size 感兴趣PyObject
,而不是PyVarObject
. 实例布局由具有某些明确定义的布局的结构体定义:强制PyObject
标头和(可选)用户定义的成员。
下面是基于定义新类型中PyObject
著名的 Noddy 示例的扩展示例:
// Noddy struct specifies PyObject instance layout
struct Noddy {
PyObject_HEAD
int number;
};
// type object corresponding to Noddy instance layout
PyTypeObject NoddyType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"noddy.Noddy", /*tp_name*/
sizeof(Noddy), /*tp_basicsize*/
0, /*tp_itemsize*/
...
Noddy_new, /* tp_new */
};
Run Code Online (Sandbox Code Playgroud)
值得注意的是,它Noddy
是一种类型、一个编译时实体,但NoddyType
它是运行时存在于内存中的一个对象。Noddy
和之间唯一明显的关系NoddyType
似乎是sizeof(Noddy)
存储在tp_basicsize
成员中的值。
在 …
尝试使用Boost :: GIL PNG IO支持编译我的文件时,我总是遇到此错误:
(我正在运行Mac OS X Leopard和Boost 1.42,LibPNG 1.4)
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::init()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:155: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:160: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In destructor 'boost::gil::detail::png_reader::~png_reader()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:174: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:186: error: 'int_p_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader_color_convert<CC>::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:228: error: 'int_p_NULL' was not declared in this scope …
Run Code Online (Sandbox Code Playgroud) TL;TR 寻找习语和模式,根据简单的规范(例如名称列表)将位置参数和关键字参数解压缩为位置参数的有序序列。这个想法看起来类似于类似 scanf 的解析。
我正在包装一个名为 的 Python 模块的函数someapi
。的函数someapi
只需要位置参数,在大多数情况下这是痛苦的数字。我想让调用者能够灵活地向我的包装器传递参数。以下是我想要允许的包装器调用的示例:
# foo calls someapi.foo()
foo(1, 2, 3, 4)
foo(1, 2, 3, 4, 5) # but forward only 1st 4 to someapi.foo
foo([1, 2, 3, 4])
foo([1, 2, 3, 4, 5, 6]) # but forward only 1st 4 to someapi.foo
foo({'x':1, 'y':2, 'z':3, 'r':4})
foo(x=1, y=2, z=3, r=4)
foo(a=0, b=0, x=1, y=2, z=3, r=4) # but forward only x,y,z,r someapi.foo
Run Code Online (Sandbox Code Playgroud)
我认为没有必要支持混合位置和关键字参数的复杂情况:
foo(3, 4, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用boost通用图像库将CYMK图像转换为RGB.
以下代码无法编译
// read cmyk image file
cmyk8_image_t img;
jpeg_read_image( "1502-T2-C-PER.jpg", img );
// convert to rgb
rgb8_image_t rgb( img.dimensions() );
copy_pixels(
color_converted_view<rgb8_image_t>(view(img)),
view(rgb));
Run Code Online (Sandbox Code Playgroud)
有人知道怎么修这个东西吗?
我已将此代码基于教程代码
void x_luminosity_gradient(const rgb32fc_view_t& src, const gray8s_view_t& dst) {
gray8_image_t ccv_image(src.dimensions());
copy_pixels(color_converted_view<gray8_pixel_t>(src), view(ccv_image));
Run Code Online (Sandbox Code Playgroud)
这是编译器输出:
1>c:\program files\boost\boost_1_35_0\boost\gil\step_iterator.hpp(164) : error C2664: 'boost::gil::detail::step_iterator_adaptor<Derived,Iterator,SFn>::step_iterator_adaptor(const Iterator &,SFn)' : cannot convert parameter 1 from 'const boost::gil::dereference_iterator_adaptor<Iterator,DFn>' to 'const boost::gil::rgb8_ptr_t &'
1> with
1> [
1> Derived=boost::gil::memory_based_step_iterator<boost::gil::rgb8_ptr_t>,
1> Iterator=boost::gil::rgb8_ptr_t ,
1> SFn=boost::gil::memunit_step_fn<boost::gil::rgb8_ptr_t >
1> ]
1> and
1> [
1> Iterator=boost::gil::cmyk8_ptr_t , …
Run Code Online (Sandbox Code Playgroud) 我正在使用GDAL API来读取光栅文件......我在某些地方发现python版本有ReadAsArray,我假设这会将光栅文件的数据作为二维数组,C#是否有类似的选项,或者至少可以你告诉我该怎么做?非常感谢!
我一直在寻找我的在线纸牌游戏(PostgreSQL,Oracle等)的不同数据库库,虽然SOCI + pg或Oracle功能更强大,但它们编译,集成和执行的工作也很复杂.我需要去做.
很简单,这些是我的要求:存储用户名,哈希,赢,输,电子邮件.非常简单.
游戏本身实际上不会经常与数据库通信.当玩家登录时,我将通过用户名检索行来记录它们,并使用他们输入的密码生成的哈希来验证哈希.
除此之外,服务器仅访问数据库以添加用户,在玩回合后记录赢或输,或更新个人信息.
鉴于SQLite支持有限的并发性,即使我同时运行100个左右的纸牌游戏,这对我的需求也应该没问题.
反思上述情况,SQLite是否适合我,还是我应该认真考虑选择更复杂的解决方案?请记住,数据库不是我最强的观点.
谢谢
我是 ruby on Rails 的新手。我正在查看它的文档,它说“约定优于配置”。这是什么意思?
c++ ×4
python ×3
boost-gil ×2
python-3.x ×2
api ×1
arguments ×1
boost ×1
build ×1
c ×1
c# ×1
database ×1
gdal ×1
geospatial ×1
graphics ×1
idioms ×1
include ×1
libpng ×1
localdb ×1
macos ×1
odbc ×1
opengl ×1
pvs-studio ×1
pyobject ×1
ruby ×1
soci ×1
sql-server ×1
sqlite ×1
tkinter ×1
winapi ×1