opengl-es-2.0

4 float color to one float in java, and back again in openGL ES 2.0 shader

倾然丶 夕夏残阳落幕 提交于 2019-12-11 08:49:29
问题 I am trying to send one color with every vertex that goes in to the shader, but in only one float value. I think is weird that you cannot send 4 bytes as attributes with every vertex, but sense it's not possible I am going to try to pack RGBA in a single float variable, so this is my code: Jave code (that packs the values in one float): private float fourfColor2One(float r, float g, float b, float a) { long temp = (byte) (r * 255); float res = temp << 24; temp = (byte) (g * 255); res += temp

Android OpenGL ES 2: How to use an OpenGL activity as a fragment in the main activity

ⅰ亾dé卋堺 提交于 2019-12-11 07:57:49
问题 I am quite new to Android and OpenGL ES. I have to create a GUI in OpenGL and I would like to use it as a Fragment in the main activity. In order to learn how to do this, I tried 2 tutorials - this Fragment tutorial and the Android developer tutorial on OpenGL ES. But still I don't understand how exactly do I include an OpenGL view in a Fragment . OpenGL doesn't use XML layout files so this process is quite confusing for me. I would like to do something like this: inside the main activity

glGenBuffers returns 0xffffffff as buffer name

谁说胖子不能爱 提交于 2019-12-11 07:16:23
问题 I have the following code (OpenglES2.0 on iphone): glGenBuffers(1, &tmp->m_vbo); where tmp->m_vbo is unsigned int. For most of the time tmp->m_vbo is valid and everything works perfect, but sometimes the returned value is 0xffffffff and first time I try to use that vbo will crash in glDrawElements. Anyone knows what might cause this ? Thanks. 回答1: I found the cause: there seemed to be something with the context. I used two threads, a loading thread and the main thread, each with each context

How can I use GLSurfaceView in a LinearLayout together with other Views, such as TextView or Button?

帅比萌擦擦* 提交于 2019-12-11 06:44:02
问题 I'm doing a small game on Android 2.3.3 and I want to use openGLES. My question is whether I can GLSurfaceView and TextView , Button in the same layout. My layout xml file is as the following <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center_horizontal" > <com.ecnu.sei.manuzhang.nim.GameView android:id="@+id

load textures into a thread blocks the mainUI in android

核能气质少年 提交于 2019-12-11 06:39:13
问题 I try to load bitmaps and display them into textures (openglES2.0). I make a runnable thread, and once loaded the bitmap are sent to textures. Even my thread is runnable, the main UI Thread freezes for a while during the loading of pictures. I really don't understand this and am pretty lost about it… any clues ? 回答1: Sounds like you're calling myThread.run() instead of myThread.start() run() executes in the calling thread, but start() makes a new thread and then calls run inside of that. If

OpenGL ES 2.0 - Multiple Programs or Shaders

佐手、 提交于 2019-12-11 05:57:02
问题 I currently have two programs, one program for solid lines and fills with a vertex-shader-for-solids and a fragment-shader-for-solids and a second program for textures with a vertex-shader-for-textures and a fragment-shader-for-textures. I swap the the two programs in and out using glUseProgram depending on what I am drawing. Is this a good solution? Or should I glAttachShader/glDetachShader from a single program? 回答1: Definitely, you're using the right solution. Binding a different program

iPad Opengl ES program works fine on simulator but not device

随声附和 提交于 2019-12-11 05:32:23
问题 For the device, all of my shaders load fine except one. For this shader program I get "Fragment program failed to compile with current context state" error, followed by a similar error for the vertex shader when I make a call to glGetProgramInfoLog(...); Vertex shader: #version 100 uniform mat4 Projection; uniform mat4 Modelview; uniform mat4 Rotation; uniform vec3 Translation; uniform vec4 LightDirection; uniform vec4 MaterialDiffuse; uniform float MaterialShininess; attribute vec3 position;

OpenGL ES 2.0 Antialiasing or smoothing on ios and android from shared c++ code

為{幸葍}努か 提交于 2019-12-11 05:24:17
问题 I'm fairly new to OpenGL and to ES2.0. I have shared c++ opengl es2 code that i use to draw on ios and android(with ndk CMake)... it mostly works but now I need antialiasing and its kind of confusing, the solutions I'm seeing are platform dependent and android side is more confusing and has limitations. I have been searching for solutions but need some more clarity. What should have worked on both: Apparently, the Kronos RenderBuffer description says Renderbuffer objects also natively

Getting GL_OUT_OF_MEMORY error at random after drawing

ⅰ亾dé卋堺 提交于 2019-12-11 05:05:01
问题 I am drawing a ton of billboards to the screen, and 'randomly' i get a glerror 1285 either after the drawing, or right before starting the next draw cycle, i can't tell. The whole data is 1.3M~ that i upload to the videocard as vertex and index buffers. There are 20 vertex buffers, 19 of them tells me the position and size of the billboard at 19 different times, and the 20th tells me the vertex index (so i can calculate texture coords in the vertex shader). Every second i change which two

Create an OpenGL ES 2.0 context on a “standard” Linux system

纵饮孤独 提交于 2019-12-11 04:40:38
问题 I'm writing a game engine using opengl 3.3/SDL/glew/Linux (Ubuntu 11.04). I want to keep the possibility to deploy on mobile (OpenGL ES 2). This means that I have to stay somewhat OpenGL ES 2.0 compatible. Therefore my question is: Is it possible to create an OpenGL ES 2.0 context using SDL/(existing patch on SDL). 回答1: You don't need a GL ES 2.0 context on PC, you can use OpenGL 4.1, which has the GL_ARB_es2_compatibility , which adds the OpenGL ES functions that weren't in OpenGL, making