LCOV - code coverage report
Current view: top level - Core - OODebugGLDrawing.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 8 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OODebugDrawing.m
       4             : 
       5             : 
       6             : Copyright (C) 2007-2013 Jens Ayton and contributors
       7             : 
       8             : Permission is hereby granted, free of charge, to any person obtaining a copy
       9             : of this software and associated documentation files (the "Software"), to deal
      10             : in the Software without restriction, including without limitation the rights
      11             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      12             : copies of the Software, and to permit persons to whom the Software is
      13             : furnished to do so, subject to the following conditions:
      14             : 
      15             : The above copyright notice and this permission notice shall be included in all
      16             : copies or substantial portions of the Software.
      17             : 
      18             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      19             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      20             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      21             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      22             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      23             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      24             : SOFTWARE.
      25             : 
      26             : */
      27             : 
      28             : #import "OODebugGLDrawing.h"
      29             : #import "OOMacroOpenGL.h"
      30             : #import "OOMaterial.h"
      31             : 
      32             : 
      33             : #ifndef OODEBUGLDRAWING_DISABLE
      34             : 
      35           0 : OOINLINE void ApplyColor(OOColor *color)
      36             : {
      37             :         GLfloat                         r, g, b, a;
      38             :         
      39             :         OO_ENTER_OPENGL();
      40             :         
      41             :         if (EXPECT_NOT(color == nil))  color = [OOColor lightGrayColor];
      42             :         [color getRed:&r green:&g blue:&b alpha:&a];
      43             :         OOGL(glColor4f(r, g, b, a));
      44             : }
      45             : 
      46             : 
      47           0 : void OODebugDrawColoredBoundingBoxBetween(Vector min, Vector max, OOColor *color)
      48             : {
      49             :         OODebugWFState state = OODebugBeginWireframe(YES);
      50             :         OO_ENTER_OPENGL();
      51             :         
      52             :         ApplyColor(color);
      53             :         OOGLBEGIN(GL_LINE_LOOP);
      54             :                 glVertex3f(min.x, min.y, min.z);
      55             :                 glVertex3f(max.x, min.y, min.z);
      56             :                 glVertex3f(max.x, max.y, min.z);
      57             :                 glVertex3f(min.x, max.y, min.z);
      58             :                 glVertex3f(min.x, max.y, max.z);
      59             :                 glVertex3f(max.x, max.y, max.z);
      60             :                 glVertex3f(max.x, min.y, max.z);
      61             :                 glVertex3f(min.x, min.y, max.z);
      62             :         OOGLEND();
      63             :         OOGLBEGIN(GL_LINES);
      64             :                 glVertex3f(max.x, min.y, min.z);
      65             :                 glVertex3f(max.x, min.y, max.z);
      66             :                 glVertex3f(max.x, max.y, min.z);
      67             :                 glVertex3f(max.x, max.y, max.z);
      68             :                 glVertex3f(min.x, min.y, min.z);
      69             :                 glVertex3f(min.x, max.y, min.z);
      70             :                 glVertex3f(min.x, min.y, max.z);
      71             :                 glVertex3f(min.x, max.y, max.z);
      72             :         OOGLEND();
      73             :         
      74             :         OODebugEndWireframe(state);
      75             : }
      76             : 
      77             : 
      78           0 : void OODebugDrawColoredLine(Vector start, Vector end, OOColor *color)
      79             : {       
      80             :         OODebugWFState state = OODebugBeginWireframe(YES);
      81             :         OO_ENTER_OPENGL();
      82             :         
      83             :         ApplyColor(color);
      84             :         
      85             :         OOGLBEGIN(GL_LINES);
      86             :                 glVertex3f(start.x, start.y, start.z);
      87             :                 glVertex3f(end.x, end.y, end.z);
      88             :         OOGLEND();
      89             :         
      90             :         OODebugEndWireframe(state);
      91             : }
      92             : 
      93             : 
      94           0 : void OODebugDrawBasis(Vector position, GLfloat scale)
      95             : {
      96             :         OODebugWFState state = OODebugBeginWireframe(YES);
      97             :         OO_ENTER_OPENGL();
      98             :         
      99             :         OOGLBEGIN(GL_LINES);
     100             :                 glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
     101             :                 glVertex3f(position.x, position.y, position.z);
     102             :                 glVertex3f(position.x + scale, position.y, position.z);
     103             :                 
     104             :                 glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
     105             :                 glVertex3f(position.x, position.y, position.z);
     106             :                 glVertex3f(position.x, position.y + scale, position.z);
     107             :                 
     108             :                 glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
     109             :                 glVertex3f(position.x, position.y, position.z);
     110             :                 glVertex3f(position.x, position.y, position.z + scale);
     111             :         OOGLEND();
     112             :         
     113             :         OODebugEndWireframe(state);
     114             : }
     115             : 
     116             : 
     117           0 : void OODebugDrawPoint(Vector position, OOColor *color)
     118             : {
     119             :         OODebugWFState state = OODebugBeginWireframe(YES);
     120             :         OO_ENTER_OPENGL();
     121             :         
     122             :         ApplyColor(color);
     123             :         OOGL(GLScaledPointSize(10));
     124             :         
     125             :         OOGLBEGIN(GL_POINTS);
     126             :                 glVertex3f(position.x, position.y, position.z);
     127             :         OOGLEND();
     128             :         
     129             :         OODebugEndWireframe(state);
     130             : }
     131             : 
     132             : 
     133           0 : OODebugWFState OODebugBeginWireframe(BOOL ignoreZ)
     134             : {
     135             :         OO_ENTER_OPENGL();
     136             :         
     137             :         OODebugWFState state = { .material = [OOMaterial current] };
     138             :         [OOMaterial applyNone];
     139             :         
     140             :         OOGL(glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_LINE_BIT | GL_POINT_BIT | GL_CURRENT_BIT));
     141             :         
     142             :         OOGL(glDisable(GL_LIGHTING));
     143             :         OOGL(glDisable(GL_TEXTURE_2D));
     144             :         OOGL(glDisable(GL_FOG));
     145             :         if (ignoreZ)
     146             :         {
     147             :                 OOGL(glDisable(GL_DEPTH_TEST));
     148             :                 OOGL(glDepthMask(GL_FALSE));
     149             :         }
     150             :         else
     151             :         {
     152             :                 OOGL(glEnable(GL_DEPTH_TEST));
     153             :                 OOGL(glDepthMask(GL_TRUE));
     154             :         }
     155             :         
     156             :         OOGL(GLScaledLineWidth(1.0f));
     157             :         
     158             :         return state;
     159             : }
     160             : 
     161             : 
     162           0 : void OODebugEndWireframe(OODebugWFState state)
     163             : {
     164             :         OO_ENTER_OPENGL();
     165             :         OOGL(glPopAttrib());
     166             :         [state.material apply];
     167             : }
     168             : 
     169             : #endif

Generated by: LCOV version 1.14