コード例 #1
0
ファイル: Image.cpp プロジェクト: jamescleaveland/Flame
void Png<ColorRGBf>::PutPixel(int x, int y, const ColorRGBAf& c)
{
  if (x < 0 || x >= m_width || y < 0 || y >= m_height)
    return;

  m_rawPixels[y][x] = ColorRGBf(c.r, c.g, c.b);
}
コード例 #2
0
ファイル: Cre8Render.cpp プロジェクト: xoorath/cre8
  void Cre8Render::InitializeLambdas()
  {
    // Here we provide the fetch methods for these variables. We will only need to fetch the values if they're requested.
    MultiTexturingSupported.SetMethod(  [](c8bool& out) {       out = GLEW_ARB_multitexture;});
    VersionMinor.SetMethod(             [](si32& out) {         glGetIntegerv(GL_MINOR_VERSION, &out); });
    VersionMajor.SetMethod(             [](si32& out) {         glGetIntegerv(GL_MAJOR_VERSION, &out); });
    MaxTextureUnits.SetMethod(          [](si32& out) {         glGetIntegerv(GL_MAX_TEXTURE_UNITS, &out); });
    MaxTextureSize.SetMethod(           [](si32& out) {         glGetIntegerv(GL_MAX_TEXTURE_SIZE, &out); });
    GLSLVersion.SetMethod(              [](const char*& out) {  out = (char*)glGetString(GL_SHADING_LANGUAGE_VERSION); });
    GLEWVersion.SetMethod(              [](const char*& out) {  out = (char*)glewGetString(GLEW_VERSION); });

    m_Textures = new Cre8RenderValue<tTextureID>[MaxTextureUnits.GetValue()];

    Cre8RenderValue<tTextureID>* a = &m_Textures[0];
    Cre8RenderValue<tTextureID>* b = &m_Textures[1];
    Cre8RenderValue<tTextureID>* c = &m_Textures[2];

    for(si32 i = 0; i < MaxTextureUnits.GetValue(); ++i)
    {
      const int ci = i;
      auto textureFunc = [ci](const tTextureID& val) 
      {
        if(g_Cre8Render->MultiTexturingSupported == true)
        {
          glActiveTextureARB(GL_TEXTURE0_ARB + ci);
          glEnable(GL_ARB_texture_non_power_of_two);
          glBindTexture(GL_ARB_texture_non_power_of_two, val);
        }
        else
        {
          glBindTexture(GL_TEXTURE_2D, val);
        }
      };
      m_Textures[i].SetMethod(0, textureFunc);
    }

    ClearAccum.SetMethod(ColorRGBf(0, 0, 0),  [](const ColorRGBf& val) {  glClearAccum(val[0], val[1], val[2], 1.f); });
    ClearColor.SetMethod(ColorRGBf(0, 0, 0),  [](const ColorRGBf& val) {  glClearColor(val[0], val[1], val[2], 1.f); });
    ClearDepth.SetMethod(1.f,                 [](const r32& val) {        glClearDepth((double)val); });
    ClearIndex.SetMethod(1.f,                 [](const r32& val) {        glClearIndex(val); });
    ClearStencil.SetMethod(0,                 [](const si32& val) {       glClearStencil(val); });
    
    EnableAttribute.AlphaTest.SetMethod(false,            enableBitLambda(GL_ALPHA_TEST));
    EnableAttribute.AutoNormal.SetMethod(false,           enableBitLambda(GL_AUTO_NORMAL));
    EnableAttribute.Blend.SetMethod(false,                enableBitLambda(GL_BLEND));
    EnableAttribute.colorMaterial.SetMethod(false,        enableBitLambda(GL_COLOR_MATERIAL));
    EnableAttribute.CullFace.SetMethod(false,             enableBitLambda(GL_CULL_FACE));
    EnableAttribute.DepthTest.SetMethod(false,            enableBitLambda(GL_DEPTH_TEST));
    EnableAttribute.Dither.SetMethod(false,               enableBitLambda(GL_DITHER));
    EnableAttribute.Fog.SetMethod(false,                  enableBitLambda(GL_FOG));
    EnableAttribute.Lighting.SetMethod(false,             enableBitLambda(GL_LIGHTING));
    EnableAttribute.LineSmooth.SetMethod(false,           enableBitLambda(GL_LINE_SMOOTH));
    EnableAttribute.LineStipple.SetMethod(false,          enableBitLambda(GL_LINE_STIPPLE));
    EnableAttribute.ColorLogicOp.SetMethod(false,         enableBitLambda(GL_COLOR_LOGIC_OP));
    EnableAttribute.IndexLogicOp.SetMethod(false,         enableBitLambda(GL_INDEX_LOGIC_OP));
    EnableAttribute.Normalize.SetMethod(false,            enableBitLambda(GL_NORMALIZE));
    EnableAttribute.PointSmooth.SetMethod(false,          enableBitLambda(GL_POINT_SMOOTH));
    EnableAttribute.PolygonOffsetLine.SetMethod(false,    enableBitLambda(GL_POLYGON_OFFSET_LINE));
    EnableAttribute.PolygonOffsetFill.SetMethod(false,    enableBitLambda(GL_POLYGON_OFFSET_FILL));
    EnableAttribute.PolygonOffsetPoint.SetMethod(false,   enableBitLambda(GL_POLYGON_OFFSET_POINT));
    EnableAttribute.PolygonSmooth.SetMethod(false,        enableBitLambda(GL_POLYGON_SMOOTH));
    EnableAttribute.PolygonStipple.SetMethod(false,       enableBitLambda(GL_POLYGON_STIPPLE));
    EnableAttribute.ScissorTest.SetMethod(false,          enableBitLambda(GL_SCISSOR_TEST));
    EnableAttribute.StencilTest.SetMethod(false,          enableBitLambda(GL_STENCIL_TEST));
    EnableAttribute.Texture1d.SetMethod(false,            enableBitLambda(GL_TEXTURE_1D));
    EnableAttribute.Texture2d.SetMethod(false,            enableBitLambda(GL_TEXTURE_2D));
  }