将字符串分配给Char指针错误 [英] Assigning String to Char pointer error

查看:142
本文介绍了将字符串分配给Char指针错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,即将使用stringify转换的字符串分配给字符指针。似乎字符指针(char * particleVS)只占用字符串的前256个字符。我在64位平台上工作。同样的代码也适用于32位平台。我无法弄清楚为什么只有256字符只被分配在64位平台的char指针变量中,任何人都可以请帮助..提前感谢。



代码如下:

  #define STRINGIFY(A)#A 

const char * particleVS = STRINGIFY(
uniform float pointRadius; // 世界空间中的磅值\ n
uniform float pointScale; // 缩放以计算大小(以像素为单位)\\ \\ n
制服vec4 eyePos; \ n
void main()\ n
{ \ n
vec4 wpos = vec4(gl_Vertex.xyz, 1 0 ); \ n
gl_Position = gl_ModelViewProjectionMatrix * wpos; \ n

// 计算窗口空间点大小\ n
vec4 eyeSpacePos = gl_ModelViewMatrix * wpos; \ n
float dist = length(eyeSpacePos.xyz); \ n
gl_PointSize = pointRadius *(pointScale / dist); \ n

gl_TexCoord [ 0 ] = gl_MultiTexCoord0; // sprite texcoord \ n
gl_TexCoord [ 1 ] = eyeSpacePos; \ n

gl_FrontColor = gl_Color; \ n
} \ n
);

解决方案

你试过W2A和A2W转换

I am stucked in a problem assigning a string, converted by using stringify, to a character pointer. It seemed that the character pointer(char * particleVS ) is taking only first 256 character of the string. My working in 64bit platform. Also the same code works fine for 32bit platform. I couldn''t figure out why only 256 character is only being assigned in a char pointer variable in 64 bit platform could anyone please help.. Thank in advance.

code is given below

#define STRINGIFY(A) #A

const char *particleVS = STRINGIFY(
uniform float pointRadius;  // point size in world space    \n
uniform float pointScale;   // scale to calculate size in pixels \n
uniform vec4 eyePos;                                        \n
void main()                                                 \n
{                                                           \n
	vec4 wpos = vec4(gl_Vertex.xyz, 1.0);                   \n
    gl_Position = gl_ModelViewProjectionMatrix * wpos;      \n

    // calculate window-space point size                    \n
    vec4 eyeSpacePos = gl_ModelViewMatrix * wpos;           \n
    float dist = length(eyeSpacePos.xyz);                   \n
    gl_PointSize = pointRadius * (pointScale / dist);       \n

    gl_TexCoord[0] = gl_MultiTexCoord0; // sprite texcoord  \n
    gl_TexCoord[1] = eyeSpacePos;                           \n

    gl_FrontColor = gl_Color;                               \n
}                                                           \n
);

解决方案

Have you tried with W2A & A2W convertion


这篇关于将字符串分配给Char指针错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆