- Timestamp:
- Apr 11, 2011 9:38:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/sdl_dev.c
r3509 r3525 127 127 #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL 128 128 GLuint texture; 129 void *tex_buf; 130 pj_size_t tex_buf_size; 129 131 #endif 130 132 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 … … 174 176 static pj_status_t sdl_stream_stop(pjmedia_vid_dev_stream *strm); 175 177 static pj_status_t sdl_stream_destroy(pjmedia_vid_dev_stream *strm); 178 static void draw_gl(struct sdl_stream *stream, void *tex_buf); 176 179 177 180 /* Operations */ … … 448 451 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 449 452 glGenTextures(1, &strm->texture); 453 454 #if defined(PJ_WIN32) && PJ_WIN32 != 0 455 if (strm->vafp.framebytes > strm->tex_buf_size) { 456 strm->tex_buf_size = strm->vafp.framebytes; 457 strm->tex_buf = pj_pool_alloc(strm->pool, strm->vafp.framebytes); 458 } 459 #endif 450 460 } else 451 461 #endif … … 514 524 pjmedia_vid_event pevent; 515 525 526 #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL 527 #if defined(PJ_WIN32) && PJ_WIN32 != 0 528 if (strm->param.rend_id == OPENGL_DEV_IDX) { 529 draw_gl(strm, strm->tex_buf); 530 } 531 #endif 532 #endif 516 533 /** 517 534 * The event polling must be placed in the same thread that … … 716 733 } 717 734 735 static void draw_gl(struct sdl_stream *stream, void *tex_buf) 736 { 737 if (stream->texture) { 738 glBindTexture(GL_TEXTURE_2D, stream->texture); 739 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 740 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 741 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 742 stream->rect.w, stream->rect.h, 0, 743 GL_RGBA, GL_UNSIGNED_BYTE, tex_buf); 744 glBegin(GL_TRIANGLE_STRIP); 745 glTexCoord2f(0, 0); glVertex2i(0, 0); 746 glTexCoord2f(1, 0); glVertex2i(stream->rect.w, 0); 747 glTexCoord2f(0, 1); glVertex2i(0, stream->rect.h); 748 glTexCoord2f(1, 1); glVertex2i(stream->rect.w, stream->rect.h); 749 glEnd(); 750 SDL_GL_SwapBuffers(); 751 } 752 } 753 718 754 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 719 755 - (pj_status_t)put_frame … … 775 811 } 776 812 #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL 777 else if (stream->param.rend_id == OPENGL_DEV_IDX) { 778 if (frame && stream->texture) { 779 glBindTexture(GL_TEXTURE_2D, stream->texture); 780 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 781 GL_NEAREST); 782 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 783 GL_NEAREST); 784 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 785 stream->rect.w, stream->rect.h, 0, 786 GL_RGBA, GL_UNSIGNED_BYTE, frame->buf); 787 glBegin(GL_TRIANGLE_STRIP); 788 glTexCoord2f(0, 0); glVertex2i(0, 0); 789 glTexCoord2f(1, 0); glVertex2i(stream->rect.w, 0); 790 glTexCoord2f(0, 1); glVertex2i(0, stream->rect.h); 791 glTexCoord2f(1, 1); 792 glVertex2i(stream->rect.w, stream->rect.h); 793 glEnd(); 794 SDL_GL_SwapBuffers(); 795 } 813 else if (stream->param.rend_id == OPENGL_DEV_IDX) { 814 #if defined(PJ_WIN32) && PJ_WIN32 != 0 815 pj_assert(frame->size == stream->vafp.framebytes); 816 pj_memcpy(stream->tex_buf, frame->buf, frame->size); 817 #else 818 draw_gl(stream, frame->buf); 819 #endif 796 820 } 797 821 #endif
Note: See TracChangeset
for help on using the changeset viewer.