我是Android上OpenGL-ES的新手,请原谅我的愚蠢问题.我正在为Android v2.2 - SDK#8构建这个程序.我的平板电脑最多支持Android v3.1
我正在尝试通过developer.android.com上的教程为Android设置OpenGL-ES环境.程序编译得很好,它应该在设备上显示一个简单的蓝屏.但是,当我尝试在我的Android设备上运行它时,我得到了"IllegalStateException:已经为此实例调用了setRenderer"错误.
以下是我的代码:
public class TA_SpaceActivity extends Activity
{
private MyGLSurfaceView myGLView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
myGLView = new MyGLSurfaceView(this); //NOTE: this is where the app crashed
setContentView(myGLView);
}
}
class MyGLSurfaceView extends GLSurfaceView
{
public MyGLSurfaceView(Context context)
{
super(context);
setRenderer (new MyRenderer());
setEGLContextClientVersion(2);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
}
class MyRenderer implements GLSurfaceView.Renderer
{
public void onSurfaceCreated(GL10 unsued, EGLConfig config)
{
GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}
public void onDrawFrame(GL10 unused)
{
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
}
public void …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Xcode 5(Mac OSX 10.8.4)上为我的OpenGL项目设置GLFW3.我已成功安装并将我的项目链接到GLFW3没问题.我甚至用项目成功创建了一个窗口,我能够通过窗口检测鼠标和键盘输入,所以我相信我已正确连接GLFW3(或者至少看起来如此).
但是,当我尝试绘制对象时出现问题.这是出现错误的代码片段:
#include <GLFW/glfw3.h>
void LoadObject()
{
glGenVertexArrays(1, &VAO_myObj); // ERROR : Use of undeclared identifier 'glGenVertexArrays'
glBindVertexArray(VAO_myObj); // ERROR : Use of undeclared identifier 'glBindVertexArray'
glGenBuffers(1, &VBO_myObj); // No error
glBindBuffer(GL_ARRAY_BUFFER, VBO_myObj); // No error
glBufferData(blah blah blah); // No error
glEnableVertexAttribArray(0); // No error
glVertexAttribPointer(blah); // No error
glBindBuffer(GL_ARRAY_BUFFER, 0); // No error
glBindVertexArray(0); // ERROR : Use of undeclared identifier 'glBindVertexArray'
}
Run Code Online (Sandbox Code Playgroud)
所以,这让我相信GLFW3无法以某种方式链接到那些函数(?).当我向Xcode键入"glGen ..."时,我只在弹出窗口中看到以下4个函数:
void glGenBuffers(GLsizei n, GLuint * buffers)
GLuint glGenLists(GLsizei range)
void …
Run Code Online (Sandbox Code Playgroud) 这是我第一次向App Store提交应用程序,请耐心等待.我正在使用iOS 6.0.
我已经设法进入最后一步,我需要验证并将我的应用程序提交给Apple进行评估,以便将其放到AppStore上.但是,在最后,它在验证期间给了我这个错误消息:
所以,我检查了Info.plist文件,以确保我已经包含了应用程序的所有必要图标.我确实拥有它们.
这是我的info.plist:
在"图标文件","图标文件"和"图标文件(iOS 5)"下,我确实提供了默认的57x57图标,iPad图标和iPhone图标.它们存在于项目文件的同一目录中.
我在这里错过了什么?(我尝试添加名为"CFBundleIcons/File/Files"的条目,但没有添加此类条目).
在我遵循rmaddy的建议之后,下面是我更新的info.plist:
现在所有图标文件都已使用正确的尺寸正确更新("摘要"选项卡上的图像上没有警告黄色三角形).为什么我仍然收到同样的错误消息?还有什么我想念的?
对不起,如果我问这样一个基本问题.我整个上午都试图谷歌,并阅读developer.android.com上的文档,但我找不到解决方案.
简而言之,我想创建一个如下所示的界面:
这是我到目前为止:
现在,我正在尝试将2个按钮带到下一行,但我仍然没有运气.如果我将android:orientation ="horizontal"更改为"vertical",则所有内容都垂直对齐.我试图在Button标签中加入android:orientation ="vertical"行,但这似乎不起作用.
我还能尝试什么?有人会给我一些指示吗?(我是Android开发的新手,也是所有这些XML的东西).
下面是我的XML代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<EditText android:id="@+id/txt_Input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/txt_Input"
android:layout_weight="4"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_Send"
android:layout_weight="1"
android:onClick="sendMessage"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_Send"
android:layout_weight="1"
android:onClick="sendMessage"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我是黄瓜和水豚的菜鸟,所以请耐心等待.
我正在尝试设置一个使用chrome和firefox作为测试平台的黄瓜项目.到目前为止,我已经通过测试来处理chrome,但不是在firefox上.
以下是代码段:
require 'uri'
require 'net/http'
require 'fileutils'
require 'selenium-webdriver'
require File.dirname(__FILE__) + '/throttle.rb'
#CAPYBARA
require 'capybara/cucumber'
require 'capybara/session'
#require 'capybara-webkit'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.register_driver :selenium_firefox do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
driver = case ENV['BROWSER']
when 'chrome'
:chrome
when 'firefox'
:selenium_firefox
when 'webkit'
:webkit
when 'ie'
:internet_explorer
else
:chrome
end
Capybara.default_driver = driver
Capybara.javascript_driver = :selenium_firefox
Capybara.run_server = false
Capybara.default_selector = :css
Run Code Online (Sandbox Code Playgroud)
然后,为了测试,我只是简单地访问了(" http://www.google.com ").
如果我将浏览器参数设置为chrome,则可以正常工作.黄瓜打开了chrome并自动输入"www.google.com",并且页面加载没有问题.
但是,我把它设置为firefox的那一刻:$ cucumber features/test.feature BROWSER = …
自昨晚以来,我一直坚持这一点,对于我的生活,我一直无法弄清楚为什么会这样.我必须错过一些非常简单的事情.
我正在制作一个OpenGL程序.在这个程序中,我正在制作一个DialogBox类.以下是代码:
//---------------------------------------------------------------
//DialogBox.h
//---------------------------------------------------------------
#include <vector>
class DialogBox
{
private:
float X; float Y; float Z;
float Width;
float Height;
float RED;
float GREEN;
float BLUE;
float ALPHA;
int currentLine;
int maxLines; //How many lines of text this dialog box can hold
int maxChars; //How many chars each line of text can hold
std::vector< std::vector<char> >Text; //Text contents of the Dialog Box
unsigned int vertexArray_DialogBox;
unsigned int vertexBuffer_DialogBox;
public:
DialogBox();
DialogBox(float width, float height);
void draw();
void draw(float x, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个向量传递给glDrawElements()的最后一个参数.如果我使用数组,它工作正常.但是,当我切换到矢量时,它只渲染了一部分对象.
这工作得很好:
//TA_CartesianSys.h
class TA_CartesianSys
{
private:
int drawOrder[86];
//the rest of the class
}
//---------------------------------
//TA_CartesianSys.cpp
TA_CartesianSys::TA_CartesianSys()
{
GLfloat CartesianVertices[] = { ... };
int tempOrder[] = { ... };
for(int i = 0; i < sizeof(tempOrder) / sizeof(int); i++)
{
drawOrder[i] = tempOrder[i];
}
//Code to generate and bind vertex array and buffer
glDrawElements(GL_LINES, sizeof(drawOrder)/sizeof(int), GL_UNSIGNED_INT, drawOrder);
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作,这就是它的样子:
现在,我决定使用vector而不是array来进行drawOrder [].这是新代码:
//TA_CartesianSys.h
class TA_CartesianSys
{
private:
std::vector<int> drawOrder; //***NOTE: This is the change
//the rest of the class …
Run Code Online (Sandbox Code Playgroud)