VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c@ 78402

Last change on this file since 78402 was 78375, checked in by vboxsync, 6 years ago

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 1.8 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "state/cr_statetypes.h"
8#include "state/cr_stateerror.h"
9#include "state.h"
10#include "cr_error.h"
11#include <stdarg.h>
12#include <stdio.h>
13
14#include <iprt/env.h>
15
16void crStateError(PCRStateTracker pState, int line, const char *file, GLenum error, const char *format, ... )
17{
18 CRContext *g = GetCurrentContext(pState);
19 char errstr[8096];
20 va_list args;
21
22 CRASSERT(error != GL_NO_ERROR);
23
24 if (g->error == GL_NO_ERROR)
25 g->error = error;
26
27#ifndef DEBUG_misha
28 if (RTEnvExist("CR_DEBUG"))
29#endif
30 {
31 char *glerr;
32 va_start( args, format );
33 vsprintf( errstr, format, args );
34 va_end( args );
35
36 switch (error) {
37 case GL_NO_ERROR:
38 glerr = "GL_NO_ERROR";
39 break;
40 case GL_INVALID_VALUE:
41 glerr = "GL_INVALID_VALUE";
42 break;
43 case GL_INVALID_ENUM:
44 glerr = "GL_INVALID_ENUM";
45 break;
46 case GL_INVALID_OPERATION:
47 glerr = "GL_INVALID_OPERATION";
48 break;
49 case GL_STACK_OVERFLOW:
50 glerr = "GL_STACK_OVERFLOW";
51 break;
52 case GL_STACK_UNDERFLOW:
53 glerr = "GL_STACK_UNDERFLOW";
54 break;
55 case GL_OUT_OF_MEMORY:
56 glerr = "GL_OUT_OF_MEMORY";
57 break;
58 case GL_TABLE_TOO_LARGE:
59 glerr = "GL_TABLE_TOO_LARGE";
60 break;
61 default:
62 glerr = "unknown";
63 break;
64 }
65
66 crWarning( "OpenGL error in %s, line %d: %s: %s\n",
67 file, line, glerr, errstr );
68 }
69}
70
71
72GLenum STATE_APIENTRY crStateGetError(PCRStateTracker pState)
73{
74 CRContext *g = GetCurrentContext(pState);
75 GLenum e = g->error;
76
77 if (g->current.inBeginEnd)
78 {
79 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
80 "glStateGetError() called between glBegin/glEnd" );
81 return 0;
82 }
83
84 g->error = GL_NO_ERROR;
85
86 return e;
87}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette