我有一个使用OpenGL 3.2(+ libs)和FreeType2的程序.然后用Boost和OpenSSL编写另一个程序.OpenGL方面是为了确保文本可以呈现,而boost/openssl程序是为了安全登录/游戏服务器.
两个程序都可以通过他们的自我运作.
然而,将Boost和OpenSSL添加到游戏(GL + freetype)项目导致它无法链接.
我已经链接了以下的库以及包含文件夹的文件夹.
glimg.lib glutil.lib glfw.lib opengl32.lib freetype.lib glew32.lib user32.lib libeay32.lib ssleay32.lib
链接器错误是.
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__DeregisterEventSource@4
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA@36
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__RegisterEventSourceA@8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteDC@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetBitmapBits@12 …Run Code Online (Sandbox Code Playgroud) c++ linker-errors visual-studio-2010 unresolved-external linker-warning
以下面的C++为例.
vector<Animal> listAnimal;
class Fish : Animal ...
class Mammal : Animal ...
class Bird : Animal ...
Run Code Online (Sandbox Code Playgroud)
如果我然后将它们全部添加到列表中,然后从列表中任意抓取它们我不知道我正在处理哪个子类.我在Java中可以做getClass()或thefish instanceof Fish.我如何在C++中执行此操作?
我想要一个很好的渐变效果.但是在它真的很零碎的那一刻,你可以看到两个三角形之间的似乎.我有以下着色器vert和frag.我唯一能想到的就是换成预先生成的纹理.
对于两个三角形,数据被浮动为浮点数[xy] [RGB],我不认为C++源是值得展示的.
VERT #version 330
layout(location = 0) in vec2 position;
layout(location = 1) in vec3 incolor;
smooth out vec3 color;
void main()
{
color = incolor;
gl_Position = vec4(position.x,position.y,0.0,1.0);
}
Run Code Online (Sandbox Code Playgroud)
FRAG #version 330
smooth out vec4 outputColor;
smooth in vec3 color;
void main()
{
outputColor = vec4(vec3(color),1.0);
}
Run Code Online (Sandbox Code Playgroud)
结果

观察单个三角形显示了块状

我在facebook图表api上看了一下.facebook api用户对象
我看不出id 的最大长度是多少.因此,我可以将其存储在我的数据库中,以便在我的游戏中唯一识别用户,而无需注册或注册.
还是每个Facebook用户唯一的ID?- 一定是.
id来自JSON"https://graph.facebook.com/me?fields=id&access_token=fromiPhoneApp
我确信一切都是正确的.我最初使用来自非官方GLSDK的glload和glfw,但后来我决定取消glload,这意味着我必须使用glew才能获得现代标题.
#include <GL/glew.h>
#include <GL/glfw.h>
Run Code Online (Sandbox Code Playgroud)
我按照说明在glfw之前加入了glew.
在运行时,OpenGL窗口打开
//(relevant code)
if(!glewInit()) {return -1; }
if(!glfwInit()) {return -1; }
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// also tried glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
if(!glfwOpenWindow(1024, 768, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)){
glfwTerminate();
return -1;
}
glfwSetWindowTitle("OpenGL 3.2");
//init method
glGenVertexArrays(1, &vao); //<< Access violation here.
Run Code Online (Sandbox Code Playgroud)
任何想法我的问题在这里?
我看过了."使用VBO使用glew访问冲突"但它没有任何帮助.
我在将图像加载到Devil时遇到问题所以我提供了我如何构建lib以及我如何使用它的确切方法.
从他们的网站下载Devel来源.
$ unzip DevIL-1.7.8.zip
$ mkdir devil
$ cd Devil-1.7.8
+-------------------------------------------+
| Just type: |
| autoreconf -i |
| ./configure <your options here> |
| make |
| sudo make install |
+-------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
如果我使用autoreconf -i,那么./configure有前缀和ilu和ilut.我收到一个错误..forgot ..来记录它.这有多重要?我刚刚没用过它.
$ chmod +x configure
$ ./configure --prefix=/home/path/to/TestingDevil/devil --enable-ILU --enable-ILUT
$ make
$ make install
Run Code Online (Sandbox Code Playgroud)
所以在这一点上我应该建立我的图书馆.我将devil 简单示例(simple.c)下载到TestingDevil/simple/simple.c构建它.
$ gcc -I ../devil/include -L ../devil/lib/ simple.c -o simple -lIL -lILU -lILUT
$ cp ../devil/lib/*.so* .
Run Code Online (Sandbox Code Playgroud)
我添加了一个图像(jpg)进行测试.
$ LD_LIBRARY_PATH=. …Run Code Online (Sandbox Code Playgroud) 我在屏幕上显示文本时遇到一些问题,过去我刚刚使用基于精灵的文本,但这次我想使用UnicodeFont.TrueTypeFonts完全绘制,但不推荐使用.
当我尝试绘制UnicodeFont时,它似乎受到我使用的字符的影响.例如,如果我绘制字符串"stackoverflow"文本和框将绘制,如果我尝试"stackoverflowcom"框不会绘制.
我的源代码的准系统版本如下.在线~74我调用uniFont.drawString(0,0,"stackoverflow"); ,如果com(或任何真的)框将不会被绘制.
编辑.>您可以使用布尔tryUnicode在true和unicode之间进行交换.
我曾尝试将它们粘贴到单独的显示列表中,但它没有任何区别.
任何人都可以提供有关为什么会发生这种情况的见解吗?
谢谢
import java.awt.Font;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.UnicodeFont;
import org.newdawn.slick.font.effects.ColorEffect;
import static org.lwjgl.opengl.GL11.*;
public class Game {
private UnicodeFont uniFont;
private TrueTypeFont truFont;
public static void main(String[] argv) {
Game game = new Game();
game.start();
}
public void start()
{
initGL(600, 600);
initFonts();
while(!Display.isCloseRequested()) //display not closed
{
render();
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
private void render()
{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(-0.25f,0.7f,0);
glScalef(0.001f,-0.001f,0.001f); …Run Code Online (Sandbox Code Playgroud) 我有一个文本文件thetext.txt.这是在我的项目中,并在构建设置中复制.就像我的GL着色器和纹理一样(工作正常.)
NSError *errorReading;
NSArray *linesOfText = [[NSString stringWithContentsOfFile:@"thetext.txt"
encoding:NSUTF8StringEncoding
error:&errorReading]
componentsSeparatedByString:@"\n"];
NSLog(@"Reading error %@",errorReading);
Run Code Online (Sandbox Code Playgroud)
它将以下内容打印到控制台.
Reading error Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x896fff0 {NSFilePath=thetext.txt, NSUnderlyingError=0x896ff60 "The operation couldn’t be completed. No such file or directory"}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我按照这篇文章构建了 GluLookAt 类型矩阵。
Method calculateLookAtMatrix(glm::vec3 eye, glm::vec3 center, glm::vec3 up)
glm::vec3 zaxis = glm::normalize(center - eye);
glm::vec3 xaxis = glm::normalize(glm::cross(up, zaxis));
glm::vec3 yaxis = glm::cross(zaxis, xaxis);
lookAtMatrix[0][0] = xaxis.x;
lookAtMatrix[0][1] = yaxis.x;
lookAtMatrix[0][2] = zaxis.x;
lookAtMatrix[1][0] = xaxis.y;
lookAtMatrix[1][1] = yaxis.y;
lookAtMatrix[1][2] = zaxis.y;
lookAtMatrix[2][0] = xaxis.z;
lookAtMatrix[2][1] = yaxis.z;
lookAtMatrix[2][2] = zaxis.z;
lookAtMatrix[3][0] = glm::dot(xaxis, -eye);
lookAtMatrix[3][1] = glm::dot(yaxis, -eye);
lookAtMatrix[3][2] = glm::dot(zaxis, -eye);
lookAtMatrix[3][3] = 1;
Run Code Online (Sandbox Code Playgroud)
我计算那个 CPU 端并将它作为一个统一的方式传递给着色器,就像透视矩阵一样。
着色器看起来像这样。
gl_Position = lookAtMatrix * position …Run Code Online (Sandbox Code Playgroud) 我需要将整数值映射到某种可变数组中的对象.什么是最好的方法来解决这个问题.我看到的唯一选择是使用objectiveC++ ...
std::map<int, id> theMap; // if i can use id?
Run Code Online (Sandbox Code Playgroud)
或者将内注放入NSString或NSNumber用作钥匙NSMutableDictionary.
我在我的网络类中使用它,客户端将发送一些数据(密钥将在有效负载中).然后在读取时,将从数据包中提取密钥,然后将地图中的对象拉出以基于所接收的内容继续该程序.(我担心客户端无法接收有效负载或丢失有效负载.)
哪种方式最好/最快?
我尝试了不同的机器,打开和关闭VSync。
我提供了我的主要方法和显示方法。在主视图中,我使用GLFWs GetTime方法计算增量。
如果我明确设置deltaTime = 0.016来锁定目标速度,则三角形将平滑移动。
int main(int argc, char** argv)
{
/*
INIT AND OTHER STUFF SNIPPED OUT
*/
double currentFrame = glfwGetTime();
double lastFrame = currentFrame;
double deltaTime;
double a=0;
double speed = 0.6;
//Main loop
while(true)
{
a++;
currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
/** I know that delta time is around 0.016 at my framerate **/
//deltaTime = 0.016;
x = sin( a * deltaTime * speed ) * 0.8f;
y …Run Code Online (Sandbox Code Playgroud)