-- [Add] Added an image loader, we shall be able to blit to screen next.
-- [Add] Added rects so we can play on the stack.
This commit is contained in:
parent
db330f1dc3
commit
c100118d72
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
# Makefile for building: Unuk-QT
|
# Makefile for building: Unuk-QT
|
||||||
# Generated by qmake (2.01a) (Qt 4.7.3) on: Sun Nov 6 23:46:01 2011
|
# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Nov 9 00:17:08 2011
|
||||||
# Project: Unuk-QT.pro
|
# Project: Unuk-QT.pro
|
||||||
# Template: app
|
# Template: app
|
||||||
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
@ -16,7 +16,7 @@ CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
|||||||
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
|
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
|
||||||
LINK = g++
|
LINK = g++
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lGLU -lQtGui -lQtCore -lpthread
|
LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lGLU -lQtGui -lQtCore -lpthread
|
||||||
AR = ar cqs
|
AR = ar cqs
|
||||||
RANLIB =
|
RANLIB =
|
||||||
QMAKE = /usr/bin/qmake-qt4
|
QMAKE = /usr/bin/qmake-qt4
|
||||||
@ -49,14 +49,18 @@ SOURCES = ../src/libUnuk/Debug.cpp \
|
|||||||
../src/libUnuk/Timer.cpp \
|
../src/libUnuk/Timer.cpp \
|
||||||
../src/libUnuk/Font.cpp \
|
../src/libUnuk/Font.cpp \
|
||||||
../src/libUnuk/ApplySurface.cpp \
|
../src/libUnuk/ApplySurface.cpp \
|
||||||
../src/Unuk/Globals.cpp
|
../src/Unuk/Globals.cpp \
|
||||||
|
../src/libUnuk/Rect.cpp \
|
||||||
|
../src/libUnuk/ImageLoader.cpp
|
||||||
OBJECTS = Debug.o \
|
OBJECTS = Debug.o \
|
||||||
main.o \
|
main.o \
|
||||||
Input.o \
|
Input.o \
|
||||||
Timer.o \
|
Timer.o \
|
||||||
Font.o \
|
Font.o \
|
||||||
ApplySurface.o \
|
ApplySurface.o \
|
||||||
Globals.o
|
Globals.o \
|
||||||
|
Rect.o \
|
||||||
|
ImageLoader.o
|
||||||
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
||||||
/usr/share/qt4/mkspecs/common/unix.conf \
|
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||||
/usr/share/qt4/mkspecs/common/linux.conf \
|
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||||
@ -159,7 +163,7 @@ qmake: FORCE
|
|||||||
|
|
||||||
dist:
|
dist:
|
||||||
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
||||||
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
|
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
|
||||||
|
|
||||||
|
|
||||||
clean:compiler_clean
|
clean:compiler_clean
|
||||||
@ -227,6 +231,17 @@ ApplySurface.o: ../src/libUnuk/ApplySurface.cpp ../src/libUnuk/ApplySurface.h \
|
|||||||
Globals.o: ../src/Unuk/Globals.cpp ../src/Unuk/Globals.h
|
Globals.o: ../src/Unuk/Globals.cpp ../src/Unuk/Globals.h
|
||||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Globals.o ../src/Unuk/Globals.cpp
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Globals.o ../src/Unuk/Globals.cpp
|
||||||
|
|
||||||
|
Rect.o: ../src/libUnuk/Rect.cpp ../src/libUnuk/Rect.h \
|
||||||
|
../src/Unuk/Globals.h \
|
||||||
|
../src/libUnuk/ApplySurface.h \
|
||||||
|
../src/libUnuk/Debug.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Rect.o ../src/libUnuk/Rect.cpp
|
||||||
|
|
||||||
|
ImageLoader.o: ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/ImageLoader.h \
|
||||||
|
../src/Unuk/Globals.h \
|
||||||
|
../src/libUnuk/Debug.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o ImageLoader.o ../src/libUnuk/ImageLoader.cpp
|
||||||
|
|
||||||
####### Install
|
####### Install
|
||||||
|
|
||||||
install: FORCE
|
install: FORCE
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
LIBS += -lGL \
|
LIBS += -lGL \
|
||||||
-lSDL \
|
-lSDL \
|
||||||
-lSDL_ttf \
|
-lSDL_ttf \
|
||||||
|
-lSDL_image \
|
||||||
-lGLU
|
-lGLU
|
||||||
RESOURCES +=
|
RESOURCES +=
|
||||||
OTHER_FILES += ../src/libUnuk/Debug.o
|
OTHER_FILES += ../src/libUnuk/Debug.o
|
||||||
@ -14,11 +15,14 @@ HEADERS += ../src/libUnuk/Debug.h \
|
|||||||
../Constants.h \
|
../Constants.h \
|
||||||
../src/Unuk/Constants.h \
|
../src/Unuk/Constants.h \
|
||||||
../src/libUnuk/ApplySurface.h \
|
../src/libUnuk/ApplySurface.h \
|
||||||
../src/Unuk/Globals.h
|
../src/Unuk/Globals.h \
|
||||||
|
../src/libUnuk/ImageLoader.h
|
||||||
SOURCES += ../src/libUnuk/Debug.cpp \
|
SOURCES += ../src/libUnuk/Debug.cpp \
|
||||||
../src/Unuk/main.cpp \
|
../src/Unuk/main.cpp \
|
||||||
../src/libUnuk/Input.cpp \
|
../src/libUnuk/Input.cpp \
|
||||||
../src/libUnuk/Timer.cpp \
|
../src/libUnuk/Timer.cpp \
|
||||||
../src/libUnuk/Font.cpp \
|
../src/libUnuk/Font.cpp \
|
||||||
../src/libUnuk/ApplySurface.cpp \
|
../src/libUnuk/ApplySurface.cpp \
|
||||||
../src/Unuk/Globals.cpp
|
../src/Unuk/Globals.cpp \
|
||||||
|
../src/libUnuk/Rect.cpp \
|
||||||
|
../src/libUnuk/ImageLoader.cpp
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
TTF_Font* Font(const char*, const int);
|
TTF_Font* Font(const char* filename, const int size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
37
src/libUnuk/ImageLoader.cpp
Normal file
37
src/libUnuk/ImageLoader.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "ImageLoader.h"
|
||||||
|
|
||||||
|
SDL_Surface* LoadImage(const char* filename) {
|
||||||
|
SDL_Surface* loadedImage = NULL;
|
||||||
|
SDL_Surface* optimizedImage = NULL;
|
||||||
|
|
||||||
|
// Initialize loadedImage with the file.
|
||||||
|
loadedImage = IMG_Load(filename);
|
||||||
|
if(loadedImage != NULL) {
|
||||||
|
// Then copy the image to a surface for us to blit later.
|
||||||
|
optimizedImage = SDL_DisplayFormat(loadedImage);
|
||||||
|
SDL_FreeSurface(loadedImage);
|
||||||
|
return optimizedImage;
|
||||||
|
} else {
|
||||||
|
// Tell us what file is mising and do some stuid error texture thing.
|
||||||
|
Debug::logger->message("ImageLoader: %s cannot be found!");
|
||||||
|
return errorTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Surface* LoadImageAlpha(const char* filename) {
|
||||||
|
SDL_Surface* loadedImage = NULL;
|
||||||
|
SDL_Surface* optimizedImage = NULL;
|
||||||
|
|
||||||
|
// Initialize loadedImage with the file.
|
||||||
|
loadedImage = IMG_Load(filename);
|
||||||
|
if(loadedImage != NULL) {
|
||||||
|
// Then copy the image to a surface and give us an alpha channel.
|
||||||
|
optimizedImage = SDL_DisplayFormatAlpha(loadedImage);
|
||||||
|
SDL_FreeSurface(loadedImage);
|
||||||
|
return optimizedImage;
|
||||||
|
} else {
|
||||||
|
// Tell us what file is mising and do some stuid error texture thing.
|
||||||
|
Debug::logger->message("ImageLoader: %s cannot be found!");
|
||||||
|
return errorTexture;
|
||||||
|
}
|
||||||
|
}
|
11
src/libUnuk/ImageLoader.h
Normal file
11
src/libUnuk/ImageLoader.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _IMAGELOADER_H_
|
||||||
|
#define _IMAGELOADER_H_
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include <SDL/SDL_image.h>
|
||||||
|
#include "../Unuk/Globals.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
SDL_Surface* LoadImage(const char* filename);
|
||||||
|
SDL_Surface* LoadImageAlpha(const char* filename);
|
||||||
|
|
||||||
|
#endif
|
38
src/libUnuk/Rect.cpp
Normal file
38
src/libUnuk/Rect.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include "Rect.h"
|
||||||
|
|
||||||
|
Rect::Rect(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect::~Rect(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::SetXY(int xArg, int yArg) {
|
||||||
|
rect.x = xArg;
|
||||||
|
rect.y = yArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::SetWidthHeight(int wArg, int hArg) {
|
||||||
|
rect.w = wArg;
|
||||||
|
rect.h = hArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::SetRGB(Uint8 rArg, Uint8 gArg, Uint8 bArg) {
|
||||||
|
r = rArg;
|
||||||
|
g = gArg;
|
||||||
|
b = bArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::Draw(void) {
|
||||||
|
SDL_Rect offset;
|
||||||
|
|
||||||
|
offset.x = rect.x - camera.x;
|
||||||
|
offset.y = rect.y - camera.y;
|
||||||
|
offset.w = rect.w;
|
||||||
|
offset.h = rect.h;
|
||||||
|
|
||||||
|
SDL_FillRect(screen, &offset, SDL_MapRGB(screen->format, r, g, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::DrawLiteral(void) {
|
||||||
|
SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b));
|
||||||
|
}
|
@ -2,7 +2,35 @@
|
|||||||
#define _RECT_H_
|
#define _RECT_H_
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <iostream> // May not need this.
|
#include <iostream> // May not need this.
|
||||||
|
#include "../Unuk/Globals.h"
|
||||||
|
#include "ApplySurface.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
class Rect {
|
||||||
|
public:
|
||||||
|
Rect(void);
|
||||||
|
~Rect(void);
|
||||||
|
|
||||||
|
int GetWidth(void) { return rect.w; }
|
||||||
|
int GetHeight(void) { return rect.h; }
|
||||||
|
int GetX(void) { return rect.x; }
|
||||||
|
int GetY(void) { return rect.y; }
|
||||||
|
|
||||||
|
void SetXY(int xArg, int yArg);
|
||||||
|
void SetWidthHeight(int wArg, int hArg);
|
||||||
|
void SetRGB(Uint8 rArg, Uint8 gArg, Uint8 bArg);
|
||||||
|
|
||||||
|
void Draw(void);
|
||||||
|
void DrawLiteral(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Uint8 r;
|
||||||
|
Uint8 g;
|
||||||
|
Uint8 b;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SDL_Rect rect;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user