试图让openframeworks构建我的应用程序,以便我可以从任何地方打开它,它将从应用程序资源文件夹中加载所需的图像.
我相信这是相对联系?
我以前在旧的xcode和oF 61上完成了它.
为此,我将所需的图像拖到左侧的项目文件中,并将其添加到可执行目标中,并在"构建阶段" - >"复制文件"中.
一直尝试各种方法,上次解决问题的SetDataPathRoot()这次不适合我.
任何想法/帮助将不胜感激!
谢谢
我正在学习Openframeworks并且发现这两个类经常用于表示有时候的向量,有时也用于表示点.使用其中一个的原因是什么?
我需要逐渐插入或改变一系列颜色,因此它从colorA到colorB再到colorC到colorD,然后再返回到colorA,这需要基于经过的时间(以毫秒为单位),任何帮助都将非常受欢迎(算法,伪代码会很棒).
请注意,我正在使用RGB,它可能是0-255或0.0-1.0范围.
这就是我到目前为止,我需要更改每个"timePeriod"的颜色,我们计算经过的时间百分比并更改颜色,这段代码的问题是当它从A到A时有一个跳转B到B到C等等
int millisNow = ofGetElapsedTimeMillis();
int millisSinceLastCheck = millisNow - lastTimeCheck;
if ( millisSinceLastCheck > timePeriod ) {
lastTimeCheck = millisNow;
millisSinceLastCheck = 0;
colorsIndex++;
if ( colorsIndex == colors.size()-1 ) colorsIndex = 0;
cout << "color indes: " << colorsIndex << endl;
cout << "color indes: " << colorsIndex + 1 << endl;
}
timeFraction = (float)(millisSinceLastCheck) / (float)(timePeriod);
float p = timeFraction;
colorT.r = colors[colorsIndex].r * p + ( colors[colorsIndex+1].r * ( 1.0 - p ) …Run Code Online (Sandbox Code Playgroud) 我之前搜索过但找不到任何答案.我对c ++有些新意,所以希望这个问题不会太愚蠢.
我试图在向量中添加和删除元素,在我的情况下,在大型更新期间填充粒子或在所有粒子上绘制循环.例如,移除一些粒子,因为它们已经死亡,但也添加了一些粒子,因为一个粒子与一个物体相撞,我想在碰撞点显示一个小粒子爆发.我在演示文件中制作了这个简单的测试代码,以找到问题的根源.
我认为问题是因为我删除并添加粒子,迭代器指针变得无效.删除工作,但当我添加一些随机的,我得到一个空指针.下面的代码有点冗长,我知道我应该使用带有begin()和end()的迭代器,但我遇到了同样的问题,并且稍微使用了代码,尝试更多的javascript数组样式循环因为我更熟悉那.
void testApp::drawParticles()
{
int i=0;
int max = particles.size();
vector<Particle*>::iterator it = particles.begin();
while ( i < max ) {
Particle * p = particles[i];
if ( ofRandom(1) > .9 ) {
it = particles.erase(it);
max = particles.size();
} else {
ofSetColor(255, 255, 0);
ofCircle( p->x, p->y, p->z, 10);
if ( ofRandom(1) < .1 ) addSomeNewOnes();
i++;
it++;
}
}
}
void testApp::addSomeNewOnes()
{
int max = ofRandom(4);
for ( int i=0; i<max; i++ ) { …Run Code Online (Sandbox Code Playgroud) 我想创建一个名为 Button 的通用类,其他人从中继承,例如,我可以拥有 StartButton、ContinueButton 等。无论我想从构造函数开始的不同属性如何,都有某些值,因为它们总是需要的所以我像这样构建了自己的按钮类:
#pragma once
#include "ofMain.h"
class Button {
public:
Button(ofPoint _pos, string _text);
virtual void setup();
virtual void update();
virtual void draw();
protected:
ofTrueTypeFont buttonName;
ofPoint pos;
string text, fontName;
bool isClicked;
int buttonFader, buttonFaderVel;
};
Run Code Online (Sandbox Code Playgroud)
这是 Button.cpp 的实现:
#include "Button.h"
Button::Button(float _pos, string _text): pos(_pos), text(_text){
cout << pos << endl;
cout << text << endl;
}
void Button::setup(){
fontSize = 19;
fontName = "fonts/GothamRnd-Medium.otf";
buttonName.loadFont(fontName, fontSize);
cout << text << endl;
}
void Button::update(){ …Run Code Online (Sandbox Code Playgroud) 我是一个openFrameworks新手.我正在学习基本的2D绘图,到目前为止一切都很棒.我画了一个圆圈使用:
ofSetColor(0x333333);
ofFill;
ofCircle(100,650,50);
Run Code Online (Sandbox Code Playgroud)
我的问题是如何给圆圈一个变量名,以便我可以用鼠标按下的方法操作?我试着在ofCircle之前添加一个名字
theball.ofSetColor(0x333333);
theball.ofFill;
theball.ofCircle(100,650,50);
Run Code Online (Sandbox Code Playgroud)
但得到我'theball'没有在此范围错误中声明.
我试图获得一个离轴投影效果,其中屏幕的内容根据用户的位置而变化.这与此视频中的内容类似:http:
//www.youtube.com/watch?feature = player_embedded&v = Jd3-eiid-Uw
我不确定为什么离轴投影是达到上述效果的合适方法.我在这里想到了两种方法:1)使用glFrustum,2)使用lookAt()
在上面的应用程序中,'camera'基本上按照用户的位置移动.所述glFrustum的坐标(left,right,bottom,top,near,far被给出了透视投影)来改变屏幕上的对象,因为它们会从不同的位置,当用户移动时出现.
与此同时,我发现这与使用用户位置翻译相机gluLookAt(centerPosition)并将相机送到lookAt中心非常相似.但我没有得到这个所需的效果,并想知道为什么会发生这种情况.

上面两个有什么区别?
在OpenGL中通过以下方式实现离轴投影:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(fNear*(-fFov * ratio + headX),
fNear*(fFov * ratio + headX),
fNear*(-fFov + headY),
fNear*(fFov + headY),
fNear, fFar);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(headX*headZ, headY*headZ, 0, headX*headZ, headY*headZ, -1, 0, 1, 0);
glTranslatef(0.0,0.0,headZ);
Run Code Online (Sandbox Code Playgroud)
上面的gluLookAt(...)有什么意义,而不是在我尝试使用相机而只是将它lookAt point作为屏幕的中心时?
我正在使用 openframeworks 创建一个项目(完整源代码在这里: https: //github.com/morphogencc/ofxAsio/tree/master/example-udpreceiver),并且空项目似乎编译得很好。
我添加了 ASIO 库和一些标头类,现在该项目似乎出现以下错误:
1>------ Build started: Project: example-udpreceiver, Configuration: Debug x64 ------
1> main.cpp
1>cl : Command line error D8049: cannot execute 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\c1xx.dll': command line is too long to fit in debug record
1>cl : Command line error D8040: error creating or communicating with child process
我在 stackoverflow 甚至 Microsoft 的页面上都找不到任何错误 D8049 的示例,而且 google 也没有找到任何结果。唯一有用的一个是这个 github 问题:
https://github.com/deplinenoise/tundra/issues/270
但我仍然不确定是什么原因导致了这个问题。有谁熟悉此错误,并且可以推荐一种方法来解决导致该错误的原因吗?
提前致谢!
c++ compiler-errors openframeworks visual-studio visual-studio-2015
我正在做一个包含 ASIO 的项目。我添加了库和头文件,但是当我有一个包含 的文件时asio.hpp,我收到以下错误:
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(229): warning C4005: 'ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition (compiling source file src\ofApp.cpp)
1> c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(215): note: see previous definition of 'ASIO_ERROR_CATEGORY_NOEXCEPT' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp) …Run Code Online (Sandbox Code Playgroud) 我在 Windows 上使用 openFrameworks,它使用 GLFW 和 GLEW,我在不同 GPU 品牌上的扩展可用性方面遇到问题。
基本上,如果我在 openGL 2 上运行我的程序,扩展是可用的。但是,如果我更改为 openGL 3.2 或更高版本,则所有扩展在 Nvida(在 * GTX1080 上测试)和 Intel (*UHD) 上都不可用,但在 AMD(*Vega Mobile GL/GH 和 RX 5700)上不可用。
这意味着无法使用 GL_ARB_texture_float,因此我的计算着色器无法按预期工作。
我正在使用 openGL 4.3,用于计算着色器支持和英特尔 GPU 支持。所有驱动程序都是最新的,所有 GPU 都支持 GL_ARB_texture_float。
此外,在 GLSL 上启用扩展没有任何作用。
这就是 openFrameworks 制作上下文的方式:
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, settings.glVersionMajor);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, settings.glVersionMinor);
if((settings.glVersionMajor==3 && settings.glVersionMinor>=2) || settings.glVersionMajor>=4)
{
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
}
if(settings.glVersionMajor>=3)
{
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
}
Run Code Online (Sandbox Code Playgroud)
不确定发生了什么,也不知道如何搜索这样的问题。欢迎任何指点!
openframeworks ×10
c++ ×8
opengl ×2
algorithm ×1
boost-asio ×1
colors ×1
glfw ×1
gpu ×1
inheritance ×1
namespaces ×1
polymorphism ×1
sequence ×1
textures ×1
vector ×1
xcode ×1