ADDED smarter graphics output

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@388 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2008-02-24 18:01:35 +00:00
parent f6b97afa4b
commit a89050faca
8 changed files with 244 additions and 55 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="de_DE">
<defaultcodec></defaultcodec>
<context>
<name>@default</name>
<message>
@ -203,57 +202,57 @@
<translation type="obsolete">Über &amp;Qt...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="285"/>
<location filename="../src/qt/MainWnd.cpp" line="307"/>
<source>This program is licensed under terms of the GNU General Public License.</source>
<translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="313"/>
<location filename="../src/qt/MainWnd.cpp" line="346"/>
<source>OpenGL version 2.1 is present.</source>
<translation>OpenGL Version 2.1 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="316"/>
<location filename="../src/qt/MainWnd.cpp" line="349"/>
<source>OpenGL version 2.0 is present.</source>
<translation>OpenGL Version 2.0 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="319"/>
<location filename="../src/qt/MainWnd.cpp" line="352"/>
<source>OpenGL version 1.5 is present.</source>
<translation>OpenGL Version 1.5 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="322"/>
<location filename="../src/qt/MainWnd.cpp" line="355"/>
<source>OpenGL version 1.4 is present.</source>
<translation>OpenGL Version 1.4 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="325"/>
<location filename="../src/qt/MainWnd.cpp" line="358"/>
<source>OpenGL version 1.3 is present.</source>
<translation>OpenGL Version 1.3 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="328"/>
<location filename="../src/qt/MainWnd.cpp" line="361"/>
<source>OpenGL version 1.2 is present.</source>
<translation>OpenGL Version 1.2 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="331"/>
<location filename="../src/qt/MainWnd.cpp" line="364"/>
<source>OpenGL version 1.1 is present.</source>
<translation>OpenGL Version 1.1 ist verfügbar.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="337"/>
<location filename="../src/qt/MainWnd.cpp" line="370"/>
<source>OpenGL is NOT available!</source>
<translation>OpenGL ist NICHT verfügbar!</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="287"/>
<location filename="../src/qt/MainWnd.cpp" line="309"/>
<source>About VBA-M</source>
<translation>Über VBA-M</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="340"/>
<location filename="../src/qt/MainWnd.cpp" line="373"/>
<source>About OpenGL</source>
<translation>Über OpenGL</translation>
</message>
@ -273,42 +272,42 @@
<translation type="obsolete">Übersetzungsdateien (*.qm)</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="227"/>
<location filename="../src/qt/MainWnd.cpp" line="249"/>
<source>.qm</source>
<translation></translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="138"/>
<location filename="../src/qt/MainWnd.cpp" line="151"/>
<source>Exit</source>
<translation>Beenden</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="144"/>
<location filename="../src/qt/MainWnd.cpp" line="157"/>
<source>Select language...</source>
<translation>Sprache auswählen...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="206"/>
<location filename="../src/qt/MainWnd.cpp" line="228"/>
<source>Select language</source>
<translation>Sprache auswählen</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="208"/>
<location filename="../src/qt/MainWnd.cpp" line="230"/>
<source>Language files (*.qm)</source>
<translation>Sprachdateien (*.qm)</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="218"/>
<location filename="../src/qt/MainWnd.cpp" line="325"/>
<source>Error!</source>
<translation>Fehler!</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="218"/>
<location filename="../src/qt/MainWnd.cpp" line="240"/>
<source>Language file can not be loaded!</source>
<translation>Sprachdatei kann nicht geladen werden!</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="104"/>
<location filename="../src/qt/MainWnd.cpp" line="117"/>
<source>Enable translation</source>
<translation>Übersetzung aktivieren</translation>
</message>
@ -320,85 +319,95 @@ No language file loaded.</source>
Deutsche Übersetzung von spacy.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="172"/>
<location filename="../src/qt/MainWnd.cpp" line="185"/>
<source>Cheats</source>
<translation></translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="151"/>
<location filename="../src/qt/MainWnd.cpp" line="164"/>
<source>Show cheats sidebar</source>
<translation>Cheats-Seitenleiste anzeigen</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="136"/>
<location filename="../src/qt/MainWnd.cpp" line="149"/>
<source>File</source>
<translation>Datei</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="137"/>
<location filename="../src/qt/MainWnd.cpp" line="150"/>
<source>Open ROM</source>
<translation>ROM laden</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="142"/>
<location filename="../src/qt/MainWnd.cpp" line="155"/>
<source>Settings</source>
<translation>Einstellungen</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="143"/>
<location filename="../src/qt/MainWnd.cpp" line="156"/>
<source>Main options...</source>
<translation>Optionen...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="149"/>
<location filename="../src/qt/MainWnd.cpp" line="162"/>
<source>Tools</source>
<translation>Werkzeuge</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="156"/>
<location filename="../src/qt/MainWnd.cpp" line="169"/>
<source>Help</source>
<translation>Hilfe</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="158"/>
<location filename="../src/qt/MainWnd.cpp" line="171"/>
<source>About VBA-M...</source>
<translation>Über VBA-M...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="159"/>
<location filename="../src/qt/MainWnd.cpp" line="172"/>
<source>About OpenGL...</source>
<translation>Über OpenGL...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="160"/>
<location filename="../src/qt/MainWnd.cpp" line="173"/>
<source>About Qt...</source>
<translation>Über Qt...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="294"/>
<source>Enter ROM loader code here.</source>
<translation>Funktionalität noch nicht vorhanden.</translation>
<translation type="obsolete">Funktionalität noch nicht vorhanden.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="296"/>
<source>Status</source>
<translation></translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="278"/>
<location filename="../src/qt/MainWnd.cpp" line="300"/>
<source>Version</source>
<translation>Version</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="280"/>
<location filename="../src/qt/MainWnd.cpp" line="302"/>
<source>Compile date:</source>
<translation>Bau-Datum:</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="283"/>
<location filename="../src/qt/MainWnd.cpp" line="305"/>
<source>No language file loaded.</source>
<translation>Deutsche Übersetzung von spacy.</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="317"/>
<source>Select ROM</source>
<translation>Bitte ROM auswählen</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="319"/>
<source>Game Boy Advance ROMs (*.gba);;All Files (*.*)</source>
<translation>Game Boy Advance ROMs (*.gba);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="325"/>
<source>Can not load ROM!</source>
<translation>ROM kann nicht geladen werden!</translation>
</message>
</context>
<context>
<name>VideoOptionsPage</name>
@ -415,17 +424,17 @@ Deutsche Übersetzung von spacy.</translation>
<message>
<location filename="../src/qt/MainOptions.cpp" line="27"/>
<source>OGL</source>
<translation>OpenGL</translation>
<translation type="obsolete">OpenGL</translation>
</message>
<message>
<location filename="../src/qt/MainOptions.cpp" line="28"/>
<source>D3D</source>
<translation>Direct3D</translation>
<translation type="obsolete">Direct3D</translation>
</message>
<message>
<location filename="../src/qt/MainOptions.cpp" line="29"/>
<source>QPainter</source>
<translation>QPainter (Qt)</translation>
<translation type="obsolete">QPainter (Qt)</translation>
</message>
</context>
<context>

View File

@ -37,3 +37,6 @@ SOURCES += ../../src/qt/configdialog.cpp
HEADERS += ../../src/qt/EmuManager.h
SOURCES += ../../src/qt/EmuManager.cpp
HEADERS += ../../src/qt/GraphicsOutput.h
SOURCES += ../../src/qt/GraphicsOutput.cpp

View File

@ -132,6 +132,18 @@
</File>
</Filter>
</Filter>
<Filter
Name="IO"
>
<File
RelativePath="..\..\src\qt\GraphicsOutput.cpp"
>
</File>
<File
RelativePath="..\..\src\qt\GraphicsOutput.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Build"

94
src/qt/GraphicsOutput.cpp Normal file
View File

@ -0,0 +1,94 @@
// VBA-M, A Nintendo Handheld Console Emulator
// Copyright (C) 2008 VBA-M development team
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GraphicsOutput.h"
GraphicsOutput::GraphicsOutput( QWidget *parent)
: QGLWidget( parent ),
m_api( NONE )
{
}
GraphicsOutput::~GraphicsOutput()
{
}
bool GraphicsOutput::setAPI( GraphicsOutput::DISPLAY_API api )
{
if( ( api == OPENGL ) && ( !QGLFormat::hasOpenGL() ) ) {
return false;
}
m_api = api;
return true;
}
GraphicsOutput::DISPLAY_API GraphicsOutput::getAPI()
{
return m_api;
}
void GraphicsOutput::render()
{
repaint(); // immediately calls paintEvent()
}
void GraphicsOutput::paintEvent( QPaintEvent *event )
{
if( m_api == NONE ) return;
QPainter painter;
painter.begin( this );
painter.setRenderHint( QPainter::Antialiasing ); // enable AA if supported by OpenGL device
painter.setRenderHint( QPainter::TextAntialiasing );
painter.setRenderHint( QPainter::HighQualityAntialiasing );
painter.fillRect( rect(), QBrush( QColor( 0xFF, 0x00, 0x00 ), Qt::SolidPattern ) );
painter.setPen( QColor( 0x00, 0x00, 0xFF ) );
painter.drawEllipse( rect() );
static unsigned int counter = 0;
static QTime firstTime = QTime::currentTime();
int tDiff = firstTime.secsTo( QTime::currentTime() );
int fps = 0;
if( tDiff != 0 ) {
fps = counter / tDiff;
}
painter.setPen( QColor( 0x00, 0xFF, 0x00 ) );
painter.setFont( QFont( "Arial", 14, QFont::Bold ) );
painter.drawText( rect(), Qt::AlignCenter, "Frame Number " + QString::number( counter++ ) +
"\nFPS: " + QString::number( fps ) );
painter.end();
}

54
src/qt/GraphicsOutput.h Normal file
View File

@ -0,0 +1,54 @@
// VBA-M, A Nintendo Handheld Console Emulator
// Copyright (C) 2008 VBA-M development team
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef GRAPHICSOUTPUT_H
#define GRAPHICSOUTPUT_H
#include "precompile.h"
// this class uses a QGLWidget with QPainter, which uses OpenGL acceleration if supported
class GraphicsOutput : public QGLWidget
{
Q_OBJECT
public:
GraphicsOutput( QWidget *parent );
~GraphicsOutput();
enum DISPLAY_API
{
NONE,
QPAINTER,
OPENGL,
DIRECT3D
};
bool setAPI( DISPLAY_API api );
DISPLAY_API getAPI();
public slots:
void render();
protected:
void paintEvent( QPaintEvent *event );
private:
DISPLAY_API m_api;
};
#endif // #ifndef GRAPHICSOUTPUT_H

View File

@ -24,9 +24,9 @@ VideoOptionsPage::VideoOptionsPage(QWidget *parent)
QGroupBox *RenderGroup = new QGroupBox(tr("Renderer Selection"));
QLabel *RenderLabel = new QLabel(tr("Renderer:"));
QComboBox *RenderCombo = new QComboBox;
RenderCombo->addItem(tr("OGL"));
RenderCombo->addItem(tr("D3D"));
RenderCombo->addItem(tr("QPainter"));
RenderCombo->addItem("OpenGL");
//RenderCombo->addItem(tr("D3D"));
RenderCombo->addItem("QPainter");
QHBoxLayout *RenderLayout = new QHBoxLayout;
RenderLayout->addWidget(RenderLabel);

View File

@ -19,7 +19,7 @@
#include "MainWnd.h"
#include "version.h"
#include "glwidget.h"
//#include "glwidget.h"
#include "configdialog.h"
#include "sidewidget_cheats.h"
@ -34,7 +34,8 @@ MainWnd::MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent )
helpMenu( 0 ),
enableTranslationAct( 0 ),
dockWidget_cheats( 0 ),
emuManager( 0 )
emuManager( 0 ),
graphicsOutput( 0 )
{
createDisplay();
setMinimumSize( 320, 240 );
@ -56,6 +57,11 @@ MainWnd::~MainWnd()
delete emuManager;
emuManager = 0;
}
if( graphicsOutput != 0 ) {
delete graphicsOutput;
graphicsOutput = 0;
}
}
@ -188,15 +194,24 @@ void MainWnd::createDockWidgets()
bool MainWnd::createDisplay()
{
if( !QGLFormat::hasOpenGL() ) return false;
GLWidget *ogl = new GLWidget( this );
if( ogl->isValid() ) {
setCentralWidget( ogl );
return true;
if( graphicsOutput != 0 ) {
delete graphicsOutput;
graphicsOutput = 0;
}
return false;
graphicsOutput = new GraphicsOutput( this );
if( !graphicsOutput->setAPI( GraphicsOutput::QPAINTER ) ) return false;
setCentralWidget( graphicsOutput );
QTimer *timer = new QTimer( this );
connect( timer, SIGNAL( timeout() ), graphicsOutput, SLOT( render() ) );
timer->start( 15 ); // set to 0 for idle time processing
// 1000 / 60 = 60 fps, but only results to 40 fps in reality.
// possible workaround: call timer more often and return or wait if too early
return true;
}

View File

@ -22,6 +22,7 @@
#include "precompile.h"
#include "EmuManager.h"
#include "GraphicsOutput.h"
class MainWnd : public QMainWindow
{
@ -53,6 +54,7 @@ private:
QMenu *helpMenu;
QDockWidget *dockWidget_cheats;
EmuManager *emuManager;
GraphicsOutput *graphicsOutput;
private slots:
bool selectLanguage();