我是Android上的OpenGL的新手,我读过大量记录的样本,我有点理解.但在尝试做任何复杂的事情之前,我想在黑色的bacground上绘制一个简单的2D白色矩形.没有其他的.
我坚持这个错误:call to OpenGL ES API with no current context这似乎是我从非OpenGL调用的东西Thread.问题是我不确定从OpenGL调用什么Thread.所以这是我的代码
// ==============活动================== //
public class MainActivity extends Activity {
public static String TAG = MainActivity.class.getSimpleName();
MyGLSurfaceView surface;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
surface = new MyGLSurfaceView(this);
setContentView(surface);
}
@Override
protected void onPause() {
super.onPause();
surface.onPause();
}
@Override
protected void onResume() {
super.onResume();
surface.onResume();
}
}
Run Code Online (Sandbox Code Playgroud)
// ==================== GLSurfaceView ======================== //
public class MyGLSurfaceView extends GLSurfaceView {
MyGLSurfaceRenderer …Run Code Online (Sandbox Code Playgroud) 在Cinder中使用OpenGL会出现一个视觉故障,如果可能的话我想在WebGL中重现.
效果来自初始化具有大小的纹理,但没有任何数据.基本上它是在GPU上显示垃圾内存(最终是桌面的碎片变色图像等)
对我正在处理的特定WebGL显示非常有用的效果.
gl::Texture: 
在WebGL/js上下文中发生这种情况的任何线索?(如果它们在浏览器中产生效果,我完全愿意使用其他资源/框架)
我正在尝试实现阴影贴图技术,但在使其发挥作用时遇到一些问题。
我在灯光位置有一个相机,这是我得到的阴影贴图。所有顶点均已乘以每个modelViewProjectionMatrix。

我还有一个带有顶点世界位置的纹理。它是一个GL_RGBA32F纹理,因为所有点都已被每个点相乘ModelMatrix以获得世界空间中的点。

和着色器:
layout(binding=5) uniform sampler2D shadowMap;
layout(binding=6) uniform sampler2D positionMap;
in vec2 texcoord;
uniform mat uViewProjectionMatrix;
out vec4 color;
void main() {
vec4 pos = texture(positionMap, texcoord);
vec4 ShadowCoord = uViewProjectionMatrix * pos;
ShadowCoord.xy = ShadowCoord.xy * vec2(0.5,0.5) + vec2(0.5,0.5);
float a = texture(shadowMap, ShadowCoord.xy).z;
color = vec4(a, a, a, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
输出(相机几乎处于光线的相同位置):

我只是想看看每个顶点的投影是否与相机的位置垂直,但看起来并非如此。所有这一切的目的是比较:
if ( texture(shadowMap, ShadowCoord.xy).z < ( ShadowCoord.z-bias ) )
Run Code Online (Sandbox Code Playgroud)
但它也不起作用。
我将不胜感激任何帮助。谢谢。
当我这样做:
SpriteBatch spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, 320, 0, 240, -1, 1));
spriteBatch.begin();
spriteBatch.draw(textureRegion, 0, 0);
spriteBatch.end();
Run Code Online (Sandbox Code Playgroud)
SpriteBatch将绘制textureRegion到我已指定的坐标系320-240到整个屏幕.假设我想使用相同的坐标系320 240进行绘制,但仅在屏幕的左半部分绘制(这意味着所有内容都将在左侧水平缩小,使屏幕的右半部分变黑),我该怎么办?
下面是我正在玩的Vala程序的一些代码.它在Ubuntu 12.04 ATI机器上运行良好,但是当我切换到运行相同操作系统的Nvidia(8400M GS)机器时,我得到零fbConfigs并且从glXChooseFBConfig返回null.
为什么会发生这种情况?这是获取FB配置和VisualInfo以使用GLX创建OpenGL上下文的最佳方式,还是我应该采用不同的方式?
int errorBase;
int eventBase;
int[] glAttrs;
int[] attrs;
FBConfig* fbConfig;
x_server = xServer;
if (screen == int.MIN)
{
screen = x_server.default_screen().screen_number_of_screen();
}
message("Creating Linux context.");
if (glXQueryExtension(x_server, out errorBase, out eventBase) == false)
{
error("GLX extension is not supported.");
}
if (x_server.render_query_extension(out errorBase, out eventBase) ==
false)
{
error("X11 Render extension is not available.");
}
// Get the visual information for this window
// so OpenGL has what it needs.
glAttrs = new int[0]; …Run Code Online (Sandbox Code Playgroud) 我非常了解C++,但我是java的初学者.
Java程序提供输出3.2999997
import java.util.*;
import java.lang.*;
import java.io.*;
class Test
{
public static void main(String args[])
{
float f = 9.9f, m = 3.3f;
float c = f % m;
System.out.println(c);
}
}
Run Code Online (Sandbox Code Playgroud)
C++程序提供输出8.88178e-16
#include <iostream>
#include<math.h>
int main()
{
float f = 9.9f, m = 3.3f;
std::cout << fmod (9.9,3.3);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我对C++程序的输出感到满意,但为什么Java没有给出零响应?
这怎么可能,因为3.3*3 = 9.9
我知道Java认为float的精度为6-7位小数,但我不知道这个输出是怎么来的?我在网上研究了这个问题,但没有找到这背后的逻辑.
public class Queue {
public class ArrayQueue
{
Object store[];
int front,rear;
static final int MAX = 100;
public ArrayQueue()
{
store = new Object[MAX];
front = rear = 0;
}
public void EnQueue(Object o)
{
if((rear +1)%MAX!=front)
{
store [rear] = o;
rear = (rear + 1) % MAX;
}
}
public Object dequeue() throws Exception
{
if( empty())
{
throw new Exception();
}
else
{
Object data = store[front];
store [front] = null;
front = (front+1)%MAX;
return data; …Run Code Online (Sandbox Code Playgroud)