FLTK logo

[master] e387dbd - Remove VS compilation warning messages about implicit type conversions.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] e387dbd - Remove VS compilation warning messages about implicit type conversions. "ManoloFLTK" Feb 21, 2021  
 
commit e387dbd30c81d27e67a33a580578ea846ff25250
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sun Feb 21 19:15:22 2021 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sun Feb 21 19:15:39 2021 +0100

    Remove VS compilation warning messages about implicit type conversions.

 src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx    |  2 +-
 .../OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx    |  2 +-
 src/gl_draw.cxx                                    | 23 +++++++++++-----------
 src/gl_start.cxx                                   |  2 +-
 src/glut_compatibility.cxx                         |  2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)

diff --git src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
index 48a1854..27360cc 100644
--- src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
+++ src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
@@ -61,7 +61,7 @@ Fl_RGB_Image* Fl_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int w, int
   int ns = Fl_Window_Driver::driver(glw)->screen_num();
   float s = Fl::screen_driver()->scale(ns);
   if (s != 1) {
-    x *= s; y *= s; w *= s; h *= s;
+    x = int(x * s); y = int(y * s); w = int(w * s); h = int(h * s);
   }
   // Read a block of pixels from the frame buffer
   int mByteWidth = w * 3;
diff --git src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
index 0a627be..0a92a9b 100644
--- src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
+++ src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
@@ -108,7 +108,7 @@ void Fl_OpenGL_Graphics_Driver::circle(double cx, double cy, double r) {
   int num_segments = (int)(10 * sqrt(rMax))+1;
   double theta = 2 * M_PI / float(num_segments);
   double tangetial_factor = tan(theta);
-  double radial_factor = cosf(theta);//calculate the radial factor
+  double radial_factor = cos(theta);//calculate the radial factor
   double x = r; //we start at angle = 0
   double y = 0;
 
diff --git src/gl_draw.cxx src/gl_draw.cxx
index 043d1c1..0485102 100644
--- src/gl_draw.cxx
+++ src/gl_draw.cxx
@@ -37,6 +37,7 @@
 #include <FL/gl.h>
 #include <FL/gl_draw.H>
 #include <FL/fl_draw.H>
+#include <FL/math.h> // for ceil()
 #include "Fl_Gl_Window_Driver.H"
 #include <FL/Fl_Image_Surface.H>
 #include <FL/glu.h>  // for gluUnProject()
@@ -154,7 +155,7 @@ void gl_draw(const char* str, int n, float x, float y) {
  \see  gl_texture_pile_height(int)
   */
 void gl_draw(const char* str) {
-  gl_draw(str, strlen(str));
+  gl_draw(str, (int)strlen(str));
 }
 
 /**
@@ -162,7 +163,7 @@ void gl_draw(const char* str) {
  \see  gl_texture_pile_height(int)
   */
 void gl_draw(const char* str, int x, int y) {
-  gl_draw(str, strlen(str), x, y);
+  gl_draw(str, (int)strlen(str), x, y);
 }
 
 /**
@@ -170,7 +171,7 @@ void gl_draw(const char* str, int x, int y) {
  \see  gl_texture_pile_height(int)
   */
 void gl_draw(const char* str, float x, float y) {
-  gl_draw(str, strlen(str), x, y);
+  gl_draw(str, (int)strlen(str), x, y);
 }
 
 static void gl_draw_invert(const char* str, int n, int x, int y) {
@@ -359,11 +360,11 @@ void gl_texture_fifo::display_texture(int rank)
   float oy = pos[1] + height - Fl_Gl_Window_Driver::gl_scale * fl_descent();
   glTexCoord2f (0.0f, 0.0f); // draw lower left in world coordinates
   glVertex2f (ox, oy);
-  glTexCoord2f (0.0f, height); // draw upper left in world coordinates
+  glTexCoord2f (0.0f, (GLfloat)height); // draw upper left in world coordinates
   glVertex2f (ox, oy - height);
-  glTexCoord2f (width, height); // draw upper right in world coordinates
+  glTexCoord2f ((GLfloat)width, (GLfloat)height); // draw upper right in world coordinates
   glVertex2f (ox + width, oy - height);
-  glTexCoord2f (width, 0.0f); // draw lower right in world coordinates
+  glTexCoord2f ((GLfloat)width, 0.0f); // draw lower right in world coordinates
   glVertex2f (ox + width, oy);
   glEnd ();
   glPopAttrib();
@@ -405,10 +406,10 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
   fifo[current].str_len = n; // record length of text in utf8
   fl_graphics_driver->font_descriptor(gl_fontsize);
   int w, h;
-  w = fl_width(fifo[current].utf8, n) * Fl_Gl_Window_Driver::gl_scale;
+  w = int(ceil(fl_width(fifo[current].utf8, n) * Fl_Gl_Window_Driver::gl_scale));
   // Hack - make w be aligned
   w = (w + 3) & (~3);
-  h = fl_height() * Fl_Gl_Window_Driver::gl_scale;
+  h = int(ceil(fl_height() * Fl_Gl_Window_Driver::gl_scale));
 
   fifo[current].scale = Fl_Gl_Window_Driver::gl_scale;
   fifo[current].fdesc = gl_fontsize;
@@ -549,7 +550,7 @@ void Fl_Gl_Window_Driver::draw_string_legacy_get_list(const char* str, int n) {
   int size = 0;
   if (gl_start_scale != 1) { // using gl_start() / gl_finish()
     size = fl_graphics_driver->font_descriptor()->size;
-    gl_font(fl_font(), size * gl_start_scale);
+    gl_font(fl_font(), Fl_Fontsize(size * gl_start_scale));
   }
   for (unsigned i = 0; i < wn; i++) {
     unsigned int r;
@@ -579,7 +580,7 @@ void Fl_Gl_Window_Driver::draw_string_legacy_glut(const char* str, int n)
   fl_graphics_driver->font_descriptor(gl_fontsize);
   Fl_Gl_Window *gwin = Fl_Window::current()->as_gl_window();
   gl_scale = (gwin ? gwin->pixels_per_unit() : 1);
-  float ratio = fl_width((char*)str_nul, n) * gl_scale/glutStrokeLength(GLUT_STROKE_ROMAN, str_nul);
+  float ratio = float(fl_width((char*)str_nul, n) * gl_scale/glutStrokeLength(GLUT_STROKE_ROMAN, str_nul));
   Fl_Surface_Device::pop_current();
 
   //setup matrices
@@ -605,7 +606,7 @@ void Fl_Gl_Window_Driver::draw_string_legacy_glut(const char* str, int n)
   glTranslatef (-winw/R, -winh/R, 0.0f);
   glTranslatef(pos[0]*2/R, pos[1]*2/R, 0.0);
   glutStrokeString(GLUT_STROKE_ROMAN, str_nul);
-  float width = fl_width((char*)str_nul);
+  float width = float(fl_width((char*)str_nul));
   delete[] str_nul;
   glPopAttrib();
   // reset original matrices
diff --git src/gl_start.cxx src/gl_start.cxx
index 9c13dac..15ec991 100644
--- src/gl_start.cxx
+++ src/gl_start.cxx
@@ -77,7 +77,7 @@ void gl_start() {
     if (fl_clip_box(0, 0, Fl_Window::current()->w(), Fl_Window::current()->h(),
                     x, y, w, h)) {
       fl_clip_region(Fl_Graphics_Driver::default_driver().XRectangleRegion(x,y,w,h));
-      glScissor(x*gl_start_scale, (Fl_Window::current()->h()-(y+h))*gl_start_scale, w*gl_start_scale, h*gl_start_scale);
+      glScissor(int(x*gl_start_scale), int((Fl_Window::current()->h()-(y+h))*gl_start_scale), int(w*gl_start_scale), int(h*gl_start_scale));
       glEnable(GL_SCISSOR_TEST);
     } else {
       glDisable(GL_SCISSOR_TEST);
diff --git src/glut_compatibility.cxx src/glut_compatibility.cxx
index df657a8..cf51e13 100644
--- src/glut_compatibility.cxx
+++ src/glut_compatibility.cxx
@@ -454,7 +454,7 @@ int glutExtensionSupported( const char* extension )
   if (!extension || strchr(extension, ' ')) return 0;
 
   const char *extensions, *start;
-  const int len = strlen( extension );
+  const int len = (const int)strlen( extension );
 
   start = extensions = (const char *) glGetString(GL_EXTENSIONS);
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.