opengl es2.0 实现播放器渲染


//media_gl.h

#ifndef MEDIA_GL_H

#define MEDIA_GL_H

//type:没使用,x,y为视口坐标,w,h为视口宽和高
int init_view(int x,int y,int w,int h,int type);


void uninit_view();

//type:3 RGB格式,4 RGBA格式,w 图片宽度,h图片高度,imgdata图片内存格式数据(rgb数组)
void update_texture(int type,int w,int h,void* imgdata);

//
void update_draw();

//x,y为视口坐标,w,h为视口宽和高,需要配合窗口一起调用
void update_viewsize(int x,int y,int w,int h);


//turn:顺时针旋转角度 0,90,180,270
void update_viewturn(int turn);


#endif


//media_gl.c

#include "media_gl.h"

#if defined( __APPLE__ ) && !defined(__MACOSX)
#include <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#elif defined(linux) || defined(__linux) || defined(__linux__)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#endif

struct media_point
{
float _x;
float _y;
float _tx;
float _ty;
};

struct media_view
{
GLuint _prpgram;
GLuint _vexctbuf;
GLuint _textureid;
int _vexctbuf_index;
};

#define shader_vs " \
attribute vec4 position;\n \
attribute vec2 texcoord;\n \
varying vec2 v_texcoord;\n \
void main() {\n \
gl_Position = position;\n \
v_texcoord = texcoord;\n \
}"

#define shader_fs  " \
varying vec2 v_texcoord;\n \
uniform sampler2D texture0;\n \
void main() {\n \
gl_FragColor= texture2D(texture0, v_texcoord);\n \
}"

struct media_view _g_view = {0,0,0,0};

static GLuint _compile(const char * source, int type) 
{
GLint status;
GLuint shader = glCreate

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值