From b5f891a9aadce637a86407b74fe9ca8e0961ed1e Mon Sep 17 00:00:00 2001 From: pradeep Date: Fri, 25 Mar 2016 09:34:16 +0530 Subject: [PATCH] rename types enum --- examples/cpu/bubblechart.cpp | 4 ++-- examples/cpu/fractal.cpp | 2 +- examples/cpu/histogram.cpp | 4 ++-- examples/cpu/plot3.cpp | 2 +- examples/cpu/plotting.cpp | 8 ++++---- examples/cpu/surface.cpp | 2 +- examples/cuda/fractal.cu | 2 +- examples/cuda/histogram.cu | 4 ++-- examples/cuda/plot3.cu | 2 +- examples/cuda/plotting.cu | 8 ++++---- examples/cuda/surface.cu | 2 +- examples/opencl/fractal.cpp | 2 +- examples/opencl/histogram.cpp | 4 ++-- examples/opencl/plot3.cpp | 2 +- examples/opencl/plotting.cpp | 8 ++++---- examples/opencl/surface.cpp | 2 +- include/fg/defines.h | 25 +++++++++++++++++-------- src/api/c/chart.cpp | 12 +++++++----- src/api/c/histogram.cpp | 2 +- src/api/c/image.cpp | 4 ++-- src/api/c/plot.cpp | 3 ++- src/api/c/surface.cpp | 3 ++- 22 files changed, 60 insertions(+), 47 deletions(-) diff --git a/examples/cpu/bubblechart.cpp b/examples/cpu/bubblechart.cpp index 71f8aadb..56d27011 100644 --- a/examples/cpu/bubblechart.cpp +++ b/examples/cpu/bubblechart.cpp @@ -79,9 +79,9 @@ int main(void) /* Create several plot objects which creates the necessary * vertex buffer objects to hold the different plot types */ - fg::Plot plt1 = chart.plot(cosData.size()/2, f32, + fg::Plot plt1 = chart.plot(cosData.size()/2, fg::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //or specify a specific plot type - fg::Plot plt2 = chart.plot(tanData.size()/2, f32, + fg::Plot plt2 = chart.plot(tanData.size()/2, fg::f32, FG_PLOT_LINE, FG_MARKER_CIRCLE); //last parameter specifies marker shape /* Set plot colors */ diff --git a/examples/cpu/fractal.cpp b/examples/cpu/fractal.cpp index f817cc30..6e076531 100644 --- a/examples/cpu/fractal.cpp +++ b/examples/cpu/fractal.cpp @@ -55,7 +55,7 @@ int main(void) /* Create an image object which creates the necessary * textures and pixel buffer objects to hold the image * */ - fg::Image img(DIMX, DIMY, FG_RGBA, u8); + fg::Image img(DIMX, DIMY, FG_RGBA, fg::u8); /* copy your data into the pixel buffer object exposed by * fg::Image class and then proceed to rendering. * To help the users with copying the data from compute diff --git a/examples/cpu/histogram.cpp b/examples/cpu/histogram.cpp index f5facbad..b6b2b52d 100644 --- a/examples/cpu/histogram.cpp +++ b/examples/cpu/histogram.cpp @@ -66,7 +66,7 @@ int main(void) */ wnd.grid(WIN_ROWS, WIN_COLS); - fg::Image img(IMGW, IMGH, FG_RGBA, u8); + fg::Image img(IMGW, IMGH, FG_RGBA, fg::u8); fg::Chart chart(FG_CHART_2D); /* set x axis limits to maximum and minimum values of data @@ -79,7 +79,7 @@ int main(void) /* * Create histogram object specifying number of bins */ - fg::Histogram hist = chart.histogram(NBINS, s32); + fg::Histogram hist = chart.histogram(NBINS, fg::s32); /* * Set histogram colors */ diff --git a/examples/cpu/plot3.cpp b/examples/cpu/plot3.cpp index 33f39259..fe0faf33 100644 --- a/examples/cpu/plot3.cpp +++ b/examples/cpu/plot3.cpp @@ -49,7 +49,7 @@ int main(void) chart.setAxesLimits(-1.1f, 1.1f, -1.1f, 1.1f, 0.f, 10.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Plot plot3 = chart.plot(ZSIZE, f32); + fg::Plot plot3 = chart.plot(ZSIZE, fg::f32); //generate a surface std::vector function; diff --git a/examples/cpu/plotting.cpp b/examples/cpu/plotting.cpp index e8793ada..e331f048 100644 --- a/examples/cpu/plotting.cpp +++ b/examples/cpu/plotting.cpp @@ -57,10 +57,10 @@ int main(void) /* Create several plot objects which creates the necessary * vertex buffer objects to hold the different plot types */ - fg::Plot plt0 = chart.plot(sinData.size()/2, f32); //create a default plot - fg::Plot plt1 = chart.plot(cosData.size()/2, f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type - fg::Plot plt2 = chart.plot(tanData.size()/2, f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape - fg::Plot plt3 = chart.plot(logData.size()/2, f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); + fg::Plot plt0 = chart.plot(sinData.size()/2, fg::f32); //create a default plot + fg::Plot plt1 = chart.plot(cosData.size()/2, fg::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type + fg::Plot plt2 = chart.plot(tanData.size()/2, fg::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape + fg::Plot plt3 = chart.plot(logData.size()/2, fg::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); /* * Set plot colors diff --git a/examples/cpu/surface.cpp b/examples/cpu/surface.cpp index 19f4c7ea..66f53b41 100644 --- a/examples/cpu/surface.cpp +++ b/examples/cpu/surface.cpp @@ -52,7 +52,7 @@ int main(void) chart.setAxesLimits(-10.f, 10.f, -10.f, 10.f, -0.5f, 1.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Surface surf = chart.surface(XSIZE, YSIZE, f32); + fg::Surface surf = chart.surface(XSIZE, YSIZE, fg::f32); surf.setColor(FG_YELLOW); //generate a surface diff --git a/examples/cuda/fractal.cu b/examples/cuda/fractal.cu index 0159a714..16f28df2 100644 --- a/examples/cuda/fractal.cu +++ b/examples/cuda/fractal.cu @@ -25,7 +25,7 @@ int main(void) /* Create an image object which creates the necessary * textures and pixel buffer objects to hold the image * */ - fg::Image img(DIMX, DIMY, FG_RGBA, u8); + fg::Image img(DIMX, DIMY, FG_RGBA, fg::u8); /* copy your data into the pixel buffer object exposed by * fg::Image class and then proceed to rendering. * To help the users with copying the data from compute diff --git a/examples/cuda/histogram.cu b/examples/cuda/histogram.cu index 7e1faa0d..740d84ac 100644 --- a/examples/cuda/histogram.cu +++ b/examples/cuda/histogram.cu @@ -77,7 +77,7 @@ int main(void) */ wnd.grid(WIN_ROWS, WIN_COLS); - fg::Image img(IMGW, IMGH, FG_RGBA, u8); + fg::Image img(IMGW, IMGH, FG_RGBA, fg::u8); fg::Chart chart(FG_CHART_2D); /* set x axis limits to maximum and minimum values of data @@ -90,7 +90,7 @@ int main(void) /* * Create histogram object specifying number of bins */ - fg::Histogram hist = chart.histogram(NBINS, s32); + fg::Histogram hist = chart.histogram(NBINS, fg::s32); /* * Set histogram colors */ diff --git a/examples/cuda/plot3.cu b/examples/cuda/plot3.cu index 0841c37c..75f19a2f 100644 --- a/examples/cuda/plot3.cu +++ b/examples/cuda/plot3.cu @@ -41,7 +41,7 @@ int main(void) chart.setAxesLimits(-1.1f, 1.1f, -1.1f, 1.1f, 0.f, 10.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Plot plot3 = chart.plot(ZSIZE, f32); + fg::Plot plot3 = chart.plot(ZSIZE, fg::f32); static float t=0; FORGE_CUDA_CHECK(cudaMalloc((void**)&dev_out, ZSIZE * 3 * sizeof(float) )); diff --git a/examples/cuda/plotting.cu b/examples/cuda/plotting.cu index f5aeebb2..da09654b 100644 --- a/examples/cuda/plotting.cu +++ b/examples/cuda/plotting.cu @@ -37,10 +37,10 @@ int main(void) /* Create several plot objects which creates the necessary * vertex buffer objects to hold the different plot types */ - fg::Plot plt0 = chart.plot( DATA_SIZE, f32); //create a default plot - fg::Plot plt1 = chart.plot( DATA_SIZE, f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type - fg::Plot plt2 = chart.plot( DATA_SIZE, f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape - fg::Plot plt3 = chart.plot( DATA_SIZE, f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); + fg::Plot plt0 = chart.plot( DATA_SIZE, fg::f32); //create a default plot + fg::Plot plt1 = chart.plot( DATA_SIZE, fg::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type + fg::Plot plt2 = chart.plot( DATA_SIZE, fg::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape + fg::Plot plt3 = chart.plot( DATA_SIZE, fg::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); /* * Set plot colors diff --git a/examples/cuda/surface.cu b/examples/cuda/surface.cu index 7f477080..53824a24 100644 --- a/examples/cuda/surface.cu +++ b/examples/cuda/surface.cu @@ -32,7 +32,7 @@ int main(void) chart.setAxesLimits(-10.f, 10.f, -10.f, 10.f, -0.5f, 1.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Surface surf = chart.surface(XSIZE, YSIZE, f32); + fg::Surface surf = chart.surface(XSIZE, YSIZE, fg::f32); surf.setColor(FG_YELLOW); FORGE_CUDA_CHECK(cudaMalloc((void**)&dev_out, XSIZE * YSIZE * 3 * sizeof(float) )); diff --git a/examples/opencl/fractal.cpp b/examples/opencl/fractal.cpp index cad45977..093663ad 100644 --- a/examples/opencl/fractal.cpp +++ b/examples/opencl/fractal.cpp @@ -117,7 +117,7 @@ int main(void) /* Create an image object which creates the necessary * textures and pixel buffer objects to hold the image * */ - fg::Image img(DIMX, DIMY, FG_RGBA, u8); + fg::Image img(DIMX, DIMY, FG_RGBA, fg::u8); Platform plat = getPlatform(); diff --git a/examples/opencl/histogram.cpp b/examples/opencl/histogram.cpp index 5c58b7d7..7675ae58 100644 --- a/examples/opencl/histogram.cpp +++ b/examples/opencl/histogram.cpp @@ -272,7 +272,7 @@ int main(void) */ wnd.grid(WIN_ROWS, WIN_COLS); - fg::Image img(IMGW, IMGH, FG_RGBA, u8); + fg::Image img(IMGW, IMGH, FG_RGBA, fg::u8); fg::Chart chart(FG_CHART_2D); /* set x axis limits to maximum and minimum values of data @@ -285,7 +285,7 @@ int main(void) /* * Create histogram object specifying number of bins */ - fg::Histogram hist = chart.histogram(NBINS, s32); + fg::Histogram hist = chart.histogram(NBINS, fg::s32); /* * Set histogram colors */ diff --git a/examples/opencl/plot3.cpp b/examples/opencl/plot3.cpp index 58c5108f..99b5f6ca 100644 --- a/examples/opencl/plot3.cpp +++ b/examples/opencl/plot3.cpp @@ -87,7 +87,7 @@ int main(void) chart.setAxesLimits(-1.1f, 1.1f, -1.1f, 1.1f, 0.f, 10.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Plot plot3 = chart.plot(ZSIZE, f32); + fg::Plot plot3 = chart.plot(ZSIZE, fg::f32); Platform plat = getPlatform(); // Select the default platform and create a context using this platform and the GPU diff --git a/examples/opencl/plotting.cpp b/examples/opencl/plotting.cpp index fc3c7d21..cdae4369 100644 --- a/examples/opencl/plotting.cpp +++ b/examples/opencl/plotting.cpp @@ -92,10 +92,10 @@ int main(void) /* Create several plot objects which creates the necessary * vertex buffer objects to hold the different plot types */ - fg::Plot plt0 = chart.plot(DATA_SIZE, f32); //create a default plot - fg::Plot plt1 = chart.plot(DATA_SIZE, f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type - fg::Plot plt2 = chart.plot(DATA_SIZE, f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape - fg::Plot plt3 = chart.plot(DATA_SIZE, f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); + fg::Plot plt0 = chart.plot(DATA_SIZE, fg::f32); //create a default plot + fg::Plot plt1 = chart.plot(DATA_SIZE, fg::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type + fg::Plot plt2 = chart.plot(DATA_SIZE, fg::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape + fg::Plot plt3 = chart.plot(DATA_SIZE, fg::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS); /* * Set plot colors diff --git a/examples/opencl/surface.cpp b/examples/opencl/surface.cpp index 2857ebd5..71ce5134 100644 --- a/examples/opencl/surface.cpp +++ b/examples/opencl/surface.cpp @@ -113,7 +113,7 @@ int main(void) chart.setAxesLimits(-10.f, 10.f, -10.f, 10.f, -0.5f, 1.f); chart.setAxesTitles("x-axis", "y-axis", "z-axis"); - fg::Surface surf = chart.surface(XSIZE, YSIZE, f32); + fg::Surface surf = chart.surface(XSIZE, YSIZE, fg::f32); surf.setColor(FG_YELLOW); Platform plat = getPlatform(); diff --git a/include/fg/defines.h b/include/fg/defines.h index 21ebd195..fd8fd79b 100644 --- a/include/fg/defines.h +++ b/include/fg/defines.h @@ -159,13 +159,13 @@ typedef enum { } fg_color; typedef enum { - s8 = 0, ///< Signed byte (8-bits) - u8 = 1, ///< Unsigned byte (8-bits) - s32 = 2, ///< Signed integer (32-bits) - u32 = 3, ///< Unsigned integer (32-bits) - f32 = 4, ///< Float (32-bits) - s16 = 5, ///< Signed integer (16-bits) - u16 = 6 ///< Unsigned integer (16-bits) + FG_INT8 = 0, ///< Signed byte (8-bits) + FG_UINT8 = 1, ///< Unsigned byte (8-bits) + FG_INT32 = 2, ///< Signed integer (32-bits) + FG_UINT32 = 3, ///< Unsigned integer (32-bits) + FG_FLOAT32 = 4, ///< Float (32-bits) + FG_INT16 = 5, ///< Signed integer (16-bits) + FG_UINT16 = 6 ///< Unsigned integer (16-bits) } fg_dtype; typedef enum { @@ -194,8 +194,17 @@ namespace fg typedef fg_chart_type ChartType; typedef fg_color_map ColorMap; typedef fg_color Color; - typedef fg_dtype dtype; typedef fg_plot_type PlotType; typedef fg_marker_type MarkerType; + + typedef enum { + s8 = FG_INT8, + u8 = FG_UINT8, + s32 = FG_INT32, + u32 = FG_UINT32, + f32 = FG_FLOAT32, + s16 = FG_INT16, + u16 = FG_UINT16, + } dtype; } #endif diff --git a/src/api/c/chart.cpp b/src/api/c/chart.cpp index d9bd9ab3..6fd53826 100644 --- a/src/api/c/chart.cpp +++ b/src/api/c/chart.cpp @@ -86,7 +86,7 @@ fg_err fg_add_image_to_chart(fg_image* pImage, fg_chart pHandle, const fg_dtype pType) { try { - common::Image* img = new common::Image(pWidth, pHeight, pFormat, pType); + common::Image* img = new common::Image(pWidth, pHeight, pFormat, (fg::dtype)pType); getChart(pHandle)->addRenderable(img->impl()); *pImage = getHandle(img); } @@ -102,7 +102,7 @@ fg_err fg_add_histogram_to_chart(fg_histogram* pHistogram, fg_chart pHandle, common::Chart* chrt = getChart(pHandle); if (chrt->chartType()== FG_CHART_2D) { - common::Histogram* hist = new common::Histogram(pNBins, pType); + common::Histogram* hist = new common::Histogram(pNBins, (fg::dtype)pType); chrt->addRenderable(hist->impl()); *pHistogram = getHandle(hist); } else { @@ -124,11 +124,13 @@ fg_err fg_add_plot_to_chart(fg_plot* pPlot, fg_chart pHandle, fg::ChartType ctype = chrt->chartType(); if (ctype == FG_CHART_2D) { - common::Plot* plt = new common::Plot(pNPoints, pType, pPlotType, pMarkerType, FG_CHART_2D); + common::Plot* plt = new common::Plot(pNPoints, (fg::dtype)pType, pPlotType, + pMarkerType, FG_CHART_2D); chrt->addRenderable(plt->impl()); *pPlot = getHandle(plt); } else { - common::Plot* plt = new common::Plot(pNPoints, pType, pPlotType, pMarkerType, FG_CHART_3D); + common::Plot* plt = new common::Plot(pNPoints, (fg::dtype)pType, pPlotType, + pMarkerType, FG_CHART_3D); chrt->addRenderable(plt->impl()); *pPlot = getHandle(plt); } @@ -147,7 +149,7 @@ fg_err fg_add_surface_to_chart(fg_surface* pSurface, fg_chart pHandle, fg::ChartType ctype = chrt->chartType(); if (ctype == FG_CHART_3D) { - common::Surface* surf = new common::Surface(pXPoints, pYPoints, pType, + common::Surface* surf = new common::Surface(pXPoints, pYPoints, (fg::dtype)pType, pPlotType, pMarkerType); chrt->addRenderable(surf->impl()); *pSurface = getHandle(surf); diff --git a/src/api/c/histogram.cpp b/src/api/c/histogram.cpp index 40ed654a..1da870bd 100644 --- a/src/api/c/histogram.cpp +++ b/src/api/c/histogram.cpp @@ -16,7 +16,7 @@ fg_err fg_create_histogram(fg_histogram *pHistogram, const uint pNBins, const fg_dtype pType) { try { - *pHistogram = getHandle(new common::Histogram(pNBins, pType)); + *pHistogram = getHandle(new common::Histogram(pNBins, (fg::dtype)pType)); } CATCHALL diff --git a/src/api/c/image.cpp b/src/api/c/image.cpp index b8f4bfa2..dd276c17 100644 --- a/src/api/c/image.cpp +++ b/src/api/c/image.cpp @@ -23,7 +23,7 @@ fg_err fg_create_image(fg_image* pImage, const fg_channel_format pFormat, const fg_dtype pType) { try { - *pImage = getHandle(new common::Image(pWidth, pHeight, pFormat, pType)); + *pImage = getHandle(new common::Image(pWidth, pHeight, pFormat, (fg::dtype)pType)); } CATCHALL @@ -93,7 +93,7 @@ fg_err fg_get_image_pixelformat(fg_channel_format* pOut, const fg_image pImage) fg_err fg_get_image_type(fg_dtype* pOut, const fg_image pImage) { try { - *pOut = getImage(pImage)->channelType(); + *pOut = (fg_dtype)(getImage(pImage)->channelType()); } CATCHALL diff --git a/src/api/c/plot.cpp b/src/api/c/plot.cpp index 14f60b87..dfc63b79 100644 --- a/src/api/c/plot.cpp +++ b/src/api/c/plot.cpp @@ -19,7 +19,8 @@ fg_err fg_create_plot(fg_plot *pPlot, const fg_marker_type pMarkerType) { try { - *pPlot = getHandle(new common::Plot(pNPoints, pType, pPlotType, pMarkerType, pChartType)); + *pPlot = getHandle(new common::Plot(pNPoints, (fg::dtype)pType, pPlotType, + pMarkerType, pChartType)); } CATCHALL diff --git a/src/api/c/surface.cpp b/src/api/c/surface.cpp index 58c557f6..4816729a 100644 --- a/src/api/c/surface.cpp +++ b/src/api/c/surface.cpp @@ -19,7 +19,8 @@ fg_err fg_create_surface(fg_surface *pSurface, const fg_marker_type pMarkerType) { try { - *pSurface = getHandle(new common::Surface(pXPoints, pYPoints, pType, pPlotType, pMarkerType)); + *pSurface = getHandle(new common::Surface(pXPoints, pYPoints, (fg::dtype)pType, + pPlotType, pMarkerType)); } CATCHALL