[ Prev | Index | Next ]
Japanese English

Creating a Renderer

In 2D graphics (2DCG), the basic workflow typically involves manipulating a renderer (drawing engine) to modify image data. This section introduces these two essential concepts.

This section introduces these two essential concepts.

Graphics Resource and Renderer

To work with 2D graphics in VCSSL, you need to understand two core components: the graphics resource, which holds the drawing contents, and the renderer, which performs the drawing operations. Don't worry -- it's simpler than it sounds.

Graphics Resource -- The Drawing Surface

In the real world, to draw a picture, you need things like paper to draw on and pens to draw with. In programming, it's similar -- you need a structure to hold and modify the drawing contents, such as an image, buffer, or graphics context (the exact term depends on the language or environment).

In VCSSL, all of these elements are bundled together into a single concept called a graphics resource.

You can think of it like a ready-to-use sheet of drawing paper that already comes with all the tools you need.

Renderer -- The Drawing Engine

A renderer (drawing engine) is the tool used to perform advanced drawing operations on graphics resource. While it's technically possible to draw directly on graphics resource, using a renderer allows for more sophisticated rendering techniques.

You can think of the renderer as "the person doing the drawing." Just like in the real world, there are artists who specialize in 2D art and others who specialize in 3D.

Similarly, VCSSL provides separate renderers for 2DCG and 3DCG.

Creating Graphics Resource

Let's start by creating the graphics data on which we'll draw. Use the "newGraphics" function from the Graphics library for this.

- Function Format -
int newGraphics( )

When called without any arguments, this function allocates an empty region in memory to store drawing contents, and returns a **graphics resource ID** -- a unique identifier assigned to the graphics resource.

Creating a Renderer (Drawing Engine)

The graphics resource created with "newGraphics" starts out blank.

To draw 2D graphics on it, you'll need to create a 2D renderer (drawing engine) using the "newGraphics2DRenderer" function.

- Function Format -
int newGraphics2DRenderer ( int width, int height, int graphicsID )

Arguments:

  • width, height: The size of the drawing canvas.
  • graphicsID: The ID of the graphics resource to draw on, obtained from the "newGraphics" function.

Example Program

Now let's actually create a renderer. Write and run the following program:


import Graphics;
import Graphics2D;

// Create graphics resource
int graphicsID = newGraphics( );

// Create a 2D renderer
int rendererID = newGraphics2DRenderer( 800, 600, graphicsID );
Sample.vcssl

When you run this program, the graphics data and renderer will be initialized, but nothing will appear on the screen just yet. That's because we haven't created a display screen to show the graphics data.

Let's move on to preparing the display in the next section.



Sponsored Link



Japanese English
Index
News From RINEARN
* VCSSL is developed by RINEARN.

VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More
2025-05-25 - This update introduces enhancements to the external program integration features (e.g., for running C-language executables). Several other improvements and fixes are also included. Details inside.

Released: Latest Version of VCSSL with Fixes for Behavioral Changes on Java 24
2025-04-22 - VCSSL 3.4.50 released with a fix for a subtle behavioral change in absolute path resolution on network drives, introduced in Java 24. Details inside.

Released the Latest Versions of RINEARN Graph and VCSSL - Now Supporting Customizable Tick Positions and Labels!
2024-11-24 - Starting with this update, a new "MANUAL" tick mode is now supported, allowing users to freely specify the positions and labels of ticks on the graph. We'll explain the details and how to use it.

Released Exevalator 2.2: Now Compatible with TypeScript and Usable in Web Browsers
2024-10-22 - The open-source expression evaluation library, Exevalator, has been updated to version 2.2. It now supports TypeScript and can be used for evaluating expressions directly in web browsers. Explains the details.

Behind the Scenes of Creating an Assistant AI (Part 1: Fundamental Knowledge)
2024-10-07 - The first part of a series on how to create an Assistant AI. In this article, we introduce the essential knowledge you need to grasp before building an Assistant AI. What exactly is an LLM-based AI? What is RAG? And more.

Launching an Assistant AI to Support Software Usage!
2024-09-20 - We've launched an Assistant AI that answers questions about how to use RINEARN software and helps with certain tasks. Anyone with a ChatGPT account can use it for free. We'll explain how to use it.

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024-02-05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Dives into each of them!

Inside the Repetitive Execution Speedup Impremented in Vnano Ver.1.1
2024-01-17 - Delves into the update in Vnano 1.1 from a developer's viewpoint, providing detailed insights into the specific improvements made to the internal structure of the script engine.