我最近从32位环境迁移到64位环境,除了一个问题之外它已经顺利完成了:glMultiDrawElements使用一些在64位操作系统下没有一些调整就无法工作的阵列.
glMultiDrawElements( GL_LINE_LOOP, fCount_, GL_UNSIGNED_INT,
reinterpret_cast< const GLvoid** >( iOffset_ ),
mesh().faces().size() );
Run Code Online (Sandbox Code Playgroud)
我正在使用VBO来处理顶点和顶点索引. fCount_并且iOffset_是数组GLsizei.由于缓冲区是绑定到GL_ELEMENT_ARRAY_BUFFER,iOffset_的元件被用作从VBO开始字节偏移.这在32位操作系统下完美运行.
如果我改变glMultiDrawElements来glDrawElements并把它变成一个循环,它工作在两个平台上罚款:
int offset = 0;
for ( Sy_meshData::Faces::ConstIterator i = mesh().faces().constBegin();
i != mesh().faces().constEnd(); ++i ) {
glDrawElements( GL_LINE_LOOP, i->vertexIndices.size(), GL_UNSIGNED_INT,
reinterpret_cast< const GLvoid* >( sizeof( GLsizei ) * offset ) );
offset += i->vertexIndices.size();
}
Run Code Online (Sandbox Code Playgroud)
我认为我所看到的是OpenGL读取64位块iOffset_导致大量数字,但glMultiDrawElements不支持任何类型超过32位(GL_UNSIGNED_INT),所以我不知道如何纠正它.
有没有其他人有这种情况并解决了它?或者我处理这个完全错误并且在32位操作系统上运气真的很幸运?
换掉我现有的代码:
typedef void ( *testPtr …Run Code Online (Sandbox Code Playgroud) 我无法编译(非常人为的)C++ 范围示例:
#include <ranges>
#include <fstream>
#include <vector>
template <typename R>
auto populate(R&& range)
{
return std::vector<char>(range.begin(), range.end());
}
int main(int argc, char* argv[]) {
auto stream = std::ifstream{"/etc/hosts"};
const auto is_odd = [](auto i) { return (i % 2) == 1; };
const auto hosts_data = populate(
std::ranges::subrange{std::istreambuf_iterator<char>{stream},
std::istreambuf_iterator<char>{}} |
std::views::filter(is_odd)
);
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
结果是:
<source>:19:35: required from here
<source>:9:17: error: no matching function for call to 'std::vector<char>::vector(std::ranges::filter_view<std::ranges::subrange<std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ranges::subrange_kind::unsized>, main(int, char**)::<lambda(auto:13)> …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在QML中实现拖动创建机制,但我遇到了一个问题,我需要新创建MouseArea的鼠标事件的目标,即使原始MouseArea没有鼠标按钮释放事件呢.
Window {
id: window
width: 300
height: 300
Rectangle {
id: base
width: 20
height: 20
color: "red"
MouseArea {
anchors.fill: parent
property var lastPoint
property var draggedObj: null
function vecLength( vec ) {
return Math.abs( Math.sqrt( Math.pow( vec.x, 2 ) +
Math.pow( vec.y, 2 ) ) );
}
onPressed: lastPoint = Qt.point( mouse.x, mouse.y )
onPositionChanged: {
if ( !draggedObj ) {
var diff = Qt.point( mouse.x - lastPoint.x,
mouse.y - lastPoint.y …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的方法,它的const重载.
Sy_animatable::PropertyTimeLine&
Sy_animatable_imp::getPropertyTimeLine( const QString& property )
{
if ( !properties_.contains( property ) ) {
throw Sy_unknownAnimPropertyException( property );
}
return properties_[property];
}
const Sy_animatable::PropertyTimeLine&
Sy_animatable_imp::getPropertyTimeLine( const QString& property ) const
{
if ( !properties_.contains( property ) ) {
throw Sy_unknownAnimPropertyException( property );
}
return properties_[property]; // "warning: returning reference to temporary"
}
Run Code Online (Sandbox Code Playgroud)
我不明白这个警告有两个原因:
properties_是一个成员变量,它的下标操作符(它是a QMap)返回一个引用,因此不应该有任何临时值,并且它在对象的生命周期内是持久的.我可以#pragma用线来隐藏警告,但我真的想知道为什么它会给我警告 - 任何建议?
我尝试从CentOS7.0的源代码安装Amarok 2.8音乐播放器。
阅读自述文件后,我知道需要Qt4.7(或更高版本)。然后我安装了QT5.3(路径是?/ QT)。
遵循Amarok安装说明https://community.kde.org/Amarok/Development/Compiling ,
cmake .. -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`
Run Code Online (Sandbox Code Playgroud)
然而,
CMake Error at /usr/share/cmake/Modules/FindQt4.cmake:1368 (message):
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
Run Code Online (Sandbox Code Playgroud)
我认为有办法告诉cmake在哪里可以找到QT。
希望有人能解决这个问题。非常感谢。
我认为这是不可能的,但我用我的软件看到它.我已经构建了一个包装器对象来管理我的缓冲区对象(我正在使用共享上下文,所以我不能使用VAO),并且VBO方面的工作正常,直到我开始用IBO测试它(glDrawElements(),我' m使用纯OpenGL 3+环境).
以下是向我的对象添加缓冲区的代码(Sy_GLObject):
QList< uint > Sy_GLObject::addBuffers( uint numBuffers, GLenum target,
GLenum numericType, GLenum usage )
{
uint* adds = new uint[numBuffers];
glGenBuffers( numBuffers, adds );
QList< uint > l;
for ( uint i = 0; i < numBuffers; ++i ) {
Buffer buffer( target, adds[i], 0, numericType, usage );
buffers_ << buffer;
l << i;
}
delete[] adds;
Sy_GL::checkError();
return l;
}
Run Code Online (Sandbox Code Playgroud)
并且此函数返回的缓冲区名称很好,直到此代码调用它:
void Sy_BVH::initialiseGLObject()
{
Sy_application::getMainWindow()->getActiveProject(
)->getModelContext()->makeCurrent();
GLuint vLoc = Sy_settings::get( "shader/flat/vertexLoc" ).toUInt();
drawBBs_ = Sy_GLObject::createObject();
// …Run Code Online (Sandbox Code Playgroud) 我正在使用GCC v4.6获得一个-Wunused-set-variable警告,代码如下:
for ( auto i : f.vertexIndices ) {
Sy_MatrixFuzzyHashable< Vector3f > wrapper( cp );
if ( !vMapper.contains( wrapper ) ) {
mesh.vertexNormals() << cp;
i.normal = mesh.vertexNormals().size() - 1;
} else {
i.normal = vMapper.value( wrapper );
}
}
Run Code Online (Sandbox Code Playgroud)
警告具体是:
warning: variable 'i' set but not used [-Wunused-but-set-variable]
Run Code Online (Sandbox Code Playgroud)
警告将使意义,如果i是一个元素的副本,但由于vertexIndices是一个QList对象(符合STL-QT容器类)的范围为基础的循环应该调用begin()和end()迭代器干将,这将始终返回一个非const迭代器(只要容器是非const的 - 就是它).
我目前无法测试它是否正常工作,因为我正在改变我的代码库以利用新的C++ 11功能,所以没有任何编译.但是我希望有人可以告诉我这个警告是否是无意义的,或者我是否误解了自动和基于范围的循环...
对不起我令人毛骨悚然的英语。在 Qt 4.8.4 中,我尝试使用静态 QString 字段创建单例类。它不能是 const,因为这个字段会在运行时改变值。通过常量 QString 初始化此字段,在同一文件中声明。
不幸的是,这是行不通的,并且在初始化字符串中
LogWay = QString("file.txt");
Run Code Online (Sandbox Code Playgroud)
程序意外以错误结束
下级停止了,因为它收到了来自操作系统的信号。信号名称:SIGSEGV 信号含义:分段错误
在文件“qatomic_i386.h”中
我做错了什么?此代码示例适用于 int、bool 或 double 变量,但不适用于 QString。为什么?我尝试在没有 QString 构造函数的情况下编写,使用简单的等式
LogWay = "...";
Run Code Online (Sandbox Code Playgroud)
但我有同样的错误。感谢您的帮助。
类的完整代码:
这是 .h 文件 #include
const double _ACCURACY_ = 0.0001;
static const QString _LOG_WAY_ = "GrafPrinterLog.txt";
class GlobalSet
{
private:
static QSettings *_Settings;
GlobalSet(){}
GlobalSet(const GlobalSet&){}
GlobalSet &operator=(const GlobalSet&);
static GlobalSet *GS;
public:
static double IntToCut;
static double ReplaceSize;
static double Accuracy;
static int MaxPointCount;
static bool NeedProper;
static QString LogWay; …Run Code Online (Sandbox Code Playgroud) 我已经成功地使用 FFmpeg 加载压缩音频文件并使用我编写的一些代码查询它们的 channel_layouts:
AVFormatContext* fmtCxt = nullptr;
avformat_open_input( &fmtCxt, "###/440_sine.wav", nullptr, nullptr );
avformat_find_stream_info( fmtCxt, nullptr );
av_find_best_stream( fmtCxt, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0 );
AVCodecContext* codecCxt = fmtCxt->streams[ret]->codec;
AVCodec* codec = avcodec_find_decoder( codecCxt->codec_id );
avcodec_open2( codecCxt, codec, nullptr );
std::cout << "Channel Layout: " << codecCxt->channel_layout << std::endl;
av_dump_format( fmtCxt, 0, "###/440_sine.wav", 0 );
Run Code Online (Sandbox Code Playgroud)
为简洁起见,我删除了所有错误检查。但是,对于 Microsoft WAV 文件(单声道或立体声),AVCodecContext::channel_layout成员始终为 0 - 尽管ffprobe并且av_dump_format(..)两者都返回有效信息:
Input #0, wav, from '###/440_sine.wav':
Duration: 00:00:00.01, bitrate: 740 kb/s
Stream …Run Code Online (Sandbox Code Playgroud)