Changeset 1068


Ignore:
Timestamp:
Nov 14, 2011, 11:37:42 PM (12 years ago)
Author:
sam
Message:

tutorial: try to send data to the GPU that matches the internal format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/tutorial/tut03.cpp

    r1067 r1068  
    5656            float f = i / (double)PALETTE_STEP;
    5757
    58             double r = 0.5 * sin(f * 0.27 - 1.5) + 0.5;
    59             double g = 0.5 * sin(f * 0.13 + 1.3) + 0.5;
     58            double r = 0.5 * sin(f * 0.27 - 2.5) + 0.5;
     59            double g = 0.5 * sin(f * 0.13 + 1.1) + 0.5;
    6060            double b = 0.5 * sin(f * 0.21 + 0.4) + 0.5;
    6161
     
    6363            uint8_t green = g * 255.0f;
    6464            uint8_t blue = b * 255.0f;
    65             m_palette[i] = u8vec4(red, green, blue, 0);
     65            m_palette[i] = u8vec4(blue, green, red, 0);
    6666        }
    6767
     
    115115            f64cmplx oldcenter = m_center;
    116116            double oldradius = m_radius;
    117             double zoom = pow(2.0, (buttons[0] ? -deltams : deltams) * 0.0015);
     117            double zoom = pow(2.0, (buttons[0] ? -deltams : deltams) * 0.0025);
    118118            if (m_radius * zoom > 8.0)
    119119                zoom = 8.0 / m_radius;
     
    224224            glBindTexture(GL_TEXTURE_2D, m_texid);
    225225            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_size.x / 2, m_size.y * 2,
    226                          0, GL_RGBA, GL_UNSIGNED_BYTE, m_pixels);
     226                         0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_pixels);
    227227            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    228228            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     
    304304            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, m_frame * m_size.y / 2,
    305305                            m_size.x / 2, m_size.y / 2,
    306 #if !defined __CELLOS_LV2__
    307                             GL_RGBA, GL_UNSIGNED_BYTE,
    308 #else
    309                             /* The PS3 is big-endian */
    310                             GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
    311 #endif
     306                            GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
    312307                            m_pixels + m_size.x * m_size.y / 4 * m_frame);
    313308        }
     
    320315            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i * m_size.y / 2,
    321316                            m_size.x / 2, m_size.y / 2,
    322 #if !defined __CELLOS_LV2__
    323                             GL_RGBA, GL_UNSIGNED_BYTE,
    324 #else
    325                             /* The PS3 is big-endian */
    326                             GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
    327 #endif
     317                            GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
    328318                            m_pixels + m_size.x * m_size.y / 4 * m_frame);
    329319    }
Note: See TracChangeset for help on using the changeset viewer.