Herramientas de usuario

Herramientas del sitio


wiki2:cpp:libraries:openframeworks

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:cpp:libraries:openframeworks [2015/08/04 19:23]
alfred [Notes]
wiki2:cpp:libraries:openframeworks [2020/05/09 09:25] (actual)
Línea 6: Línea 6:
  
  
-Import the generated project as "​Existing code as makefile project"​. You only need to add OpenFrameworks and Addons projects as references in your new project. +Import the generated project as "​Existing code as makefile project"​. You only need to add OpenFrameworks and Addons projects as references in your new project ​(do not forget to select "Linux GCC").
 ==== Notes ==== ==== Notes ====
   * **To add an addon after having created the project** you just need to include its name in the ''​addons.make''​ file.   * **To add an addon after having created the project** you just need to include its name in the ''​addons.make''​ file.
 +  * To compile with **C++11** you need to go to ''​libs/​openFrameworksCompiled/​project/​makefileCommon''​ path and edit the main makefile which is ''​compile.project.mk''​. You need to search for the rule that does the compilation and add: ''​-std=c++0x''​.
 +<code cpp>
 +$(OF_PROJECT_OBJ_OUPUT_PATH)%.o:​ $(PROJECT_ROOT)/​%.cpp
 + @echo "​Compiling"​ $<
 + @mkdir -p $(@D)
 + $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) -std=c++0x -MMD -MP -MF $(OF_PROJECT_OBJ_OUPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUPUT_PATH)$*.o -o $@ -c $<
 +</​code>​
 +  * Muy probablemente quieras usar otras libs, las tendrías que añadir también en el makefile:
 +<code cpp>
 +$(TARGET): $(OF_PROJECT_OBJS) $(OF_PROJECT_ADDONS_OBJS) $(OF_PROJECT_LIBS) $(TARGET_LIBS)
 + @echo '​Linking $(TARGET) for $(ABI_LIB_SUBPATH)'​
 + @mkdir -p $(@D)
 + $(CXX) -o $@ $(OF_PROJECT_OBJS) $(OF_PROJECT_ADDONS_OBJS) $(TARGET_LIBS) $(OF_PROJECT_LIBS) $(LDFLAGS) $(OF_CORE_LIBS) ​ -lboost_system -lboost_timer -lboost_thread ​
 +</​code>​
 +===== Useful data =====
 +==== Obtain information ====
 +
 +  * Ventana
 +    * ofGetWidth(),​ ofGetHeight()
 +  * Programa
 +    * ofGetElapsedTimef(),​ ofGetElapsedTimeMicros(),​ ofGetElapsedTimeMillis()
 +
 +==== Useful constants ====
 +
 +  * TWO_PI
 +  * DEG_TO_RAD (any number we multiply by DEG_TO_RAD will be converted to radians)
 +===== Graphics =====
 +
 +  * [[wiki2:​cpp:​libraries:​openframeworks:​creating_graphics|Creating Graphics]]
 ===== Addons ===== ===== Addons =====
  
Línea 17: Línea 45:
 Crear un listener de UDP: Crear un listener de UDP:
 <code cpp> <code cpp>
 +#include "​ofxNetwork.h"​
 +
 ofxUDPManager udpConnection;​ ofxUDPManager udpConnection;​
  
Línea 31: Línea 61:
   * https://​github.com/​jefftimesten/​ofxJSON   * https://​github.com/​jefftimesten/​ofxJSON
 <code cpp> <code cpp>
 +#include "​ofxJSON.h"​
 +...
 ofxJSONElement result; ofxJSONElement result;
 std::string url = "​http://​127.0.0.1:​5000/​sketch/​1";​ std::string url = "​http://​127.0.0.1:​5000/​sketch/​1";​
Línea 56: Línea 88:
 </​code>​ </​code>​
  
-===== Snippets =====+==== Addons Repository ​====
  
-  * Create image from code (color picker)+  * http://​www.ofxaddons.com/​categories
  
-<code cpp> +===== Snippets ​=====
-float w ofGetWidth();​ +
-float h ofGetHeight();​ +
-float cx w/2; +
-float cy h/2; +
- +
-img.allocate(w,​h,​OF_IMAGE_COLOR);​ +
- +
-for (float y=0; y<h; y++) { +
-    for (float x=0; x<w; x++) { +
-                     +
-        float angle atan2(y-cy,​x-cy)+PI;​ +
-        float dist ofDist(x,​y,​cx,​cy);​ +
-        float hue angle/​TWO_PI*255;​ +
-        float sat ofMap(dist,​0,​w/​4,​0,​255,​true);​ +
-        float bri = ofMap(dist,​w/​4,​w/​2,​255,​0,​true);​ +
-         +
-        img.setColor(x,​y,​ofColor::​fromHsb(hue,​sat,​bri));​ +
-    } +
-+
- +
-img.reloadTexture(); ​  +
-</​code>​+
  
 +  * [[wiki2:​cpp:​libraries:​openframeworks:​snippets|OpenFrameworks Snippets]]
wiki2/cpp/libraries/openframeworks.1438716211.txt.gz · Última modificación: 2020/05/09 09:25 (editor externo)