› Foros › Multiplataforma › Desarrollo
while(1){
SDL_SetRenderDrawColor( gRenderer, 255,0,0,255);
SDL_RenderFillRect( gRenderer, &fillRect );
SDL_RenderPresent( gRenderer );
}
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
//Screen dimension constants
enum {
SCREEN_WIDTH = 1920,
SCREEN_HEIGHT = 1080
};
SDL_Window * gWindow = NULL;
SDL_Renderer * gRenderer = NULL;
SDL_Rect fillRect = { SCREEN_WIDTH / 4,
SCREEN_HEIGHT / 4,
SCREEN_WIDTH / 2,
SCREEN_HEIGHT / 2
};
int main(int argc, char *argv[])
{
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
return -1;
if ((gWindow = SDL_CreateWindow( "RedRectangle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN)) == NULL)
return -1;
if ((gRenderer = SDL_CreateRenderer( gWindow, -1, 0)) == NULL)
return -1;
SDL_SetRenderDrawColor( gRenderer, 255,0,0,255);
SDL_RenderFillRect( gRenderer, &fillRect );
SDL_RenderPresent( gRenderer );
SDL_Delay(4000);
SDL_DestroyRenderer( gRenderer );
SDL_DestroyWindow( gWindow );
gWindow = NULL;
gRenderer = NULL;
SDL_Quit();
return 0;
}
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(PSL1GHT)),)
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
endif
include $(PSL1GHT)/ppu_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := .
DATA := data
INCLUDES := include
PKGFILES := $(CURDIR)/pkgfiles
TITLE := PRUEBA - SDL2
APPID := SPRITE2D1
CONTENTID := UP0001-$(APPID)_00-0000000000000000
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := `sdl2-config --cflags --libs` -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
export BUILDDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))
PNGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.png)))
JPGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.jpg)))
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg)))
FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(addsuffix .o,$(TTFFILES)) \
$(addsuffix .o,$(VPOFILES)) \
$(addsuffix .o,$(FPOFILES)) \
$(addsuffix .o,$(PNGFILES)) \
$(addsuffix .o,$(JPGFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := -I$(PORTLIBS)/include/freetype2 \
$(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(LIBPSL1GHT_INC) \
-I$(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
$(LIBPSL1GHT_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
$ make pkg
main.c
linking ... pruebaSDL.elf
CEX self ... pruebaSDL.self
ELF header size @ 40
8 program headers @ 40
24 section headers @ 203ae0
deflated...processing segment 0 with rlen 1cc22c len 40afc offset 0...encrypted...
deflated...processing segment 1 with rlen 100c8 len 4628 offset 1d0000...encrypted...
deflated...processing segment 2 with rlen 9e9c len 34d9 offset 1f0000...encrypted...
deflated...processing segment 3 with rlen 39f8 len aad offset 200000...encrypted...
processing segment 4 with rlen 0 len 0 offset 2039f8...encrypted...
processing segment 5 with rlen 0 len 0 offset 1e00c8...encrypted...
processing segment 6 with rlen 0 len 0 offset 0...encrypted...
deflated...processing segment 7 with rlen 28 len 22 offset 1cc204...encrypted...
segments enumerated
built crypt data
file built
self written in memory
building pkg ... pruebaSDL.pkg
[b][/b]
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) *.elf *.self *.pkg
#---------------------------------------------------------------------------------
run:
ps3load $(OUTPUT).self
#---------------------------------------------------------------------------------
pkg: $(BUILD) $(OUTPUT).pkg
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).self: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.vpo.o : %.vpo
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2$ make pkg
main.c
linking ... pruebaSDL.elf
CEX self ... pruebaSDL.self
ELF header size @ 40
8 program headers @ 40
24 section headers @ 203ae0
deflated...processing segment 0 with rlen 1cc22c len 40afc offset 0...encrypted...
deflated...processing segment 1 with rlen 100c8 len 4628 offset 1d0000...encrypted...
deflated...processing segment 2 with rlen 9e9c len 34d9 offset 1f0000...encrypted...
deflated...processing segment 3 with rlen 39f8 len aad offset 200000...encrypted...
processing segment 4 with rlen 0 len 0 offset 2039f8...encrypted...
processing segment 5 with rlen 0 len 0 offset 1e00c8...encrypted...
processing segment 6 with rlen 0 len 0 offset 0...encrypted...
deflated...processing segment 7 with rlen 28 len 22 offset 1cc204...encrypted...
segments enumerated
built crypt data
file built
self written in memory
building pkg ... pruebaSDL.pkg
o)
#---------------------------------------------------------------------------------
%.fpo.o : %.fpo
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.png.o : %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
$ make pkg
main.c
linking ... pruebaSDL.elf
CEX self ... pruebaSDL.self
ELF header size @ 40
8 program headers @ 40
24 section headers @ 203ae0
deflated...processing segment 0 with rlen 1cc22c len 40afc offset 0...encrypted...
deflated...processing segment 1 with rlen 100c8 len 4628 offset 1d0000...encrypted...
deflated...processing segment 2 with rlen 9e9c len 34d9 offset 1f0000...encrypted...
deflated...processing segment 3 with rlen 39f8 len aad offset 200000...encrypted...
processing segment 4 with rlen 0 len 0 offset 2039f8...encrypted...
processing segment 5 with rlen 0 len 0 offset 1e00c8...encrypted...
processing segment 6 with rlen 0 len 0 offset 0...encrypted...
deflated...processing segment 7 with rlen 28 len 22 offset 1cc204...encrypted...
segments enumerated
built crypt data
file built
self written in memory
building pkg ... pruebaSDL.pkg