]> git.cworth.org Git - vogl/blobdiff - src/voglcommon/vogl_general_context_state.cpp
Add gl_pname_defs as non-generated file
[vogl] / src / voglcommon / vogl_general_context_state.cpp
index a6637daf3350dec7252d8f4f3f231bd80ecda3e5..94a71891d919d5790602bc04e8437133d7163024 100644 (file)
@@ -28,7 +28,7 @@
 #include "vogl_general_context_state.h"
 #include "vogl_console.h"
 
-#include "gl_pname_defs.inc"
+#include "gl_pname_defs.h"
 
 // TODO: Indexed versions of glGet's
 // TODO: Add GL4 types
@@ -278,10 +278,13 @@ public:
         m_can_use_glGetPointerv = (GL_ENTRYPOINT(glGetPointerv) != NULL) && !context_info.is_core_profile();
 
         m_max_texture_units = 0;
-        GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_TEXTURE_UNITS, &m_max_texture_units);
-
         m_max_texture_coords = 0;
-        GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_TEXTURE_COORDS, &m_max_texture_coords);
+
+        if (!context_info.is_core_profile())
+        {
+            GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_TEXTURE_UNITS, &m_max_texture_units);
+            GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_TEXTURE_COORDS, &m_max_texture_coords);
+        }
 
         m_max_combined_texture_coords = 0;
         GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &m_max_combined_texture_coords);
@@ -294,6 +297,8 @@ public:
 
         m_max_vertex_attribs = 0;
         GL_ENTRYPOINT(glGetIntegerv)(GL_MAX_VERTEX_ATTRIBS, &m_max_vertex_attribs);
+
+        VOGL_CHECK_GL_ERROR;
     }
 
     bool m_can_use_glGetBooleani_v;
@@ -941,7 +946,10 @@ bool vogl_general_context_state::restore(const vogl_context_info &context_info,
 #endif
 
     GLint prev_client_active_texture = 0;
-    GL_ENTRYPOINT(glGetIntegerv)(GL_CLIENT_ACTIVE_TEXTURE, &prev_client_active_texture);
+    if (!context_info.is_core_profile())
+    {
+        GL_ENTRYPOINT(glGetIntegerv)(GL_CLIENT_ACTIVE_TEXTURE, &prev_client_active_texture);
+    }
 
     GLint prev_active_texture = 0;
     GL_ENTRYPOINT(glGetIntegerv)(GL_ACTIVE_TEXTURE, &prev_active_texture);
@@ -2622,8 +2630,10 @@ bool vogl_polygon_stipple_state::snapshot(const vogl_context_info &context_info)
 
     clear();
 
-    GL_ENTRYPOINT(glGetPolygonStipple)(reinterpret_cast<GLubyte *>(m_pattern));
+    vogl_scoped_state_saver pixelstore_state_saver(cGSTPixelStore);
+    vogl_reset_pixel_store_states();
 
+    GL_ENTRYPOINT(glGetPolygonStipple)(m_pattern);
     VOGL_CHECK_GL_ERROR;
 
     m_valid = true;
@@ -2642,8 +2652,10 @@ bool vogl_polygon_stipple_state::restore(const vogl_context_info &context_info)
 
     VOGL_CHECK_GL_ERROR;
 
-    GL_ENTRYPOINT(glPolygonStipple)(reinterpret_cast<const GLubyte *>(m_pattern));
+    vogl_scoped_state_saver pixelstore_state_saver(cGSTPixelStore);
+    vogl_reset_pixel_store_states();
 
+    GL_ENTRYPOINT(glPolygonStipple)(m_pattern);
     VOGL_CHECK_GL_ERROR;
 
     return true;
@@ -2667,7 +2679,7 @@ bool vogl_polygon_stipple_state::serialize(json_node &node, vogl_blob_manager &b
         return false;
 
     json_node &arr_node = node.add_array("pattern");
-    for (uint i = 0; i < 32; i++)
+    for (uint i = 0; i < VOGL_ARRAY_SIZE(m_pattern); i++)
         arr_node.add_value(m_pattern[i]);
 
     return true;
@@ -2685,11 +2697,19 @@ bool vogl_polygon_stipple_state::deserialize(const json_node &node, const vogl_b
     if (!pArr_node)
         return false;
 
-    if ((pArr_node->size() != 32) || (!pArr_node->are_all_children_values()))
+    if (!pArr_node->are_all_children_values())
         return false;
 
-    for (uint i = 0; i < 32; i++)
-        m_pattern[i] = pArr_node->value_as_uint32(i);
+    // An earlier version wrote the wrong size, so ignore that data.
+    if (pArr_node->size() == VOGL_ARRAY_SIZE(m_pattern))
+    {
+        for (uint i = 0; i < VOGL_ARRAY_SIZE(m_pattern); i++)
+            m_pattern[i] = static_cast<uint8>(pArr_node->value_as_uint32(i));
+    }
+    else
+    {
+        vogl_warning_printf("%s: Polygon stipple data is not valid in this older trace file so it's being ignored - please recapture (sorry)\n", VOGL_METHOD_NAME);
+    }
 
     m_valid = true;
 
@@ -2701,8 +2721,9 @@ uint vogl_polygon_stipple_state::get_num_pattern_rows() const
     return 32;
 }
 
-uint32 vogl_polygon_stipple_state::get_pattern_row(uint rowIndex) const
+uint32 vogl_polygon_stipple_state::get_pattern_row(uint row_index) const
 {
-    VOGL_ASSERT(rowIndex < 32);
-    return m_pattern[rowIndex];
+    VOGL_ASSERT(row_index < 32);
+
+    return m_pattern[4 * row_index] | (m_pattern[4 * row_index + 1] << 8U) | (m_pattern[4 * row_index + 2] << 16U) | (m_pattern[4 * row_index + 3] << 24U);
 }