小编use*_*150的帖子

OpenGL多矩阵变换

我有模型的简单顶点着色器

#version 330

layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec3 VertexNormal;
layout(location = 2) in vec2 VertexUV;

out VS_GS_VERTEX
{
    vec3 vs_worldpos;
    vec3 vs_normal;
    vec2 VertexUV;
} vertex_out;

uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
uniform mat4 lookAtMatrix;

void main(void)
{
    mat4 MVP = projectionMatrix * lookAtMatrix * modelMatrix;

    gl_Position = MVP * vec4(VertexPosition, 1.0);
    gl_Normal = mat3(modelMatrix) * VertexNormal;

    vertex_out.vs_worldpos = gl_Position.xyz;
    vertex_out.vs_normal = gl_Normal;
    vertex_out.VertexUV = VertexUV;
}
Run Code Online (Sandbox Code Playgroud)

我在那里传递了modelMatrix

  modelMat := MatrixMultiply(transMat, baseMat);
  modelMat := …
Run Code Online (Sandbox Code Playgroud)

delphi opengl matrix

9
推荐指数
1
解决办法
821
查看次数

SSPI和SQL Server Windows身份验证

我正在尝试使用Windows身份验证连接到SQL Server.可以在NetCpp上找到Microsoft C#和C源代码.

在Delphi中我有这样的代码:

function TTDS7SSPI.MakeSPN: string;
const
    szBracketedInstanceFormatString = '%s/[%s]:%s';
    szBracketedEmptyInstanceFormatString = '%s/[%s]%s';
    szClearInstanceFormatString = '%s/%s:%s';
    szClearEmptyInstanceFormatString = '%s/%s%s';
  szBracketedFormatString = '%s/[%s]:%d';
  szClearFormatString = '%s/%s:%d';
var
  NeedBrackets: Boolean;
  FmtString: string;
begin
  NeedBrackets := Pos(':', FHostName) > 0;
  if FInstanceName <> '' then begin
    // Make an instance name based SPN, i.e. MSSQLSvc/FQDN:instancename
    if NeedBrackets then begin
      if FInstanceName = '' then
        FmtString := szBracketedEmptyInstanceFormatString
      else
        FmtString := szBracketedInstanceFormatString;
    end
    else begin
      if FInstanceName = '' …
Run Code Online (Sandbox Code Playgroud)

sql-server delphi sspi

9
推荐指数
1
解决办法
682
查看次数

如何通过RTTI为TStringGrid.Cells之类的compex设置/获取属性值?

我有值存储在xml和lua代码中,并通过RTTI访问对象的属性.

var
  o, v: TValue; // o is current object
  a: TStringDynArray; // params as array
  ctx: TRttiContext;
  tt: TRttiType;
  p: TRttiProperty;
  pt: PTypeInfo;
begin
...
  ctx := TRttiContext.Create;
  try
    o := GetLastClassInParams(ctx, obj, a, param_idx);
    tt := ctx.GetType(o.TypeInfo);
    if high(a) < param_idx then
        raise Exception.Create(S_FN + S_NOP);
    p := tt.GetProperty(a[param_idx]);
    if p = nil then
        raise Exception.Create(S_FN + S_PNE + a[param_idx]);
    pt := p.PropertyType.Handle;
    case p.PropertyType.TypeKind of
      tkInteger: v := TValue.From<integer>(integer(Value));
      tkEnumeration: v := TValue.FromOrdinal(pt, GetEnumValue(pt, VarToStr(Value)));
      tkUString: v …
Run Code Online (Sandbox Code Playgroud)

delphi rtti

6
推荐指数
1
解决办法
7216
查看次数

如何在主线程中执行不基于TThread的线程?

例如,来自可执行文件或DLL中的CreateTimerQueueTimer回调提供的线程?具有与主线程相同的线程ID是很重要的.

procedure TMyMainClass.ExecuteMe(someparam: paramtype);
begin
  {something}
end;
Run Code Online (Sandbox Code Playgroud)

procedure TimerCallback(pvContext: pointer; fTimerOrWaitFired: boolean); stdcall;
begin
  {do what ?}
end;
Run Code Online (Sandbox Code Playgroud)

Final update:
所有这些东西(TThread.Synchronize,TThread.Queue,PostThreadMessage等)的作品通过消息.因此,请确保dll在等待回调时主机应用处理消息.

delphi

5
推荐指数
1
解决办法
2611
查看次数

在TDictionary中使用"class of"?

想法很简单 - 将带有类名的TDictionary用于TComponent

for enum in vm.ClassNameToComponent do
 TLuaClassTemplate<enum.Value>.RegisterClass(vm.LS, PrintGlobal, container, vm);
Run Code Online (Sandbox Code Playgroud)

用enum而不是

TLuaClassTemplate<TButton>.RegisterClass(vm.LS, PrintGlobal, container, vm);
TLuaClassTemplate<TPanel>.RegisterClass(vm.LS, PrintGlobal, container, vm);
TLuaClassTemplate<TEdit>.RegisterClass(vm.LS, PrintGlobal, container, vm);
...
Run Code Online (Sandbox Code Playgroud)

并使用从xml中获取的类名来处理基于泛型的类.
但是有问题:

TClassNameToComponentDict = TDictionary<string, TComponent>;
...
ClassNameToComponent: TClassNameToComponentDict;
...
  ClassNameToComponent := TClassNameToComponentDict.Create;
  ClassNameToComponent.Add('TButton', TButton);
  ClassNameToComponent.Add('TPanel', TPanel);
  ClassNameToComponent.Add('TEdit', TEdit);
...
Run Code Online (Sandbox Code Playgroud)

错误"不兼容的类型'TComponent'和'类TButton'".
如何使用TButton等"类"作为通用值?

delphi

4
推荐指数
1
解决办法
152
查看次数

这是C#SqlDecimal算术错误吗?

我正在尝试实现SQL Server Vardecimal解压缩.值每10位存储为3位十进制数.但在实施过程中,我发现数学的奇怪行为.这是我做的简单测试

private SqlDecimal Test() {

  SqlDecimal mantissa = 0;
  SqlDecimal sign = -1;
  byte exponent = 0x20;
  int numDigits = 0;

  // -999999999999999999999999999999999.99999

  for (int i = 0; i < 13; i++) {

    int temp = 999;

    //equal to mantissa = mantissa * 1000 + temp;
    numDigits += 3;
    int pwr = exponent - (numDigits - 1);
    mantissa += temp * (SqlDecimal)Math.Pow(10, pwr);
  }

  return sign * mantissa;
}
Run Code Online (Sandbox Code Playgroud)

前两次传球很好,我有

999000000000000000000000000000000
999999000000000000000000000000000
Run Code Online (Sandbox Code Playgroud)

但第三个

999999998999999999999980020000000
Run Code Online (Sandbox Code Playgroud)

这是C#SqlDecimal数学中的一些错误还是我做错了什么?

c#

4
推荐指数
1
解决办法
217
查看次数

如何将通用记录作为参数传递给TFileStream.Read函数?

例如,我有几种要从​​文件读取的记录类型

  PDescriptorBlockHeader = ^TDescriptorBlockHeader;
  TDescriptorBlockHeader = packed record

    BlockType: UInt32;
    BlockAttributes: UInt32; // +4
    OffsetToFirstEvent: UInt16; // +8
    OsId: byte; // +10
    OsVersion: byte;
    DisplayableSize: UInt64;  // +12
    FormatLogicalAddress: UInt64; // +20
    SessionId: UInt64; // +28
    ControlBlockID: UInt32; // +36
    StringStorage: MTF_TAPE_ADDRESS; // +40
    OsSpecificData: MTF_TAPE_ADDRESS; // +44
    StringType: byte; // +48
    Reserved: byte; // +49
    HeaderChecksum: UInt16; //+50
  end;
Run Code Online (Sandbox Code Playgroud)

我想使用通用功能从文件中读取

type
  TReaderHelper = class
    class procedure ReadToStruct<T:record>(stream: TFileStream; offset: Int64);
  end;

implementation

class procedure TReaderHelper.ReadToStruct<T>(stream: TFileStream; offset: Int64);
var …
Run Code Online (Sandbox Code Playgroud)

delphi

3
推荐指数
2
解决办法
92
查看次数

FastMM 64位"块头已损坏"

最新的FastMM4 4.991,XE2,试图解决内存泄漏问题,并在FullDebugMode + LogErrorsToFile设置下出现此错误.错误

The current thread ID is 0x7C4, and the stack trace (return addresses) leading to this error is:
41B914 [FastMM4][CheckFreeBlockUnmodified$qqrrp29Fastmm4.TFullDebugBlockHeaderui23Fastmm4.TBlockOperation]
41B996 [FastMM4][DebugGetMem$qqri]
41BD1F [FastMM4][DebugReallocMem$qqrrpvi]
40615D [System.pas][System][@ReallocMem$qqrrpvi][3524]
40CF62 [System.pas][System][@UStrSetLength$qqrr20System.UnicodeStringi][24163]
40D057 [System.pas][System][@UStrCat$qqrr20System.UnicodeStringrx20System.UnicodeString][24290]
8127D6 [LogHandler.pas][LogHandler][AddCustomLog$qqruiuii][160]
...
Run Code Online (Sandbox Code Playgroud)

代码非常简单,并且在几个项目中使用而没有任何错误

procedure AddCustomLog(p1, p2: NativeUInt; MsgType: integer);
const
  MSG_LEN = 200;
var
  ErrorString: array [0 .. MSG_LEN] of Char;
  i: integer;
  temp: string;
  descr: UTF8String;
  b: byte;
  pb: PByte;
begin
  case MsgType of
    ...
    BUFFER_LOG: begin
        temp := 'len = ' + IntToStr(p2) + …
Run Code Online (Sandbox Code Playgroud)

delphi fastmm

2
推荐指数
1
解决办法
652
查看次数

如何检查Variant是否已设置varByRef标志?

建议用来VarIsClear检查Variant是Null,Empty还是Unassigned.但是Unassigned如果设置了varByRef标志,我发现函数可以在调试器中返回False变量.VarIsClear检查

function VarIsClear(const V: Variant): Boolean;
var
  LHandler: TCustomVariantType;
  LVarData: TVarData;
begin
  LVarData := FindVarData(V)^;
  with LVarData do
    if VType < CFirstUserType then
      Result := (VType = varEmpty) or
                (((VType = varDispatch) or (VType = varUnknown)) and
                  (VDispatch = nil))
    else if FindCustomVariantType(VType, LHandler) then
      Result := LHandler.IsClear(LVarData)
    else
      Result := False;
end;
Run Code Online (Sandbox Code Playgroud)

在我的情况下,VType是16384($ 4000 = varByRef).如何检查Null,Empty或Unassigned是否正确?

delphi

2
推荐指数
1
解决办法
4983
查看次数

如何在iOS / Android中获取语言环境ID

我需要获取Windows返回的语言环境ID:

GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, PChar(locale), 256)
Run Code Online (Sandbox Code Playgroud)

适用于iOS和Android。我需要用于SQL Server排序规则信息(LCID)。

delphi android ios

2
推荐指数
1
解决办法
663
查看次数

为什么德尔福"为"这样做?

Delphi XE2,简单代码:

function FastSwap(Value: uint16): uint16; register; overload;
asm
  bswap eax
  shr eax, 16
end;
...
type
  PPicEleHdr = ^TPicEleHdr;

  TPicEleHdr = packed record
    zero, size, count: word;
  end;
var
  count: integer;
  buf: TBytes;
begin
...
  peh := @buf[offs];
  count := integer(FastSwap(peh.count));
  for i := 0 to count - 1 do begin
Run Code Online (Sandbox Code Playgroud)

在这里,for我在CPU窗口中看到

UnitExtract.pas.279: for i := 0 to count - 1 do begin
0051E459 8B45DC           mov eax,[ebp-$24]
0051E45C 48               dec eax
0051E45D 85C0             test eax,eax
0051E45F 0F82CD000000 …
Run Code Online (Sandbox Code Playgroud)

delphi

1
推荐指数
2
解决办法
211
查看次数

GLSL如何使用几何着色器显示法线?

我有 vertex shader

#version 330 core

layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 VertexUV;
layout(location = 2) in vec3 VertexNormal;

out VS_GS_VERTEX
{
    vec2 UV;
    vec3 vs_worldpos;
    vec3 vs_normal;
} vertex_out;

uniform mat4 proj_matrix;
uniform mat4 model_matrix;

void main(void)
{
    gl_Normal = VertexNormal;
    gl_Position = proj_matrix * vec4(VertexPosition, 1.0);

    vertex_out.UV = VertexUV; //VertexPosition.xy;
    vertex_out.vs_worldpos = gl_Position.xyz;
    vertex_out.vs_normal = mat3(model_matrix) * gl_Normal;
}
Run Code Online (Sandbox Code Playgroud)

fragment shader

#version 330 core

in GS_FS_VERTEX
{
    vec2 UV;
    vec3 vs_worldpos;
    vec3 …
Run Code Online (Sandbox Code Playgroud)

opengl glsl geometry-shader

1
推荐指数
1
解决办法
4747
查看次数

标签 统计

delphi ×10

opengl ×2

android ×1

c# ×1

fastmm ×1

geometry-shader ×1

glsl ×1

ios ×1

matrix ×1

rtti ×1

sql-server ×1

sspi ×1