- Fix warnings in frontend
- Example of using vertex arrays in one of rendering functions
--- a/QTfrontend/CMakeLists.txt Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/CMakeLists.txt Wed Mar 18 22:02:55 2009 +0000
@@ -27,6 +27,8 @@
# Done
include_directories(.)
+set(CMAKE_CXX_FLAGS "-Wall")
+
if(WIN32 AND NOT UNIX)
set(HEDGEWARS_BINDIR ".")
set(HEDGEWARS_DATADIR "../share/")
--- a/QTfrontend/game.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/game.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -32,8 +32,8 @@
HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
TCPBase(true),
- m_pTeamSelWidget(pTeamSelWidget),
- ammostr(ammo)
+ ammostr(ammo),
+ m_pTeamSelWidget(pTeamSelWidget)
{
this->config = config;
this->gamecfg = gamecfg;
--- a/QTfrontend/hwform.h Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/hwform.h Wed Mar 18 22:02:55 2009 +0000
@@ -122,13 +122,13 @@
ID_PAGE_SCHEME = 16
};
HWGame * game;
+ HWNetServer* pnetserver;
+ HWNetRegisterServer* pRegisterServer;
HWTeam * editedTeam;
HWNewNet * hwnet;
GameUIConfig * config;
AmmoSchemeModel * ammoSchemeModel;
QStack<quint8> PagesStack;
- HWNetServer* pnetserver;
- HWNetRegisterServer* pRegisterServer;
QTime eggTimer;
SDLInteraction sdli;
void OnPageShown(quint8 id, quint8 lastid=0);
--- a/QTfrontend/itemNum.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/itemNum.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -22,9 +22,8 @@
#include <QPainter>
ItemNum::ItemNum(const QImage& im, QWidget * parent, unsigned char min, unsigned char max) :
- m_im(im), QFrame(parent), nonInteractive(false), minItems(min), maxItems(max),
- numItems(min+2 >= max ? min : min+2),
- infinityState(false)
+ QFrame(parent), m_im(im), infinityState(false), nonInteractive(false), minItems(min), maxItems(max),
+ numItems(min+2 >= max ? min : min+2)
{
}
--- a/QTfrontend/itemNum.h Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/itemNum.h Wed Mar 18 22:02:55 2009 +0000
@@ -31,27 +31,27 @@
unsigned char getItemsNum() const;
void setItemsNum(const unsigned char num);
+ private:
+ QImage m_im;
+ bool infinityState;
+
protected:
ItemNum(const QImage& im, QWidget * parent, unsigned char min=2, unsigned char max=8);
virtual QSize sizeHint () const;
virtual ~ItemNum()=0;
-
+
bool nonInteractive;
- unsigned char numItems;
unsigned char minItems;
unsigned char maxItems;
+ unsigned char numItems;
// from QWidget
virtual void mousePressEvent ( QMouseEvent * event );
virtual void paintEvent(QPaintEvent* event);
-
+
// to be implemented in child
virtual void incItems()=0;
virtual void decItems()=0;
-
- private:
- bool infinityState;
- QImage m_im;
};
#endif // _ITEM_NUM_INCLUDED
--- a/QTfrontend/misc.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/misc.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -54,7 +54,7 @@
// start hashing
- quint32 w[16], i, a, b, c, d, f, g, t;
+ quint32 w[16], i, a, b, c, d;
quint32 h0 = 0x67452301;
quint32 h1 = 0xEFCDAB89;
--- a/QTfrontend/pages.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/pages.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -660,7 +660,6 @@
PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent)
{
- QFont * font14 = new QFont("MS Shell Dlg", 14);
QGridLayout * pageLayout = new QGridLayout(this);
pageLayout->setColumnStretch(0, 1);
pageLayout->setColumnStretch(1, 1);
@@ -674,7 +673,6 @@
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent)
{
- QFont * font14 = new QFont("MS Shell Dlg", 14);
QVBoxLayout * vLayout = new QVBoxLayout(this);
QHBoxLayout * topLine = new QHBoxLayout();
QHBoxLayout * middleLine = new QHBoxLayout();
@@ -850,6 +848,10 @@
AbstractPage(parent)
{
QGridLayout * pageLayout = new QGridLayout(this);
+
+ QLabel * lblConnecting = new QLabel(this);
+ lblConnecting->setText(tr("Connecting..."));
+ pageLayout->addWidget(lblConnecting);
}
PageScheme::PageScheme(QWidget* parent) :
--- a/QTfrontend/selectWeapon.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/selectWeapon.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -70,8 +70,8 @@
}
SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) :
- m_numItems(numItems),
- QFrame(parent)
+ QFrame(parent),
+ m_numItems(numItems)
{
wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this);
--- a/QTfrontend/statsPage.cpp Wed Mar 18 21:43:46 2009 +0000
+++ b/QTfrontend/statsPage.cpp Wed Mar 18 22:02:55 2009 +0000
@@ -34,7 +34,6 @@
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
{
- QFont * font14 = new QFont("MS Shell Dlg", 14);
QGridLayout * pageLayout = new QGridLayout(this);
pageLayout->setColumnStretch(0, 1);
pageLayout->setColumnStretch(1, 1);
--- a/hedgewars/uConsts.pas Wed Mar 18 21:43:46 2009 +0000
+++ b/hedgewars/uConsts.pas Wed Mar 18 22:02:55 2009 +0000
@@ -118,7 +118,9 @@
end;
PTexture = ^TTexture;
-
+ TVertex2f = record
+ X, Y: GLfloat;
+ end;
const
errmsgCreateSurface = 'Error creating SDL surface';
errmsgTransparentSet = 'Error setting transparent color';
--- a/hedgewars/uStore.pas Wed Mar 18 21:43:46 2009 +0000
+++ b/hedgewars/uStore.pas Wed Mar 18 22:02:55 2009 +0000
@@ -342,24 +342,46 @@
end;
procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
+var VertexBuffer, TextureBuffer: array [0..5] of TVertex2f;
begin
+glPushMatrix;
+glTranslatef(X, Y, 0);
+
glBindTexture(GL_TEXTURE_2D, Texture^.id);
-glBegin(GL_QUADS);
-
-glTexCoord2f(0, 0);
-glVertex2i(X, Y);
-
-glTexCoord2f(Texture^.rx, 0);
-glVertex2i(Texture^.w + X, Y);
+VertexBuffer[0].X:= 0;
+VertexBuffer[0].Y:= 0;
+VertexBuffer[1].X:= Texture^.w;
+VertexBuffer[1].Y:= 0;
+VertexBuffer[2].X:= Texture^.w;
+VertexBuffer[2].Y:= Texture^.h;
+VertexBuffer[3].X:= 0;
+VertexBuffer[3].Y:= Texture^.h;
+VertexBuffer[4]:= VertexBuffer[0];
+VertexBuffer[5]:= VertexBuffer[2];
-glTexCoord2f(Texture^.rx, Texture^.ry);
-glVertex2i(Texture^.w + X, Texture^.h + Y);
+TextureBuffer[0].X:= 0;
+TextureBuffer[0].Y:= 0;
+TextureBuffer[1].X:= Texture^.rx;
+TextureBuffer[1].Y:= 0;
+TextureBuffer[2].X:= Texture^.rx;
+TextureBuffer[2].Y:= Texture^.ry;
+TextureBuffer[3].X:= 0;
+TextureBuffer[3].Y:= Texture^.ry;
+TextureBuffer[4]:= TextureBuffer[0];
+TextureBuffer[5]:= TextureBuffer[2];
-glTexCoord2f(0, Texture^.ry);
-glVertex2i(X, Texture^.h + Y);
+glEnableClientState(GL_VERTEX_ARRAY);
+glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-glEnd()
+glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
+glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
+glDrawArrays(GL_TRIANGLES, 0, Length(VertexBuffer));
+
+glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+glDisableClientState(GL_VERTEX_ARRAY);
+
+glPopMatrix
end;
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt);