OpenGL ES 2.0 shaders off-screen blend and color conversion

Hi, i am very newbie in OpenGL and Shaders, i would like to use OpenGl to color conversion, and alpha blending (PowerVr SGX 530), could you help me? I have written this so far, but shaders doesnt work, what i am doing wrong?

#include <stdio.h>
#include <stdlib.h>

#include <../include/EGL/egl.h>
#include <../include/EGL/eglext.h>
#include <../include/GLES2/gl2.h>
#include <../include/GLES2/gl2ext.h>

int main() {

	EGLDisplay eglDisplay = 0;
	EGLConfig eglConfig = 0;
	EGLSurface eglSurface = 0;
	EGLContext eglContext = 0;

	eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	EGLint iMajorVersion, iMinorVersion;
	eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion);

	EGLint pi32ConfigAttribs[5];
	pi32ConfigAttribs[0] = EGL_SURFACE_TYPE;
	pi32ConfigAttribs[1] = EGL_WINDOW_BIT;
	pi32ConfigAttribs[2] = EGL_RENDERABLE_TYPE;
	pi32ConfigAttribs[3] = EGL_OPENGL_ES2_BIT;
	pi32ConfigAttribs[4] = EGL_NONE;

	EGLint pi32ContextAttribs[3];
	pi32ContextAttribs[0] = EGL_CONTEXT_CLIENT_VERSION;
	pi32ContextAttribs[1] = 2;
	pi32ContextAttribs[2] = EGL_NONE;

	int iConfigs;
	eglChooseConfig(eglDisplay, pi32ConfigAttribs, &eglConfig, 1, &iConfigs);
	eglSurface = eglCreatePbufferSurface(eglDisplay, eglConfig, NULL);
	eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, pi32ContextAttribs);
	eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);

	int renderBufferWidth = 1280;
	int renderBufferHeight = 720;

	// now the FBO
	GLuint fbo = 0;
	glGenFramebuffers(1, &fbo);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);

	GLuint renderBuffer = 0;
	glGenRenderbuffers(1, &renderBuffer);
	glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, renderBufferWidth, renderBufferHeight);

	glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);

	GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
		printf("Problem with OpenGL framebuffer after specifying color render buffer: %x", status);

	const char* pszFragShader =
			"void main (void) { gl_FragColor = vec4(0.0, 0.0, 0.0 , 0.0); }";

	GLuint uiFragShader, uiVertShader; // Used to hold the fragment and vertex shader handles
	GLuint uiProgramObject; // Used to hold the program handle (made out of the two previous shaders
	uiFragShader = glCreateShader(GL_FRAGMENT_SHADER);
	glShaderSource(uiFragShader, 1, (const char**) &pszFragShader, NULL);
	GLint bShaderCompiled;
	glGetShaderiv(uiFragShader, GL_COMPILE_STATUS, &bShaderCompiled);

	uiProgramObject = glCreateProgram();

 program object =  %d", uiProgramObject);

	glAttachShader(uiProgramObject, uiFragShader);


	GLfloat vVertices[] = { -1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f,
			0.0f };

	glViewport(0, 0, renderBufferWidth, renderBufferHeight);
	glClearColor(1.0f, 0.0f, 1.0f, 1.0f);


	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, vVertices);
	glDrawArrays(GL_TRIANGLES, 0, 4);
	eglSwapBuffers(eglDisplay, eglSurface);

	GLuint * data = (GLuint *) malloc(renderBufferWidth * renderBufferHeight * sizeof(GLuint));
	glReadPixels(0, 0, renderBufferWidth, renderBufferHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);

pixel = %u", data[2]);

	return 0;

You need a vertex shader.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.