Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wvtrammell

Pages: 1 2 [3] 4 5
31
General / Re: SFML 2.0
« on: May 09, 2013, 06:07:27 am »
I tried Cmake according to the tutorial.  I was then told not to use Cmake.
Is there something else to do after installing the various files from SFML 2.0 in their appropriate folders?
Thanks
Warren Trammell

32
General / Re: SFML 2.0
« on: May 09, 2013, 04:49:17 am »
I get 1 warning and 25 error messages
Apple Mach-O Linker (ld) Warning
Apple Mach-O Linker (ld) Errors

How do I Include headers & link to frameworks?
Thanks
Warren

33
General / SFML 2.0
« on: May 09, 2013, 02:58:27 am »
I am running OSX  10.8.3 & Xcode 4.6.2 (clang)
I downloaded   SFML 2.0 ((MAC OS X Clang (OS X 10.8+).
I installed the various files in their respective places (FRAMEWORKS etc.)
What else do I need to do?
Specify location of Tutorial or specific instructions for a newbee please.

Warren Trammell

34
Graphics / Re: App.display
« on: December 12, 2012, 05:33:35 pm »
The object is to fill the screen with random colored pixels and then sort the pixels from left to right with the darkest on the left.  The program worked fine in version 1.6 but something was changed with the App.display command in 2.0 as it will only work in 2.0 with screen sizes of 1000 x 1000 pixels or less.  What was changed in App.display from 1.6 to 2.0?????
Warren

35
Graphics / Graphics 2.0
« on: December 12, 2012, 12:33:33 am »
Here is a simpler version of the App.display problem I am having.

#include <SFML/Graphics.hpp>
#include <time.h>
#include <iostream>
#include <sstream>

int data[2560][3],total[1440], wheel[12][3];

void quickSort(int[], int, int);
void q_sort(int[], int, int, int);

FILE *pFile;

int main()
{   
   pFile = fopen("//users//warren//programming//projects//basicolor.txt","r");
   
   int prnt, green, red, blue, x, y, z = 0;
   int count = 0, row,col;
   char buffer[12], string1[12], string2[12], string3[12];
   
   // Initialize random
   srand((unsigned int)time(NULL));
   
   // Create main window
   sf::RenderWindow App(sf::VideoMode(2500, 1300), "Basic Colors Graphics");
   
   // Clear screen
   App.clear(sf::Color(128, 255, 128));
            
   for(y = 0; y < 12; y++)          
       {
       for(x = 0; x < 3; x++)
      {
           fscanf(pFile,"%i",&wheel[y]
  • );

      }
       }
   
        for(y = 200; y < 1200; y++)
            {   
       for(x = 400; x < 800; x++)
      {
      red = wheel[z][0];
      green = wheel[z][1];
      blue = wheel[z][2];
         
      sf::Color choice(red,green,blue);
                sf::RectangleShape recShape;
                recShape.setSize(sf::Vector2f(1,1));
                recShape.setPosition(x, y);
                recShape.setFillColor(choice);
                App.draw(recShape);
                count++;
                if (count > 10000)
                   {
                   z++;
                   count = 0;
                   }
                if(z > 11) z = 0;
      }
            App.display();
            }
             
// Start game loop
        while(App.isOpen())
            {
            // Process events
            sf::Event Event;
            while (App.pollEvent(Event))
                {
                // Close window : exit
                if (Event.type == sf::Event::Closed)  App.close();
                }
            }
        return EXIT_SUCCESS;
}
//End of main

Why does changing the range of the x variable to 400 to 1200 cause 12 different colors to be displayed?
Thanks
Warren

36
Graphics / Re: App.display
« on: December 11, 2012, 04:58:52 am »
// Main.cpp
// Basic colors
// December 6, 2012
// Random colors to fill screen
// Sort horizontal and then vertical
// Mark's input

#include <SFML/Graphics.hpp>
#include <time.h>
#include <iostream>
#include <sstream>

int data[2450][3],total[1350], wheel[12][3];

void quickSort(int[], int, int);
void q_sort(int[], int, int, int);

FILE *pFile;

int main()
{   
   pFile = fopen("//users//warren//programming//projects//basicolor.txt","r");
   
   int prnt, green, red, blue, x, y, z;
   int count,row,col;
   char buffer[10], string1[10], string2[10], string3[10];
   
   // Initialize random
   srand((unsigned int)time(NULL));
   
   // Create main window
   sf::RenderWindow App(sf::VideoMode(2500, 1350), "Basic Colors Graphics");
   
   // Clear screen
   App.clear(sf::Color(128, 128, 128));
            
   for(y = 0; y < 12; y++)          
       {
       for(x = 0; x < 3; x++)
      {
           fscanf(pFile,"%i",&wheel[y]
  • );

      }
       }
        // Fill screen with randow colors:
   for(y = 0; y < 1350; y++)
       {   
       for(x = 0; x < 2500; x++)
      {
           z = rand() % 12;
      red = wheel[z][0];
      green = wheel[z][1];
      blue = wheel[z][2];
         
      sf::Color choice(red,green,blue);
                sf::RectangleShape recShape;
                recShape.setSize(sf::Vector2f(1,1));
                recShape.setPosition(x, y);
                recShape.setFillColor(choice);
                App.draw(recShape);

      }
        App.display();
        }
             
         // Screen filled with random colors:

                    sf::Image Image = App.capture();               
                    for(count = 1; count < 1350; count++)
                        {
                        row = count;
                        // Sort by rows
                        y = row -1;
                     z = 0;
              for(x = 0; x < 1000; x++)
             {
             sf::Color color = Image.getPixel(x,y);
             data[z][0] = (int)color.r;
             data[z][1] = (int)color.g;
             data[z][2] = (int)color.b;
             sprintf(string1,"%i",(int)color.r);
             sprintf(string2,"%i",(int)color.g);
             sprintf(string3,"%i",(int)color.b);
             strcpy(buffer,string1);
             strcat(buffer,string2);
             strcat(buffer,string3);
                      
             total[z] = atoi(buffer);
             z++;
             }
         quickSort(total, z, 1);
         z = 0;
         for(x = 0; x < 1000; x++)
             {
             red = data[z][0];
             green = data[z][1];
             blue = data[z][2];
             sf::Color choice(red,green,blue);
                            sf::RectangleShape recShape;
                            recShape.setSize(sf::Vector2f(1,1));
                            recShape.setPosition(x, y);
                            recShape.setFillColor(choice);
                            App.draw(recShape);
                            z++;
             }
                App.display();
                }
                           

// Start game loop
        while (App.isOpen())
            {
            // Process events
            sf::Event Event;
            while (App.pollEvent(Event))
                {
                // Close window : exit
                if (Event.type == sf::Event::Closed)  App.close();

                //Escape key exit
                if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))  App.close();
                }
            }
        return EXIT_SUCCESS;
}
//End of main



void quickSort(int total[], int size, int row)
{
   q_sort(total, 0, size - 1, row);
}
void q_sort(int total[], int left, int right, int row)
{
   int pivot, l_hold, r_hold;
   int piv0,piv1,piv2;
   l_hold = left;
   r_hold = right;
   pivot = total
;
   piv0 = data
[0];
   piv1 = data
[1];
   piv2 = data
[2];
   while (left < right)
   {
      while ((total
>= pivot) && (left < right)) right--;
      if (left != right)
      {
         total
= total
;
         data
[0] = data
[0];
         data
[1] = data
[1];
         data
[2] = data
[2];
         left++;
      }
      while ((total
<= pivot) && (left < right)) left++;
      if (left != right)
      {
         total
= total
;
         data
[0] = data
[0];
         data
[1] = data
[1];
         data
[2] = data
[2];
         right--;
      }
   }
   total
= pivot;
   data
[0] = piv0;
   data
[1] = piv1;
   data
[2] = piv2;
   pivot = left;
   piv0 = data
[0];
   piv1 = data
[1];
   piv2 = data
[2];
   left = l_hold;
   right = r_hold;
   if (left < pivot) q_sort(total, left, pivot-1,row);
   if (right > pivot) q_sort(total, pivot+1, right,row);
}



37
Graphics / Re: App.display
« on: December 10, 2012, 10:20:36 pm »
I have written a few lines of code in C++ using version 2.0.
It fills the screen randomingly choosing one of 12 colors for each pixel.
I then sort line by line moving the darker colors to the left.
If I wait until all rows are sorted and then call App.display it works.
But if I call App.display after sorting each line, the final screen is different.
I am confused.
If anything I would expect the opposite results.
Any thought? Anyone? 
Thanks.
Warren
A 90 year old would be programmer with a new mac mini.

38
Graphics / App.display
« on: December 10, 2012, 07:17:00 pm »
In version 2.0 does the command App.display write to the screen the most recent App.draw item defined or does it re display all previous App.draw items.
Thanks a bunch.
Warren Trammell

39
General / Compiling & Linking
« on: October 13, 2012, 07:35:16 pm »
Hi
The following commands work great to create a file to run on my computer.

g++ -F /Library/Frameworks -c main.cpp
g++ main.o -framework sfml-window -framework sfml-graphics -framework sfml-system -o mark

What commands do I need to get a file to run on my son's MAC?
Thanks a heap.
Warren Trammell

40
General / Xcode 4.3.1
« on: March 20, 2012, 03:12:55 pm »
HI
So I must continue using Xcode 3 in order to use SFML 1.6?
Thanks
Warren

41
General / X code 4.3.1
« on: March 20, 2012, 12:24:19 am »
Hi
Just installed new version of Xcode.  Do I reinstall SFML to get it into the new version of Xcode?
Thanks
Warren

42
Graphics / Order
« on: March 31, 2011, 05:37:01 pm »
Thanks
Are you saying the code should be inside an if statement when inside the event loop?
Warreni

43
Graphics / Sending variables to the screen
« on: March 31, 2011, 12:09:17 am »
I am new at this so I put together a few lines of code to place digits (0 - 9) to the screen sequentially.  However it did not come out that way.  The program cycles continously but only writes to the screen when a key is pressed.  Would some one point out my error in the code please? Thanks
Warren Trammell


Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>

int main()
{
int x = 0, y = 0, count = -1;
char buffer[10];

    // Create main window
    sf::RenderWindow App(sf::VideoMode(1600, 900), "SFML Fonts");

  // Clear screen
App.Clear(sf::Color(128,128,128));

    // Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("/users/warren/projects/impact.ttf", 50))
        return EXIT_FAILURE;

    // Start game loop
    while (App.IsOpened())
    {
count++;
if(count > 9) count = 0;

    // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
             x = x + 50;
if(x > 1500)
{
x = 0;
y = y + 50;
}

// Create a graphical string
sf::String Text;
sprintf(buffer,"%i",count);
Text.SetText(buffer);
Text.SetFont(MyFont);
Text.SetColor(sf::Color::Black);
Text.SetPosition(x, y);
Text.SetSize(50);

// Draw our strings
App.Draw(Text);

// Finally, display rendered frame on screen
App.Display();
           
  // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

        }
}

    return EXIT_SUCCESS;
}

44
Graphics / pixel color
« on: February 20, 2011, 07:54:21 pm »
With your help I was able to come up with code that works.  Thanks.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>

int main()
{
int Color;
char buffer[10];


    // Create main window
    sf::RenderWindow App(sf::VideoMode(1200, 900), "SFML Graphics");


// Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("/users/warren/projects/impact.ttf", 50))
        return EXIT_FAILURE;


// Clear screen
App.Clear(sf::Color(128,128,255));

// Draw apredefined shape
App.Draw(sf::Shape::Rectangle(50,50,200, 200, sf::Color(64,128,190)));

// Finally, display the rendered frame on screen
App.Display();

sf::Image Image = App.Capture();
sf::Color color = Image.GetPixel(100, 100);

// Create a graphical string
    sf::String prntr;

      sprintf(buffer,"%i",(int)color.r);
       prntr.SetText(buffer);
            prntr.SetFont(MyFont);
            prntr.SetColor(sf::Color(0, 0, 0));
            prntr.SetPosition(150, 350);
            prntr.SetSize(150);

       // Draw our strings
       App.Draw(prntr);


// Create a graphical string
    sf::String prntg;

sprintf(buffer,"%i",(int)color.g);
prntg.SetText(buffer);
prntg.SetFont(MyFont);
prntg.SetColor(sf::Color(0, 0, 0));
prntg.SetPosition(450, 350);
prntg.SetSize(150);

// Draw our strings
App.Draw(prntg);


// Create a graphical string
    sf::String prntb;

sprintf(buffer,"%i",(int)color.b);
prntb.SetText(buffer);
prntb.SetFont(MyFont);
prntb.SetColor(sf::Color(0, 0, 0));
prntb.SetPosition(750, 350);
prntb.SetSize(150);

// Draw our strings
App.Draw(prntb);

// Finally, display the rendered frame on screen
App.Display();


    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

 

    }

    return EXIT_SUCCESS;
}

45
Graphics / pixel color
« on: February 19, 2011, 08:25:47 pm »
You are right.  I need to learn Classes before I can hope to do any programming in SFML.
I assumed the word Color in the expression "sf::Color Pixel = "
was the name of an integer variable containing the value of the color in the designated pixel.
Boy was I ever wrong.
Warreni

Pages: 1 2 [3] 4 5