Ejemplo n.º 1
0
		std::string 
		_sono_xml::to_string(
			__in_opt bool verbose
			)
		{
			std::stringstream result;

			result << SONO_XML_HEADER << " (PATH. " << STRING_CHECK(m_path) << ", LEN. " 
				<< m_source.size() << ")";

			if(verbose) {
				result << std::endl << "---" << std::endl << STRING_CHECK(m_source) 
					<< std::endl << "---" << std::endl;
			}

			return result.str();
		}
Ejemplo n.º 2
0
			void 
			_base::link(
				__in const std::string &vertex,
				__in const std::string &fragment,
				__in_opt const std::vector<std::string> &attribute
				)
			{
				GLuint index = 0;
				std::string buffer;
				GLint complete, length;
				std::vector<gaea::graphics::shader::base> shader;
				std::vector<std::string>::const_iterator attrib_iter;
				std::vector<gaea::graphics::shader::base>::iterator shader_iter;

				shader.push_back(gaea::graphics::shader::base(vertex, GL_VERTEX_SHADER));
				GL_CHECK(glAttachShader, m_handle, shader.back().handle());
				shader.push_back(gaea::graphics::shader::base(fragment, GL_FRAGMENT_SHADER));
				GL_CHECK(glAttachShader, m_handle, shader.back().handle());

				for(attrib_iter = attribute.begin(); attrib_iter != attribute.end(); 
						++attrib_iter) {
					GL_CHECK(glBindAttribLocation, m_handle, index++, attrib_iter->c_str());
				}

				GL_CHECK(glLinkProgram, m_handle);
				GL_CHECK(glGetProgramiv, m_handle, GL_LINK_STATUS, &complete);

				if(!complete) {
					GL_CHECK(glGetProgramiv, m_handle, GL_INFO_LOG_LENGTH, &length);

					if(length > 0) {
						buffer.resize(++length, 0);
						GL_CHECK(glGetProgramInfoLog, m_handle, length, &length, &buffer[0]);
					}

					if(!length) {
						buffer = PROGRAM_ERROR_UNKNOWN;
					} else if(length < 0) {
						buffer = PROGRAM_ERROR_MALFORMED;
					}

					THROW_GAEA_PROGRAM_EXCEPTION_FORMAT(GAEA_PROGRAM_EXCEPTION_EXTERNAL,
						"%s", STRING_CHECK(buffer));
				}

				for(shader_iter = shader.begin(); shader_iter != shader.end(); 
						++shader_iter) {
					GL_CHECK(glDetachShader, m_handle, shader_iter->handle());
				}
			}
Ejemplo n.º 3
0
void
iregisterdllfun(void)
{
  int         i,
              index;
  ResType     argtypes[MAX_ARGS];  /* list of types of arguments */
  bool        vararg[MAX_ARGS];    /* is the argument a variable arg */
  bool        ispointer[MAX_ARGS]; /* is the argument a pointer */
  int         varargcount = 0;     /* number of variable args */
  int         ispointercount = 0;  /* number of pointer args */
  nialptr     z = apop();
  char       *nialname;            /* names used by calldllfun */
  char       *dllname;             /* the real name of the function */
                                   /* in the DLL file */
  char       *library;             /* name of the DLL file */
  ResType     resulttype;          /* the type of the result */
  nialptr     nargtypes;           /* the arg type array */
  int         argcount;
  int         j;
  int         sz;
  nialptr     current;       /* usually hold the current entry in the dlllist */
  int         is_register;

  /* if we have 5 args we are registering a function */

  if ((tally(z) == 5) && (kind(z) == atype))
    is_register = 1;         /* register mode */

  else 
  /* only one arg and it is a char or a phrase, we are deleting the fun */
  if ((kind(z) == chartype) || (kind(z) == phrasetype))
    is_register = 0;         /* delete mode */

  else {                     /* error mode */
    apush(makefault("?Incorrect number of arguments to registerdllfun"));
    freeup(z);
    return;
  }

  if (is_register) {
    /* The Nial level name for the DLL function */
    STRING_CHECK(z, 0)
      nialname = STRING_GET(z, 0);


    /* The internal DLL name for the function */
    STRING_CHECK(z, 1)
      dllname = STRING_GET(z, 1);

    /* The name of the library file */
    STRING_CHECK(z, 2)
      library = STRING_GET(z, 2);

    /* The name of the result type */
    STRING_CHECK(z, 3)
      resulttype = StringToTypeID(STRING_GET(z, 3));

    /* did we find an unrecognized result type? */
    if (resulttype < 0) {
      apush(makefault("?Return type not recognized"));
      freeup(z);
      return;
    }

    if (kind(fetch_array(z, 4)) != atype) {
      apush(makefault("?Argument must be a list of strings or phrases"));
      freeup(z);
      return;
    }

    nargtypes = fetch_array(z, 4);
    argcount = tally(nargtypes);

    /* Check each of the argument type */
    for (j = 0; j < argcount; j++)
      STRING_CHECK_FREEUP(nargtypes, j, z)
      /* create an integer list of argument types from the phrase/string list */
        for (i = 0; i < argcount; i++) {
        char       *tmp;

        tmp = pfirstchar(fetch_array(nargtypes, i));  /* safe: no allocation */
        argtypes[i] = StringToTypeID(tmp);

        /* the ith argument name was not recognized */
        if (argtypes[i] < 0) {
          char        stmp[256];

          wsprintf(stmp, "?Type \"%s\" for argument %d not recognized", tmp, i + 1);
          apush(makefault(stmp));
          freeup(z);
          return;
        }
        /* set the vararg and ispointer flags for this arg */
        vararg[i] = IsVarArg(tmp);
        ispointer[i] = IsPointer(tmp);
        /* keep count of these special args */
        if (vararg[i])
          varargcount++;
        if (ispointer[i])
          ispointercount++;
      }

    /* NEW workspace Version */

    /* If the list does not yet exist, then create a one element list here */
    if (tally(dlllist) == 0) {
      nialptr     tmp = create_new_dll_entry; /* build a empty entry */

      setup_dll_entry(tmp)   /* fill it with empty data */
        apush(tmp);
      isolitary();           /* make it a list */
      decrrefcnt(dlllist);
      freeup(dlllist);
      dlllist = apop();
      incrrefcnt(dlllist);
      index = 0;
    }
    else {
      int         pos;

      /* does the requested name already exist in out list? */
      if ((pos = inlist(nialname)) >= 0) {
        /* yes it's here already, so note its position, and free the old
         * entry */
        index = pos;
        freeEntry(index);
      }
      else {
        /* if we got here, then we need to create a new entry and add it to
         * and existing dlllist */
        nialptr     tmp = create_new_dll_entry;

        setup_dll_entry(tmp)
          decrrefcnt(dlllist);
        append(dlllist, tmp);
        dlllist = apop();
        incrrefcnt(dlllist);
        index = tally(dlllist) - 1; /* this is the location of the new entry */
      }
    }



    /* grab the entry to work on */
    current = fetch_array(dlllist, index);

    /* fill in data */
    set_handle(current, NULL);
    set_nialname(current, nialname);
    set_dllname(current, dllname);
    set_callingconvention(current, (dllname[0] == '_' ? C_CALL : PASCAL_CALL));
    set_library(current, library);
    set_isloaded(current, false);
    set_resulttype(current, resulttype);
    set_argcount(current, argcount);
    set_varargcount(current, varargcount);
    set_ispointercount(current, ispointercount);

    sz = argcount;
    replace_array(current, 10, (sz == 0 ? Null : new_create_array(inttype, 1, 0, &sz)));
    for (j = 0; j < sz; j++)
      set_argtypes(current, j, argtypes[j]);

    replace_array(current, 11, (sz == 0 ? Null : new_create_array(booltype, 1, 0, &sz)));
    for (j = 0; j < sz; j++)
      set_ispointer(current, j, ispointer[j]);

    replace_array(current, 14, (sz == 0 ? Null : new_create_array(booltype, 1, 0, &sz)));
    for (j = 0; j < sz; j++)
      set_vararg(current, j, vararg[j]);
  }
  else { /* delete entry code */
Ejemplo n.º 4
0
	void 
	display::start(
		__in_opt const mirra::parameter_t &parameter
		)
	{
		std::string title;
		uint32_t height, width;
		mirra::parameter_t::const_iterator iter;
		mirra::object_parameter_t::const_iterator attribute_iter;

		if(!m_initialized) {
			THROW_MIRRA_DISPLAY_EXCEPTION(MIRRA_DISPLAY_EXCEPTION_UNINITIALIZED);
		}

		if(m_started) {
			THROW_MIRRA_DISPLAY_EXCEPTION(MIRAR_DISPLAY_EXCEPTION_STARTED);
		}

		height = DISPLAY_PARAMETER_DEFAULT_HEIGHT;
		title = DISPLAY_PARAMETER_DEFAULT_TITLE;
		width = DISPLAY_PRAAMETER_DEFAULT_WIDTH;

		iter = parameter.find(OBJECT_DISPLAY);
		if(iter != parameter.end()) {

			attribute_iter = iter->second.find(DISPLAY_PARAMETER_HEIGHT);
			if(attribute_iter != iter->second.end()) {

				if(attribute_iter->second.type != DATA_UNSIGNED) {
					THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_INVALID_PARAMETER,
						"%s: %s (expecting %s)", DISPLAY_PARAMETER_STRING(DISPLAY_PARAMETER_HEIGHT),
						DATA_STRING(attribute_iter->second.type), DATA_STRING(DATA_UNSIGNED));
				}

				height = attribute_iter->second.data.uvalue;
			}

			attribute_iter = iter->second.find(DISPLAY_PARAMETER_TITLE);
			if(attribute_iter != iter->second.end()) {

				if(attribute_iter->second.type != DATA_STRING) {
					THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_INVALID_PARAMETER,
						"%s: %s (expecting %s)", DISPLAY_PARAMETER_STRING(DISPLAY_PARAMETER_TITLE),
						DATA_STRING(attribute_iter->second.type), DATA_STRING(DATA_STRING));
				}

				title = (attribute_iter->second.data.strvalue ? attribute_iter->second.data.strvalue :
					STRING_EMPTY);
			}

			attribute_iter = iter->second.find(DISPLAY_PARAMETER_WIDTH);
			if(attribute_iter != iter->second.end()) {

				if(attribute_iter->second.type != DATA_UNSIGNED) {
					THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_INVALID_PARAMETER,
						"%s: %s (expecting %s)", DISPLAY_PARAMETER_STRING(DISPLAY_PARAMETER_WIDTH),
						DATA_STRING(attribute_iter->second.type), DATA_STRING(DATA_UNSIGNED));
				}

				width = attribute_iter->second.data.uvalue;
			}
		}

		m_window = SDL_CreateWindow(STRING_CHECK(title), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
			width, height, WINDOW_INIT_FLAGS);

		if(!m_window) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_CreateWindow: %s", SDL_GetError());
		}

		m_window_renderer = SDL_CreateRenderer(m_window, SCALAR_INVALID(int), WINDOW_RENDERER_INIT_FLAGS);
		if(!m_window_renderer) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_CreateRenderer: %s", SDL_GetError());
		}

		if(SDL_GetRendererOutputSize(m_window_renderer, &m_renderer_width, &m_renderer_height)) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_GetRendererOutputSize: %s", SDL_GetError());
		}

		if(SDL_SetRenderDrawBlendMode(m_window_renderer, SDL_BLENDMODE_BLEND)) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_SetRenderDrawBlendMode: %s", SDL_GetError());
		}

		m_window_texture = SDL_CreateTexture(m_window_renderer, SDL_PIXELFORMAT_BGRA8888, SDL_TEXTUREACCESS_STREAMING,
			width, height);

		if(!m_window_texture) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_CreateTexture: %s", SDL_GetError());
		}

		if(SDL_SetTextureBlendMode(m_window_texture, SDL_BLENDMODE_BLEND)) {
			THROW_MIRRA_DISPLAY_EXCEPTION_FORMAT(MIRRA_DISPLAY_EXCEPTION_EXTERNAL,
				"SDL_SetTextureBlendMode: %s", SDL_GetError());
		}

		m_started = true;
		clear();
	}