summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHoe Hao Cheng <haochengho12907@gmail.com>2023-02-24 22:00:01 +0800
committerHoe Hao Cheng <haochengho12907@gmail.com>2023-03-03 21:08:59 +0800
commite10df65f555a7449bde9f082e6a0868d63933ba3 (patch)
treeefce2a716a5c8778e48ea013f46227f6ef2585fc /src
parente2fef121f975d2f07b28022587a3b4ee225154e8 (diff)
downloadmesa-demos-e10df65f555a7449bde9f082e6a0868d63933ba3.tar.gz
glinfo_common: remove wglinfo and glxinfo specific bits
This creates some code duplication in both tools as a result, but those code doesn't make sense for eglinfo. Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Diffstat (limited to 'src')
-rw-r--r--src/wgl/wglinfo.c63
-rw-r--r--src/xdemos/glinfo_common.c72
-rw-r--r--src/xdemos/glinfo_common.h17
-rw-r--r--src/xdemos/glxinfo.c79
4 files changed, 142 insertions, 89 deletions
diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c
index d543da23..a82418fb 100644
--- a/src/wgl/wglinfo.c
+++ b/src/wgl/wglinfo.c
@@ -58,6 +58,14 @@ struct format_info {
};
+struct options {
+ InfoMode mode;
+ GLboolean findBest;
+ GLboolean limits;
+ GLboolean singleLine;
+};
+
+
static LRESULT CALLBACK
WndProc(HWND hWnd,
UINT uMsg,
@@ -611,6 +619,61 @@ find_best_visual(HDC hdc)
}
+static void
+usage(void)
+{
+ printf("Usage: wglinfo [-v] [-t] [-h] [-b] [-l] [-s]\n");
+ printf("\t-B: brief output, print only the basics.\n");
+ printf("\t-v: Print visuals info in verbose form.\n");
+ printf("\t-t: Print verbose visual information table.\n");
+ printf("\t-h: This information.\n");
+ printf("\t-b: Find the 'best' visual and print its number.\n");
+ printf("\t-l: Print interesting OpenGL limits.\n");
+ printf("\t-s: Print a single extension per line.\n");
+}
+
+
+static void
+parse_args(int argc, char *argv[], struct options *options)
+{
+ int i;
+
+ options->mode = Normal;
+ options->findBest = GL_FALSE;
+ options->limits = GL_FALSE;
+ options->singleLine = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-t") == 0) {
+ options->mode = Wide;
+ }
+ else if (strcmp(argv[i], "-v") == 0) {
+ options->mode = Verbose;
+ }
+ else if (strcmp(argv[i], "-B") == 0) {
+ options->mode = Brief;
+ }
+ else if (strcmp(argv[i], "-b") == 0) {
+ options->findBest = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-l") == 0) {
+ options->limits = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-h") == 0) {
+ usage();
+ exit(0);
+ }
+ else if(strcmp(argv[i], "-s") == 0) {
+ options->singleLine = GL_TRUE;
+ }
+ else {
+ printf("Unknown option `%s'\n", argv[i]);
+ usage();
+ exit(0);
+ }
+ }
+}
+
int
main(int argc, char *argv[])
diff --git a/src/xdemos/glinfo_common.c b/src/xdemos/glinfo_common.c
index 82875e2f..eea9c58d 100644
--- a/src/xdemos/glinfo_common.c
+++ b/src/xdemos/glinfo_common.c
@@ -826,78 +826,6 @@ context_flags_string(int mask)
static void
-usage(void)
-{
-#ifdef _WIN32
- printf("Usage: wglinfo [-v] [-t] [-h] [-b] [-l] [-s]\n");
-#else
- printf("Usage: glxinfo [-v] [-t] [-h] [-b] [-l] [-s] [-i] [-display <dname>]\n");
- printf("\t-display <dname>: Print GLX visuals on specified server.\n");
- printf("\t-i: Force an indirect rendering context.\n");
-#endif
- printf("\t-B: brief output, print only the basics.\n");
- printf("\t-v: Print visuals info in verbose form.\n");
- printf("\t-t: Print verbose visual information table.\n");
- printf("\t-h: This information.\n");
- printf("\t-b: Find the 'best' visual and print its number.\n");
- printf("\t-l: Print interesting OpenGL limits.\n");
- printf("\t-s: Print a single extension per line.\n");
-}
-
-void
-parse_args(int argc, char *argv[], struct options *options)
-{
- int i;
-
- options->mode = Normal;
- options->findBest = GL_FALSE;
- options->limits = GL_FALSE;
- options->singleLine = GL_FALSE;
- options->displayName = NULL;
- options->allowDirect = GL_TRUE;
-
- for (i = 1; i < argc; i++) {
-#ifndef _WIN32
- if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
- options->displayName = argv[i + 1];
- i++;
- }
- else if (strcmp(argv[i], "-i") == 0) {
- options->allowDirect = GL_FALSE;
- }
- else
-#endif
- if (strcmp(argv[i], "-t") == 0) {
- options->mode = Wide;
- }
- else if (strcmp(argv[i], "-v") == 0) {
- options->mode = Verbose;
- }
- else if (strcmp(argv[i], "-B") == 0) {
- options->mode = Brief;
- }
- else if (strcmp(argv[i], "-b") == 0) {
- options->findBest = GL_TRUE;
- }
- else if (strcmp(argv[i], "-l") == 0) {
- options->limits = GL_TRUE;
- }
- else if (strcmp(argv[i], "-h") == 0) {
- usage();
- exit(0);
- }
- else if(strcmp(argv[i], "-s") == 0) {
- options->singleLine = GL_TRUE;
- }
- else {
- printf("Unknown option `%s'\n", argv[i]);
- usage();
- exit(0);
- }
- }
-}
-
-static void
query_ATI_meminfo(void)
{
#ifdef GL_ATI_meminfo
diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h
index dc6610c9..1f506e99 100644
--- a/src/xdemos/glinfo_common.h
+++ b/src/xdemos/glinfo_common.h
@@ -34,7 +34,7 @@
/**
* Ext functions needed in common code but must be provided by
- * glxinfo or wglinfo.
+ * the glinfo tool.
*/
struct ext_functions
{
@@ -63,17 +63,6 @@ typedef enum
} InfoMode;
-struct options
-{
- InfoMode mode;
- GLboolean findBest;
- GLboolean limits;
- GLboolean singleLine;
- /* GLX only */
- char *displayName;
- GLboolean allowDirect;
-};
-
void
print_extension_list(const char *ext, GLboolean singleLine);
@@ -96,10 +85,6 @@ profile_mask_string(int mask);
const char *
context_flags_string(int mask);
-
-void
-parse_args(int argc, char *argv[], struct options *options);
-
void
print_gpu_memory_info(const char *glExtensions);
diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index 3e989da6..b2381a61 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -100,7 +100,17 @@ struct visual_attribs
int swapMethod;
};
-
+struct options
+{
+ InfoMode mode;
+ GLboolean findBest;
+ GLboolean limits;
+ GLboolean singleLine;
+ char *displayName;
+ GLboolean allowDirect;
+};
+
+
/**
* Version of the context that was created
*
@@ -1282,6 +1292,73 @@ find_best_visual(Display *dpy, int scrnum)
}
+static void
+usage(void)
+{
+ printf("Usage: glxinfo [-v] [-t] [-h] [-b] [-l] [-s] [-i] [-display <dname>]\n");
+ printf("\t-display <dname>: Print GLX visuals on specified server.\n");
+ printf("\t-i: Force an indirect rendering context.\n");
+ printf("\t-B: brief output, print only the basics.\n");
+ printf("\t-v: Print visuals info in verbose form.\n");
+ printf("\t-t: Print verbose visual information table.\n");
+ printf("\t-h: This information.\n");
+ printf("\t-b: Find the 'best' visual and print its number.\n");
+ printf("\t-l: Print interesting OpenGL limits.\n");
+ printf("\t-s: Print a single extension per line.\n");
+}
+
+
+static void
+parse_args(int argc, char *argv[], struct options *options)
+{
+ int i;
+
+ options->mode = Normal;
+ options->findBest = GL_FALSE;
+ options->limits = GL_FALSE;
+ options->singleLine = GL_FALSE;
+ options->displayName = NULL;
+ options->allowDirect = GL_TRUE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
+ options->displayName = argv[i + 1];
+ i++;
+ }
+ else if (strcmp(argv[i], "-i") == 0) {
+ options->allowDirect = GL_FALSE;
+ }
+ else if (strcmp(argv[i], "-t") == 0) {
+ options->mode = Wide;
+ }
+ else if (strcmp(argv[i], "-v") == 0) {
+ options->mode = Verbose;
+ }
+ else if (strcmp(argv[i], "-B") == 0) {
+ options->mode = Brief;
+ }
+ else if (strcmp(argv[i], "-b") == 0) {
+ options->findBest = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-l") == 0) {
+ options->limits = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-h") == 0) {
+ usage();
+ exit(0);
+ }
+ else if(strcmp(argv[i], "-s") == 0) {
+ options->singleLine = GL_TRUE;
+ }
+ else {
+ printf("Unknown option `%s'\n", argv[i]);
+ usage();
+ exit(0);
+ }
+ }
+}
+
+
int
main(int argc, char *argv[])
{