suche c funktion

Gast #200715
Lesenswert?

Mit ANSI C geht das gar nicht. Entweder lässt Du Dir von einer
Bibliotheks-Funktion helfen, die der Compiler mitbringt oder aber Du
verwendest eine Funktion des Systems.

Da wir nun weder den von Dir verwendeten Compiler noch das
Betriebssystem kennen, kann zumindest ich nicht weiter helfen.
Gast #200716
Lesenswert?

Gibts nicht. Ansi soll ja einen gewissen portabilitätsgrad haben.

Such mal nach bresenham, wenn du einen Algorithmus brauchst um Linien
zu zeichnen. Da solltest du sehr schnell fündig werden.

Beim PC kannst du auch api - Funktionen von windows verwenden. z.B gibt
es dort direkt so was wie LineTo() oder Polyline. Die findest du in der
msdn hilfe.
Gast #200717
Lesenswert?

Im Internet habe ich jetzt was gefunden:
Diesen Code habe ich in Visual Studio.Net 2003 eingefügt.
Der Compiler zeigt folgende fehler an: siehe Anhang.
Was kann da die Ursache sein????

-----Quellcode------------
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <mem.h>


#define VIDEO_INT           0x10      /* the BIOS video interrupt. */
#define SET_MODE            0x00      /* BIOS func to set the video
mode. */
#define VGA_256_COLOR_MODE  0x13      /* use to set 256-color mode. */
#define TEXT_MODE           0x03      /* use to set 80x25 text mode.
*/

#define SCREEN_WIDTH        320       /* width in pixels of mode 0x13
*/
#define SCREEN_HEIGHT       200       /* height in pixels of mode 0x13
*/
#define NUM_COLORS          256       /* number of colors in mode 0x13
*/

#define sgn(x) ((x<0)?-1:((x>0)?1:0)) /* macro to return the sign of a
                                         number */
typedef unsigned char  byte;
typedef unsigned short word;

byte *VGA = (byte *)0xA0000;          /* this points to video memory.
*/
word *my_clock = (word *)0x046C;      /* this points to the 18.2hz
system
                                         clock. */
void set_mode(byte mode);
void plot_pixel(int x,int y,byte color);
/*********************************************************************** 
***
 *  set_mode
  *
 *     Sets the video mode.
  *

************************************************************************ 
**/

void set_mode(byte mode)
{
  union REGS regs;

  regs.h.ah = SET_MODE;
  regs.h.al = mode;
  int86(VIDEO_INT, &regs, &regs);
}

/*********************************************************************** 
***
 *  plot_pixel
  *
 *    Plot a pixel by directly writing to video memory, with no
  *
 *    multiplication.
  *

************************************************************************ 
**/

void plot_pixel(int x,int y,byte color)
{
  /*  y*320 = y*256 + y*64 = y*2^8 + y*2^6   */
  VGA[(y<<8)+(y<<6)+x]=color;
}


int main()
{
set_mode(VGA_256_COLOR_MODE);
plot_pixel(40,60,2);
plot_pixel(2,110,5);
plot_pixel(50,200,1);
plot_pixel(100,60,0);
plot_pixel(2,2,6);
}
Angehängte Dateien:
Gast #200718
Lesenswert?

Das ist uralter 16-Bit-DOS-Code; so wird unter einem Betriebssystem
(hier offensichtlich Windows) keine Graphikausgabe programmiert. Da das
Visual Studio kein DOS-Compiler ist, wirst Du mit Fehlermeldungen
zugedeckt - zu recht.

Wenn Du wirklich unter DOS Graphikausgaben programmieren willst,
besorge Dir einen DOS-Compiler (also einen Compiler, der
16-Bit-Realmode-Applikationen erzeugen kann, wie Borland C++ 3.1).

Alternativ solltest Du Dir mal die Win32-API und hier insbesondere den
GDI-Teil näher ansehen.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren