- OpenGL Insights by Patrick Cozzi and Christophe Riccio
- OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3 (8th Edition) by
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
#define CONSTANTHASH_DEPTH 64 | |
// randomly generated constants. The bottom half has to be FFFF or | |
// else the entire hash loses some strength | |
static const size_t CONSTANTHASH_CONSTANTS[CONSTANTHASH_DEPTH+1] = | |
{ | |
0x6157FFFF, 0x5387FFFF, 0x8ECBFFFF, 0xB3DBFFFF, 0x1AFDFFFF, 0xD1FDFFFF, 0x19B3FFFF, 0xE6C7FFFF, | |
0x53BDFFFF, 0xCDAFFFFF, 0xE543FFFF, 0x369DFFFF, 0x8135FFFF, 0x50E1FFFF, 0x115BFFFF, 0x07D1FFFF, | |
0x9AA1FFFF, 0x4D87FFFF, 0x442BFFFF, 0xEAA5FFFF, 0xAEDBFFFF, 0xB6A5FFFF, 0xAFE9FFFF, 0xE895FFFF, | |
0x4E05FFFF, 0xF8BFFFFF, 0xCB5DFFFF, 0x2F85FFFF, 0xF1DFFFFF, 0xD5ADFFFF, 0x438DFFFF, 0x6073FFFF, |
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
// Simplified scope stack implementation | |
#include <new> | |
#include <cstdio> | |
#include <cassert> | |
typedef unsigned char u8; | |
class LinearAllocator { | |
public: |
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
#include <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <functional> | |
#include <tuple> | |
#include <type_traits> | |
#include <vector> | |
template< typename T > | |
using ParseResult = std::vector<std::tuple<T, std::string>>; |
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
protocol Num { | |
class func zero() -> Self | |
func succ() -> Self | |
func add(y: Self) -> Self | |
func multiply(y: Self) -> Self | |
} | |
extension Int32: Num { | |
static func zero() -> Int32 { return 0 } | |
func succ() -> Int32 { return self + 1 } |
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
protocol Monoid { | |
class func mzero() -> Self | |
func mop(y: Self) -> Self | |
} | |
func mconcat<M : Monoid>(t: Array<M>) -> M { | |
return (t.reduce(M.mzero()) { $0.mop($1) }) | |
} | |
protocol Num { |
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
// The DSL's implementation (i.e. just the applicative interface for Optionals + methods for creating tuples) | |
operator infix <*> { associativity left } | |
@infix func <*><A, B>(lhs: (A -> B)?, rhs: A?) -> B? { | |
switch lhs { | |
case .None: | |
return .None | |
case let .Some(f): | |
return rhs.map(f) | |
} | |
} |
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< unsigned SrcSize, unsigned DstSize > | |
static inline uint32_t signExtend(uint32_t x) | |
{ | |
static_assert(SrcSize <= 32, "SrcSize cannot be larger than 32 bits."); | |
static_assert(SrcSize <= 32, "DstSize cannot be larger than 32 bits."); | |
static_assert(SrcSize < DstSize, "DstSize must be larger than SrcSize."); | |
constexpr unsigned src_mask = (1 << SrcSize) - 1; | |
constexpr unsigned extension = ((1 << (DstSize - SrcSize)) - 1) << SrcSize; | |
uint32_t result = x & src_mask; | |
uint32_t is_signed = (x & (1 << (SrcSize - 1))) >> (SrcSize - 1); |
Probability notes (http://www.autonlab.org/tutorials/prob18.pdf):
========================
- "P(A)" means the probability that the event A will happen/A will be true.
- The core axioms
- 0 <= P(A) <= 1
- P(true) = 1
- P(false) = 0
- P(A or B) = P(A) + P(B) - P(A and B) Note: it seems that this is definition of or is the exclusive or.
- From the core axioms, we can derive:
=============================
- Lecture 1: The Geometry of Linear Equations
- The matrix A (whose columns are u, v, w) times the column vector x (whose components are c, d, e) is the same as the combination cu + dv + ew of the three columns.
- Lecture 2: Elimination with Matrices
- Elimination works by creating a triangular matrix, which for a system of 3 equations and three variables gives us a new system of 3 equations that has one equation with only one variable, another with two variables, and the last with three variables. This system can then be easily solved.
- Lecture 3: Multiplication and Inverse Matrices
- When multiply matrices, A*B=C, the element in the i-th row and j-th column of the resultant matrix, C, is calculated by taking the dot product of the i-th row of A with the j-th column of B.
- Another way to view matrix multiplication: in A*B=C, each column of C is a linear combination of the columns of A. e.g.
OlderNewer