This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Surface* flip_vertical(SDL_Surface* sfc) { | |
SDL_Surface* result = SDL_CreateRGBSurface(sfc->flags, sfc->w, sfc->h, | |
sfc->format->BytesPerPixel * 8, sfc->format->Rmask, sfc->format->Gmask, | |
sfc->format->Bmask, sfc->format->Amask); | |
const auto pitch = sfc->pitch; | |
const auto pxlength = pitch*(sfc->h - 1); | |
auto pixels = static_cast<unsigned char*>(sfc->pixels) + pxlength; | |
auto rpixels = static_cast<unsigned char*>(result->pixels) ; | |
for(auto line = 0; line < sfc->h; ++line) { | |
memcpy(rpixels,pixels,pitch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename elemT, size_t m_columns, size_t n_rows > | |
class Heightmap { | |
public: | |
typedef std::array<elemT, n_rows * m_columns> container_t; | |
const container_t& elems() const {return _elems;} | |
container_t& elems() {return _elems;} | |
const elemT& operator() (size_t c, size_t r) const { | |
check_range(c,r); return _elems.at(r * n_rows + c);} | |
elemT& operator() (size_t c, size_t r) { | |
check_range(c,r);return _elems.at(r * n_rows + c);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.eclipse.jface.viewers.*; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.custom.StyleRange; | |
import org.eclipse.swt.events.*; | |
import org.eclipse.swt.graphics.Point; | |
import org.eclipse.swt.graphics.Rectangle; | |
import org.eclipse.swt.layout.FillLayout; | |
import org.eclipse.swt.widgets.Display; | |
import org.eclipse.swt.widgets.Event; | |
import org.eclipse.swt.widgets.Shell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graph3; | |
size(10cm,0); | |
currentprojection=perspective(0,100,0); | |
real h_0 = 0.357; | |
real h_1 = 0.956; | |
real w_0 = 0.7; | |
real w_1 = 0.547; | |
real t_0 = 0.367; |