소스 검색

Merge branch 'master' into piaf_integration

Dan Elkouby 10 년 전
부모
커밋
9fe3dd05f8
7개의 변경된 파일91개의 추가작업 그리고 40개의 파일을 삭제
  1. 2 32
      .ycm_extra_conf.py
  2. 1 1
      external/tinystl
  3. 1 0
      platform/include/Graphics.h
  4. 37 0
      platform/nspire/Graphics.cpp
  5. 1 0
      platform/nspire/rules.mk
  6. 46 4
      platform/sfml/Graphics.cpp
  7. 3 3
      rules.mk

+ 2 - 32
.ycm_extra_conf.py

@@ -35,38 +35,8 @@ import subprocess
 # These are the compilation flags that will be used in case there's no
 # compilation database set (by default, one is not set).
 # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
-flags = [
-'-Wall',
-'-Wextra',
-#'-Werror',
-'-Wno-long-long',
-'-Wno-variadic-macros',
-'-fexceptions',
-'-DNDEBUG',
-'-m32',
-# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
-# source code needs it.
-'-DUSE_CLANG_COMPLETER',
-# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
-# language to use when compiling headers. So it will guess. Badly. So C++
-# headers will be compiled as C headers. You don't want that so ALWAYS specify
-# a "-std=<something>".
-# For a C project, you would set this to something like 'c99' instead of
-# 'c++11'.
-'-std=c++11',
-# ...and the same thing goes for the magic -x option which specifies the
-# language that the files to be compiled are written in. This is mostly
-# relevant for c++ headers.
-# For a C project, you would set this to 'c' instead of 'c++'.
-'-x',
-'c++',
-'-isystem',
-os.environ['NDLESS_GIT'] + '/ndless-sdk/include',
-'-isystem',
-os.environ['HOME'] + '/.ndless/include',
-]
-
-flags += subprocess.check_output(["make", "include"]).split(" ")
+flags = ['-x', 'c++']
+flags += subprocess.check_output(["make", "cflags"]).split(" ")
 
 
 # Set this to the absolute path to the folder (NOT the file!) containing the

+ 1 - 1
external/tinystl

@@ -1 +1 @@
-Subproject commit e81f939b28d82ee7436dca6ea6357b981aa99e1a
+Subproject commit f2bc39cbc7c758d3440ddc5fba88b69f132a0d5f

+ 1 - 0
platform/include/Graphics.h

@@ -36,6 +36,7 @@ namespace WalrusRPG
         void put_sprite(const WalrusRPG::Graphics::Texture &sheet, int x, int y,
                         const WalrusRPG::Utils::Rect &window);
 
+        void put_sprite_clipping(const Texture &sheet, int x, int y, const WalrusRPG::Utils::Rect &sprite_window, const WalrusRPG::Utils::Rect &clipping_window);
         /*
          * Draws a sprite with clipping given as window and color
          * tinting.

+ 37 - 0
platform/nspire/Graphics.cpp

@@ -40,6 +40,43 @@ void Graphics::put_sprite_tint(const Texture &sheet, int x, int y, const Rect &w
     CXfb::draw_sprite_sheet_tint(sheet.data, x, y, window, color.value);
 }
 
+void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y, const Rect &sprite_window, const Rect &clipping_window)
+{
+    const signed &ss_x = sprite_window.x, ss_y = sprite_window.y;
+    const signed &ss_w = sprite_window.width, &ss_h = sprite_window.height;
+    const signed &cx = clipping_window.x, &cy = clipping_window.y; 
+    const signed &cw = clipping_window.width, &ch = clipping_window.height; 
+    const signed lx = x - cx, ly = y - cy;
+   
+    if(lx < -ss_w || lx > cw) return;
+    if(ly < -ss_h || ly > ch) return;
+
+    signed fx = x, fy = y;
+    signed fssx = ss_x, fssy = ss_y, fssw = ss_w, fssh = ss_h;
+   
+    if(lx < 0) {
+        fssw = ss_w+lx;
+        fssx = -lx;
+        fx = cx;
+    }
+
+    if(lx > cw - ss_w) {
+        fssw -= lx-(cw - ss_w);
+    }
+
+    if(ly > ch - ss_h) {
+        fssh -= ly-(ch - ss_h);
+    }
+
+    if(ly < 0) {
+        fssh = ss_h+ly;
+        fssy = -ly;
+        fy = cy;
+    }
+    
+    CXfb::draw_sprite_sheet(sheet.data, fx, fy, {fssx, fssy, fssw, fssh});
+}
+
 void Graphics::fill(const Pixel &color)
 {
     CXfb::buffer_fill(color);

+ 1 - 0
platform/nspire/rules.mk

@@ -5,6 +5,7 @@ SRCS_CPP += $(wildcard $(nspire_LOCAL_PATH)/*.cpp)
 INCLUDE += $(nspire_LOCAL_PATH)/public
 
 CFLAGS_COMMON += -marm -DNSPIRE=1
+YCM_EXTRA_CFLAGS := -m32 -I$(NDLESS_GIT)/ndless-sdk/include -I$(HOME)/.ndless/include
 
 CC = nspire-gcc
 CPP = nspire-g++

+ 46 - 4
platform/sfml/Graphics.cpp

@@ -74,16 +74,58 @@ void Graphics::put_sprite_tint(const WalrusRPG::Graphics::Texture &sheet, int x,
     buffer.draw(sprite);
 }
 
+void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y, const Rect &sprite_window, const Rect &clipping_window)
+{
+    const signed &ss_x = sprite_window.x, ss_y = sprite_window.y;
+    const signed &ss_w = sprite_window.width, &ss_h = sprite_window.height;
+    const signed &cx = clipping_window.x, &cy = clipping_window.y; 
+    const signed &cw = clipping_window.width, &ch = clipping_window.height; 
+    const signed lx = x - cx, ly = y - cy;
+   
+    if(lx < -ss_w || lx > cw) return;
+    if(ly < -ss_h || ly > ch) return;
+
+    signed fx = x, fy = y;
+    signed fssx = ss_x, fssy = ss_y, fssw = ss_w, fssh = ss_h;
+   
+    if(lx < 0) {
+        fssw = ss_w+lx;
+        fssx = -lx;
+        fx = cx;
+    }
+
+    if(lx > cw - ss_w) {
+        fssw -= lx-(cw - ss_w);
+    }
+
+    if(ly > ch - ss_h) {
+        fssh -= ly-(ch - ss_h);
+    }
+
+    if(ly < 0) {
+        fssh = ss_h+ly;
+        fssy = -ly;
+        fy = cy;
+    }
+
+    sf::Sprite sprite;
+    sprite.setTexture(sheet.data);
+    sprite.setTextureRect(sf::IntRect(fssx, fssy, fssw, fssh));
+    sprite.setPosition(fx, fy);
+    buffer.draw(sprite);
+}
+
+    
 void Graphics::fill(const Pixel &color)
 {
-    buffer.clear(sf::Color(color.r << 3, color.g << 2, color.b << 2, 255));
+    buffer.clear(sf::Color(color.r << 3, color.g << 2, color.b << 3, 255));
 }
 
 void Graphics::put_pixel(uint16_t x, uint16_t y, const Pixel &color)
 {
     sf::RectangleShape pixel;
     pixel.setSize(sf::Vector2f(1, 1));
-    pixel.setFillColor(sf::Color(color.r << 3, color.g << 2, color.b << 3));
+    pixel.setFillColor(sf::Color(color.r << 3, color.g << 2, color.b << 3, 255));
     pixel.setPosition(x, y);
     buffer.draw(pixel);
 }
@@ -102,7 +144,7 @@ void Graphics::put_vertical_line(uint16_t x, uint16_t y, uint16_t y2, const Pixe
 void Graphics::put_line(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2,
                         const Pixel &color)
 {
-    sf::Color lineColor(color.r << 3, color.g << 2, color.b << 3);
+    sf::Color lineColor(color.r << 3, color.g << 2, color.b << 3, 255);
     sf::Vertex line[] = {sf::Vertex(sf::Vector2f(x, y), lineColor),
                          sf::Vertex(sf::Vector2f(x2+1, y2+1), lineColor)};
 
@@ -113,7 +155,7 @@ void Graphics::put_rectangle(const Rect &rect, const Pixel &color)
 {
     sf::RectangleShape rectangle;
     rectangle.setSize(sf::Vector2f(rect.width, rect.height));
-    rectangle.setFillColor(sf::Color(color.r << 3, color.g << 2, color.b << 3));
+    rectangle.setFillColor(sf::Color(color.r << 3, color.g << 2, color.b << 3, 255));
     rectangle.setPosition(rect.x, rect.y);
     buffer.draw(rectangle);
 }

+ 3 - 3
rules.mk

@@ -1,4 +1,4 @@
-.PHONY: format clean all run versionning include release bundle
+.PHONY: format clean all run versionning cflags release bundle
 
 all: $(EXE)
 
@@ -61,7 +61,7 @@ format:
 	@echo "Formatting source using clang-format"
 	@clang-format -i -style=file $(shell git ls-files -c -o --exclude-standard *.c *.cpp *.h)
 
-include:
-	@echo -n $(addprefix -I ,$(INCLUDE) $(INCLUDE_EXT))
+cflags:
+	@echo -n $(CPPFLAGS) $(YCM_EXTRA_CFLAGS)
 
 .FORCE: