Thursday, 23 August 2012
SDL2.0 to create a modern OpenGL context.
I've been having difficulty finding documentation for SDL2.0 so I'm going to record the invocations here as I find them... (With thanks to everyone who's helped me find them)
Once I've got a better (and full) handle on it I might try to right a well written tutorial... For now I'll just record my findings.
Once I've got a better (and full) handle on it I might try to right a well written tutorial... For now I'll just record my findings.
Requesting a given version of OpenGL
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,2);
This appears to disable the compatibility profile/enable the core profile only. I need to check this though.
Creating an OpenGL context...
int width = 640; int height = 480;
SDL_Window* pWindow;
SDL_GLContext context;
int other_flags = 0;
pWindow = SDL_CreateWindow("Title",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height,
SDL_WINDOW_OPENGL|other_flags);
context = SDL_GL_CreateContext(pWindow);
Verifying that the Context was created successfully...
const unsigned char* version = glGetString(GL_VERSION);
if (version == NULL) {
// Failed to initialise, error logging here
exit(-1);
}
Flushing pipeline...
SDL_GL_SwapWindow(pWindow);
Todo: Figure out how to compile/link a shader.
Tuesday, 14 August 2012
Crossplatform Development?
So. I'm finally going back to C++... and remembering why I learned Python to get away from certain things.
Most notably is the pain of setting up Makefiles by hand. Still. I think I've hit on something. Relative to my project's directory...
I have a folder for my build which contains a Makefile customised for that platform. On windows this is...
mingw_debug/Makefile:
CC=mingw32-gcc.exe
CXX=mingw32-g++.exe
CFLAGS=-g -O0 -Wall -pedantic -Wno-long-long
LIBS=-lmingw32 -lSDLmain -lSDL -lopengl32 -lphysfs
DLL=SDL.dll libphysfs.dll
include ../src/Makefile.core
It explicitly specifies CC and CXX because I tend to use Cygwin as a replacement shell and it allows me to use make instead of mingw32-make.exe.
src/Makefile.core
SOURCES=hello.cxx
OBJECTS=$(SOURCES:.cxx=.o)
DEPS=$(OBJECTS:.o=.d)
CFLAGS+=-I../src/
all: Coulomb.exe $(DLL)
-include $(DEPS)
Coulomb.exe: $(OBJECTS)
$(CXX) -o Coulomb.exe $(OBJECTS) $(LIBS)
define cc-command
$(CXX) -o $@ -c $< $(CFLAGS)
endef
define depend-command
$(CXX) -MM -MF $(patsubst %.o,%.d,$@) $< $(CFLAGS)
endef
data/%.o: ../src/data/%.cxx
$(depend-command)
$(cc-command)
%.o: ../src/%.cxx
$(depend-command)
$(cc-command)
%.dll: ../%.dll
cp $< .
.phony: all clean
clean:
rm -rf *.exe
rm -rf *.o
rm -rf data/*.o
rm -rf *.d
rm -rf data/*.d
rm -rf *.dll
Unfortunately I still don't really know what I'm going to do with this set up yet. I'd appreciate any comments on the Makefile set up though.
Most notably is the pain of setting up Makefiles by hand. Still. I think I've hit on something. Relative to my project's directory...
I have a folder for my build which contains a Makefile customised for that platform. On windows this is...
mingw_debug/Makefile:
CC=mingw32-gcc.exe
CXX=mingw32-g++.exe
CFLAGS=-g -O0 -Wall -pedantic -Wno-long-long
LIBS=-lmingw32 -lSDLmain -lSDL -lopengl32 -lphysfs
DLL=SDL.dll libphysfs.dll
include ../src/Makefile.core
It explicitly specifies CC and CXX because I tend to use Cygwin as a replacement shell and it allows me to use make instead of mingw32-make.exe.
src/Makefile.core
SOURCES=hello.cxx
OBJECTS=$(SOURCES:.cxx=.o)
DEPS=$(OBJECTS:.o=.d)
CFLAGS+=-I../src/
all: Coulomb.exe $(DLL)
-include $(DEPS)
Coulomb.exe: $(OBJECTS)
$(CXX) -o Coulomb.exe $(OBJECTS) $(LIBS)
define cc-command
$(CXX) -o $@ -c $< $(CFLAGS)
endef
define depend-command
$(CXX) -MM -MF $(patsubst %.o,%.d,$@) $< $(CFLAGS)
endef
data/%.o: ../src/data/%.cxx
$(depend-command)
$(cc-command)
%.o: ../src/%.cxx
$(depend-command)
$(cc-command)
%.dll: ../%.dll
cp $< .
.phony: all clean
clean:
rm -rf *.exe
rm -rf *.o
rm -rf data/*.o
rm -rf *.d
rm -rf data/*.d
rm -rf *.dll
Unfortunately I still don't really know what I'm going to do with this set up yet. I'd appreciate any comments on the Makefile set up though.
Saturday, 4 August 2012
DuelFieldStars v1 release
I have decided that the DuelFieldStars project no-longer interests me.
Originally I was only going to implement the features it has now and everything else, that I did not implement, were extra things I added to my ambitions. So I am quite happy calling it here.
This has also given me opportunity to play with py2exe. I think in the future I will try to organise my project with py2exe in mind.
Windows distributable: https://github.com/downloads/Tarinaky/DuelFieldStars/duelfieldstars_win_v1.0.0.zip
Clone source (reqs. Python2.7 and Pygame): https://github.com/Tarinaky/DuelFieldStars/tarball/v1.0.0
I guess this means I need to look for a new project now...
Originally I was only going to implement the features it has now and everything else, that I did not implement, were extra things I added to my ambitions. So I am quite happy calling it here.
This has also given me opportunity to play with py2exe. I think in the future I will try to organise my project with py2exe in mind.
Windows distributable: https://github.com/downloads/Tarinaky/DuelFieldStars/duelfieldstars_win_v1.0.0.zip
Clone source (reqs. Python2.7 and Pygame): https://github.com/Tarinaky/DuelFieldStars/tarball/v1.0.0
I guess this means I need to look for a new project now...
Subscribe to:
Posts (Atom)