为iPhone开发是我第一次使用Objective-c和第一次使用xcode深入体验.使用openGL将openGLES iPhone应用程序移植到OSX桌面有多难?我不是在询问用户界面 - 显然桌面上没有相当于cocoa touch UI的东西.我特别询问了app delegate和openGLES层.有任何重大障碍吗?它是否像在cocoa类型的项目中简单地创建一个新的app委托一样直截了当?
完全重复:使用正则表达式验证电子邮件地址
什么是有效的电子邮件地址字符和模式,以及如何编写与之匹配的正则表达式?
我目前有一些接近以下实现基于物理的游戏的FPS独立游戏循环的东西.它几乎可以在我测试的每台计算机上运行良好,在帧速率下降时保持游戏速度一致.然而,我将移植到嵌入式设备,这可能会更加困难的视频,我想知道它是否仍然会削减芥末.
编辑:
对于这个问题,假设msecs()返回程序运行的以毫秒为单位的时间.msecs的实现在不同平台上是不同的.此循环也在不同平台上以不同方式运行.
#define MSECS_PER_STEP 20
int stepCount, stepSize; // these are not globals in the real source
void loop() {
int i,j;
int iterations =0;
static int accumulator; // the accumulator holds extra msecs
static int lastMsec;
int deltatime = msec() - lastMsec;
lastMsec = msec();
// deltatime should be the time since the last call to loop
if (deltatime != 0) {
// iterations determines the number of steps which are needed
iterations = deltatime/MSECS_PER_STEP;
// save any …Run Code Online (Sandbox Code Playgroud) 我发现自己需要一个包含Lua的C项目中的哈希表容器.我想知道是否可以使用Lua中的哈希表作为通用容器.我看过ltable.h并且所有函数都需要一个Lua状态并且似乎与Lua环境相关联,所以我猜这是不切实际的,如果数据需要独立于Lua.
Win32应用程序如何只响应第一个WM_KEYDOWN通知?MSDN文档声明位30"指定先前的密钥状态.如果密钥在发送消息之前关闭,则值为1,如果密钥已启动则为零." 但在我的WndProc中,第30位始终为0.
case WM_KEYDOWN:
// ToDo - stop multiple notifications for repeating keys
printf("WM_KEYDOWN %i %i", wParam, lParam & 30);
return 0;
Run Code Online (Sandbox Code Playgroud)
请问lParam&30是错误的方式吗?我做错了什么吗?
我试图将一些表示图像库的xml转换为html表.(必须使用html而不是css). 如何</tr><tr>使用xsl每隔六个左右添加行中断?
我有这个:
<xsl:for-each select="//email/gallery" >
<td>
<img>
<xsl:attribute name="src">
<xsl:value-of select="gallery-image-location"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="gallery-image-alt"/>
</xsl:attribute>
</img>
</td>
<xsl:if test="????">
</tr>
<tr>
</xsl:if>
<xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
在Javascript中我会做类似的事情:
for (i=0; i<gallery.length; i++) {
htm += '<td><img src="' +
gallery[i].gallery-image-location +
'" alt="'+ gallery[i].gallery-image-alt +'"></td>';
if (i%6 == 5 && i != gallery.length-1) {
htm += '</tr><tr>';
}
}
Run Code Online (Sandbox Code Playgroud) 我有一行coldfusion代码,包括用utf-8字符集编码的cfm文件,并将其保存到变量中.我遇到的问题是没有办法在cfinclude中指定一个字符集,结果变量似乎没有正确读取utf-8所以任何非ascii字符都被错误地呈现.
<cfsavecontent variable="content">
<cfinclude template="test.cfm">
</cfsavecontent>
<cfoutput>#content#</cfoutput>
Run Code Online (Sandbox Code Playgroud)
如果我使用cffile这不是问题,因为我可以指定一个chaset,但是文件没有被解析为coldfusion变量.
<cfset path = expandPath(".") & "\test.html">
<cffile action="read" file="#path#" variable="content" charset="utf-8">
<cfoutput>#content#</cfoutput>
Run Code Online (Sandbox Code Playgroud)
所以我的问题 - 有没有办法将解析的coldfusion文件加载到变量中,同时尊重特定的字符集?
检测图形卡和编译的openGL二进制文件是否支持在运行时不是2的幂的纹理的最佳方法是什么?
这个问题的前言是,我意识到C宏是一个敏感的主题.很多时候,他们可以通过非宏观解决方案来实现,这种解决方案更安全,不受经典问题的影响,例如增加的参数; 所以,在这种情况下,我在C中有一个哈希表实现,其链接节点用于冲突.我相信大多数人已经看过这一百万次,但有点像这样.
typedef struct tnode_t {
char* key; void* value; struct tnode_t* next;
} tnode_t;
typedef struct table_t {
tnode_t** nodes;
unsigned long node_count;
unsigned long iterator; // see macro below
...
}
Run Code Online (Sandbox Code Playgroud)
我想提供一种迭代遍历节点的抽象方式.我考虑使用一个函数,它接受一个函数指针并将函数应用于每个节点,但我经常发现这种解决方案非常有限,所以我想出了这个宏:
#define tbleach(table, node) \
for(node=table->nodes[table->iterator=0];\
table->iterator<table->node_count;\
node=node?node->next:table->nodes[++table->iterator])\
if (node)
Run Code Online (Sandbox Code Playgroud)
哪个可以用作:
tnode_t* n;
tbleach(mytable, n) {
do_stuff_to(n->key, n->value);
}
Run Code Online (Sandbox Code Playgroud)
我能看到的唯一缺点是迭代器索引是表的一部分,所以显然你不能在同一个表中同时进行两个循环.我不知道如何解决这个问题,但我不认为这是一个交易破坏者,考虑到这个小宏将有多大用处.所以我的问题.
**更新**
我收集了Zack和Jens的建议,用"else"删除了问题,并在for语句中声明了迭代器.一切似乎都有效,但是visual studio抱怨使用宏时"不允许使用类型名称".我想知道这里到底发生了什么,因为它编译并运行但我不确定迭代器的作用域.
#define tbleach(table, node) \
for(node=table->nodes[0], unsigned long i=0;\
i<table->node_count;\
node=node?node->next:table->nodes[++i])\
if (!node) {} else
Run Code Online (Sandbox Code Playgroud)
这种做法是不好的形式,如果没有,有没有办法改善它?
说我有下表:
ID Author
---------------------
1 Bill
2 Joe
3 Bill and Joe
4 Bill
Run Code Online (Sandbox Code Playgroud)
我想要一个结果集来自:
SELECT id FROM table WHERE Author LIKE '%Bill%' OR Author = 'Bill'
Run Code Online (Sandbox Code Playgroud)
我如何订购它,以便与相等匹配的行是返回的第一行,之后是匹配的?例如,查询将返回1,4,3.我正在使用MySQL,但会在任何数据库中获取答案.
考虑以下示例(一个简单的2d向量lib).这里有一个构造函数,它返回一个带有方法的对象表.我对这种方法的问题是它正在为每个构造函数创建新表.有没有办法使用表的单个实例,但只更改_data字段,该字段标识方法正在处理的点?这是一种更好的方法吗?
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
const char* test =
"p1 = point(410, 680);"
"p2 = point(320, 120);"
"print('dot='..p1:dot(p2));"
"print('cross='..p1:cross(p2));";
typedef struct point_t {
lua_Number x, y;
} point_t;
point_t* p_new(lua_Number x, lua_Number y) {
point_t* p = malloc(sizeof(point_t));
p->x = x;
p->y = y;
return p;
}
void lua_settabledata(lua_State *L , char * key , void * value) {
lua_pushstring(L, key);
lua_pushlightuserdata(L, value);
lua_settable(L, -3);
}
void lua_settablefunction(lua_State *L, char * key …Run Code Online (Sandbox Code Playgroud)