opengl-es

Why my OpenGL custom shader gives me this error?

醉酒当歌 提交于 2020-07-21 09:08:27
问题 I'm using a custom shader with cocos2d 3.17 for my macOS app on XCode11 but I have some troubles. myShader.frag #ifdef GL_ES precision lowp float; #endif uniform sampler2D u_texture; varying lowp vec4 v_fragmentColor; uniform mat4 u_rotation; void main() { mat4 t1= mat4(1); mat4 t2= mat4(1); t1[3] = vec4(-0.5,-0.5,1,1); t2[3] = vec4(+0.5,+0.5,1,1); vec2 pos = (t2 * u_rotation * t1 * vec4(gl_PointCoord, 0, 1)).xy; gl_FragColor = v_fragmentColor * texture2D(u_texture, pos); } myShader.vert

how to update vertex buffer data frequently (every frame) opengl

安稳与你 提交于 2020-07-19 05:29:24
问题 I have a simple 2d triangle displayed on the screen, I want to update the color buffer data every frame, so the color of the triangle changes constantly, but im not sure how to update the data efficiently. this is the code for the color buffer: GLfloat colourVert[] = { 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; GLuint colourBuffer; glGenBuffers(1, &colourBuffer); glBindBuffer(GL_ARRAY_BUFFER, colourBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(colourVert), colourVert, GL_DYNAMIC

android OpenGl How to draw a rectangle

↘锁芯ラ 提交于 2020-07-17 17:34:35
问题 I wnat to draw a rectangle using opengl. package jnidemo.example.com.openglsquare; import android.content.Context; import android.opengl.GLSurfaceView; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10;