Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
gl: check gl1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin authored and Wang Bin committed Mar 24, 2013
1 parent 9a7c9ae commit 2dbc8f1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 13 deletions.
2 changes: 1 addition & 1 deletion QtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cache(SOURCE_ROOT, set, SOURCE_ROOT)
cache(mkspecs_cached, set, mkspecs_build)

EssentialDepends = avutil avcodec avformat swscale
OptionalDepends = portaudio direct2d gdiplus xv #openal
OptionalDepends = portaudio direct2d gdiplus xv gl #openal
for(d, EssentialDepends) {
!config_$$d {
CONFIG *= recheck
Expand Down
13 changes: 13 additions & 0 deletions config.tests/gl/gl.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG += qt
QT += core gui opengl
CONFIG += console

SOURCES += main.cpp

win32 {
LIBS += -lopengl32
} else:macx {
LIBS += -framework OpenGL -framework AGL
} else {
LIBS += -lGL
}
43 changes: 43 additions & 0 deletions config.tests/gl/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013 Wang Bin <[email protected]>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#include <qgl.h> //check type conflicting for gl.h and GLES2/gl2.h
//gl.h is auto included by qt build with gl(not gles)
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif //__APPLE__

int main()
{
glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);
glPushMatrix();
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2d(0.0, 0.0); glVertex2d(-1.0, +1.0);
glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);

return 0;
}
4 changes: 3 additions & 1 deletion examples/examples.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
TEMPLATE = subdirs

SUBDIRS += \
player-gl \
simpleplayer \
videographicsitem \
videowall
Expand All @@ -13,3 +12,6 @@ config_gdiplus {
config_direct2d {
SUBDIRS += player-d2d
}
config_gl {
SUBDIRS += player-gl
}
8 changes: 6 additions & 2 deletions src/GLWidgetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
#include "QtAV/GLWidgetRenderer.h"
#include "private/VideoRenderer_p.h"
#include <QResizeEvent>

#ifdef Q_OS_MAC
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif //Q_OS_MAC
//TODO: vsync http://stackoverflow.com/questions/589064/how-to-enable-vertical-sync-in-opengl
//TODO: check gl errors
//GL_BGRA is available in OpenGL >= 1.2
#ifndef GL_BGRA
#ifndef GL_BGRA_EXT
#include <GL/glext.h> //GL_BGRA_EXT for OpenGL<=1.1
#include <GL/glext.h> //GL_BGRA_EXT for OpenGL<=1.1 //TODO Apple include <OpenGL/xxx>
#endif //GL_BGRA_EXT
#ifndef GL_BGRA //it may be defined in glext.h
#define GL_BGRA GL_BGRA_EXT
Expand Down
6 changes: 4 additions & 2 deletions src/VideoRendererTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ void RegisterVideoRendererWidget_Man()
{
FACTORY_REGISTER_ID_MAN(VideoRenderer, Widget, "QWidegt")
}

#if HAVE_GL
FACTORY_REGISTER_ID_AUTO(VideoRenderer, GLWidget, "QGLWidegt")

void RegisterVideoRendererGLWidget_Man()
{
FACTORY_REGISTER_ID_MAN(VideoRenderer, GLWidget, "QGLWidegt")
}

#endif //HAVE_GL
#if HAVE_GDIPLUS
FACTORY_REGISTER_ID_AUTO(VideoRenderer, GDI, "GDI")

Expand Down Expand Up @@ -84,7 +84,9 @@ void RegisterVideoRendererXV_Man()
void VideoRenderer_RegisterAll()
{
RegisterVideoRendererWidget_Man();
#if HAVE_GL
RegisterVideoRendererGLWidget_Man();
#endif //HAVE_GL
#if HAVE_GDIPLUS
RegisterVideoRendererGDI_Man();
#endif //HAVE_GDIPLUS
Expand Down
18 changes: 11 additions & 7 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ config_direct2d {
#LIBS += -lD2d1
}
config_xv {
DEFINES *= HAVE_XV=1
SOURCES += XVRenderer.cpp
HEADERS += QtAV/XVRenderer.h
LIBS += -lXv
DEFINES *= HAVE_XV=1
SOURCES += XVRenderer.cpp
HEADERS += QtAV/XVRenderer.h
SDK_HEADERS += QtAV/XVRenderer.h
LIBS += -lXv
}
config_gl {
DEFINES *= HAVE_GL=1
SOURCES += GLWidgetRenderer.cpp
HEADERS += QtAV/GLWidgetRenderer.h
SDK_HEADERS += QtAV/GLWidgetRenderer.h
}

SOURCES += \
QtAV_Compat.cpp \
QtAV_Global.cpp \
Expand All @@ -106,7 +112,6 @@ SOURCES += \
AVDemuxThread.cpp \
EventFilter.cpp \
Filter.cpp \
GLWidgetRenderer.cpp \
GraphicsItemRenderer.cpp \
ImageConverter.cpp \
ImageConverterFF.cpp \
Expand Down Expand Up @@ -138,7 +143,6 @@ SDK_HEADERS *= \
QtAV/AVDemuxThread.h \
QtAV/BlockingQueue.h \
QtAV/Filter.h \
QtAV/GLWidgetRenderer.h \
QtAV/GraphicsItemRenderer.h \
QtAV/ImageConverter.h \
QtAV/QPainterRenderer.h \
Expand Down

0 comments on commit 2dbc8f1

Please sign in to comment.