草庐IT

GL_UNSIGNED_BYTE

全部标签

c++ - -Wconversion warning while using operator <<= on unsigned char

当我用gcc编译以下代码时:intmain(){unsignedcharc=1;c我收到这个警告:conversionto‘unsignedchar’from‘int’mayalteritsvalue[-Wconversion]为什么?这段代码有什么问题?其实,我真的可以使用oprator吗?在unsignedchar上变量?编译命令:g++test.cpp-Wconversion-otest.exe 最佳答案 这是一个有效的警告:c相当于:c=c和的规则假设操作数被提升,在这种情况下将提升为int结果是提升的类型。所以会有一个从i

c++ - 转换为无符号时,标准表示结果为 "the least unsigned integer"。为什么 "least"在这里很重要?

C++标准在[conv.integral/2]中说,关于整数转换为无符号:Ifthedestinationtypeisunsigned,theresultingvalueistheleastunsignedintegercongruenttothesourceinteger(modulo2nwherenisthenumberofbitsusedtorepresenttheunsignedtype).我的问题是,为什么会有“最少”这个词?有没有可能有多个结果,我们需要从中选择一个? 最佳答案 有无限多个整数等于任何值k模2n。有k,k

c++ - double 会在算术表达式中隐式转换为 unsigned int 吗?

在StanleyB.Lippman的C++Primer中,关于“隐式转换”的部分说:intival;unsignedintui;floatfval;fval=ui-ival*1.0;ivalisconvertedtodouble,thenmultipliedby1.0.Theresultisconvertedtounsignedint,thensubtractedbyui.Theresultisconvertedtofloat,thenassignedtofval.但我不这么认为:我认为实际上ival被转换为double然后乘以1.0然后ui是哪个是类型unsignedint转换为do

c++ - 如何在QT中实时更新GL()

我想知道以固定的计时器间隔调用updateGL()是否会减慢渲染过程。所以,我想尝试实时渲染。我没有让它自动执行的功能。有人知道吗?其次,我在我的程序中注释了updateGL(),CPU使用率降低到1%和0%。现在,当我点击显示小部件时,它会跳到14%,为什么?GPU不是在做所有的渲染工作吗?如果是,为什么CPU跳到14?我该如何解决这个问题? 最佳答案 是的,你可以做到实时,没有撕裂(例如,以恰好60fps的速度重新绘制,显示器的刷新率)。为此,您必须启用V_sync,并使用间隔为0的QTimer计时器;。启用V_sync将使自动

c# - 如何在 C++ CLR 中将数组 <System::Byte> 转换为 char*?

在我的项目中,我将一个byte[]从C#传递到C++CLR函数。C++CLR代码:voidTestByteArray(array^byteArray){...}C#代码:byte[]bytes=newbyte[128];...TestByteArray(bytes);在TestByteArray()函数中,我需要将byteArray转换为char*,以便我可以在nativeC++代码中使用它。我怎样才能进行这样的转换? 最佳答案 voidTestByteArray(array^byteArray){pin_ptrp=&byteArr

c++ - Qt creator 添加外部库(还是: Cannot open include file: 'GL/glew.h' )

我按照说明操作:在“项目”Pane中,打开项目文件(.pro)。在代码编辑器中右键单击以打开上下文菜单并选择“添加库...”。然后将以下行添加到pro文件中:win32:CONFIG(release,debug|release):LIBS+=-L$$PWD/D:/OpenGL/glew-1.5.4/lib/-lglew32else:win32:CONFIG(debug,debug|release):LIBS+=-L$$PWD/D:/OpenGL/glew-1.5.4/lib/-lglew32dINCLUDEPATH+=$$PWD/D:/OpenGL/glew-1.5.4/include

c++ - "points to uninitialised byte(s)"Valgrind 错误

我一直在使用Valgrind来查找我的代码中的内存泄漏,虽然没有发现内存泄漏,但报告了一些错误,所有这些错误都源于单个函数/类方法:==17043==ERRORSUMMARY:10100errorsfrom3contexts(suppressed:0from0)==17043====17043==100errorsincontext1of3:==17043==Syscallparamsocketcall.sendto(msg)pointstouninitialisedbyte(s)==17043==at0x5441DA2:send(send.c:28)==17043==by0x404C

c++ - unsigned long long 与 uint64_t 冲突?

这个问题在这里已经有了答案:longlongintvs.longintvs.int64_tinC++(3个答案)关闭7年前。我们对某些类型参数使用模板特化classmy_template_class:publicmy_template_class_base{....}classmy_template_class:publicmy_template_class_base{....}这与gcc的64位编译完美配合。而当我们尝试32位模式时,它会报告上述两个类的“先前定义”。所以unsignedlonglong在32位编译中与uint64_t相同,但在64位编译中则不同?编译区别是CXX标志

c++ - 我的 For 循环有什么问题?我收到警告 : comparison between signed and unsigned integer expressions [-Wsign-compare]

#include#include#include#includeusingnamespacestd;intmain(){vectorvector_double;vectorvector_string;...while(cin>>sample_string){...}for(inti=0;i 最佳答案 Whyisthereawarningwith-Wsign-compare?正如警告的名称及其文本所暗示的,问题在于您正在比较有符号整数和无符号整数。人们普遍认为这是一次意外。为了避免这个警告,你只需要确保的两个操作数(或任何其他比较运算

c++ - 使用连续无符号整数列表初始化 std::vector<unsigned int>

我想用一种特殊的方法来初始化一个std::vector这在我用作引用的C++书籍中有所描述(如果重要的话,UlrichBreymann的德语书籍'DerC++Programmer')。在那本书中有一个关于STL序列类型的部分,特别提到了list,vector和deque.在本节中,他写道,这种序列类型有两个特殊的构造函数,即如果X指的是这样一种类型,X(n,t)//createsasequencewithncopiesoftX(i,j)//createsasequencefromtheelementsoftheinterval[i,j)我想在unsignedint的间隔内使用第二个,即