Beispiel #1
0
static bool gl_xml_shader(void *data, const char *path)
{
   gl_t *gl = (gl_t*)data;

#ifdef HAVE_FBO
   gl_deinit_fbo(gl);
   glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
#endif

   gl_shader_deinit();

   if (!gl_glsl_init(path))
      return false;

#ifdef HAVE_FBO
   // Set up render to texture again.
   gl_init_fbo(gl, gl->tex_w, gl->tex_h);
#endif

   // Apparently need to set viewport for passes when we aren't using FBOs.
   gl_shader_use(0);
   set_viewport(gl, gl->win_width, gl->win_height, false, true);
   gl_shader_use(1);
   set_viewport(gl, gl->win_width, gl->win_height, false, true);

   return true;
}
Beispiel #2
0
	/**
	 * @brief   Scroll vertically a section of the screen.
	 * @note    Optional.
	 * @note    If x,y + cx,cy is off the screen, the result is undefined.
	 * @note    If lines is >= cy, it is equivelent to a area fill with bgcolor.
	 *
	 * @param[in] x, y     The start of the area to be scrolled
	 * @param[in] cx, cy   The size of the area to be scrolled
	 * @param[in] lines    The number of lines to scroll (Can be positive or negative)
	 * @param[in] bgcolor  The color to fill the newly exposed area.
	 *
	 * @notapi
	 */
	void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
		/* This is marked as "TODO: Test this" in the original GLCD driver.
		 * For now we just leave the GDISP_HARDWARE_SCROLL off.
		 */
		static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)];
		coord_t row0, row1;
		unsigned i, gap, abslines;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		abslines = lines < 0 ? -lines : lines;

		acquire_bus();
		if (abslines >= cy) {
			abslines = cy;
			gap = 0;
		} else {
			gap = cy - abslines;
			for(i = 0; i < gap; i++) {
				if(lines > 0) {
					row0 = y + i + lines;
					row1 = y + i;
				} else {
					row0 = (y - i - 1) + lines;
					row1 = (y - i - 1);
				}

				/* read row0 into the buffer and then write at row1*/
				set_viewport(x, row0, cx, 1);
				lld_lcdReadStreamStart();
				lld_lcdReadStream(buf, cx);
				lld_lcdReadStreamStop();

				set_viewport(x, row1, cx, 1);
				stream_start();
				write_data(buf, cx);
				stream_stop();
			}
		}

		/* fill the remaining gap */
		set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines);
		stream_start();
		gap = cx*abslines;
		for(i = 0; i < gap; i++) write_data(bgcolor);
		stream_stop();
		reset_viewport();
		release_bus();
	}
Beispiel #3
0
	/**
	 * @brief   Scroll vertically a section of the screen.
	 * @note    Optional.
	 * @note    If x,y + cx,cy is off the screen, the result is undefined.
	 * @note    If lines is >= cy, it is equivelent to a area fill with bgcolor.
	 *
	 * @param[in] x, y     The start of the area to be scrolled
	 * @param[in] cx, cy   The size of the area to be scrolled
	 * @param[in] lines    The number of lines to scroll (Can be positive or negative)
	 * @param[in] bgcolor  The color to fill the newly exposed area.
	 *
	 * @notapi
	 */
	void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
		static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)];
		coord_t row0, row1;
		unsigned i, gap, abslines, j;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		abslines = lines < 0 ? -lines : lines;

		acquire_bus();
		if (abslines >= cy) {
			abslines = cy;
			gap = 0;
		} else {
			gap = cy - abslines;
			for(i = 0; i < gap; i++) {
				if(lines > 0) {
					row0 = y + i + lines;
					row1 = y + i;
				} else {
					row0 = (y - i - 1) + lines;
					row1 = (y - i - 1);
				}

				/* read row0 into the buffer and then write at row1*/
				set_viewport(x, row0, cx, 1);
				stream_start();
				j = read_data();			// dummy read
				for (j = 0; j < cx; j++)
					buf[j] = read_data();
				stream_stop();

				set_viewport(x, row1, cx, 1);
				stream_start();
				for (j = 0; j < cx; j++)
					write_data(buf[j]);
				stream_stop();
			}
		}

		/* fill the remaining gap */
		set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines);
		stream_start();
		gap = cx*abslines;
		for(i = 0; i < gap; i++) write_data(bgcolor);
		stream_stop();
		release_bus();
	}
void OpenGL3RenderState::enable(OpenGL3ContextState& state) const
{
    depth_state_.enable(state);
    stencil_state_.enable(state);
    blend_state_.enable(state);
    rasterizer_state_.enable(state);
    if (viewport_.is_empty())
        set_viewport(state, rect<int>(0, 0, state.window_size.x(), state.window_size.y()));
    else
        set_viewport(state, viewport_);
    set_scissor(state, scissor_state_);
}
Beispiel #5
0
static __inline void reset_viewport(void) {
	switch(GDISP.Orientation) {
		case GDISP_ROTATE_0:
		case GDISP_ROTATE_180:
			set_viewport(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
			break;
		case GDISP_ROTATE_90:
		case GDISP_ROTATE_270:
			set_viewport(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH);
			break;
	}
}
void CRenderTarget::phase_downsamp	()
{
	// DON'T DO THIS!!!
	//IDirect3DSurface9 *source, *dest;
	//rt_Position->pSurface->GetSurfaceLevel(0, &source);
	//rt_half_depth->pSurface->GetSurfaceLevel(0, &dest);
	//HW.pDevice->StretchRect(source, NULL, dest, NULL, D3DTEXF_POINT);

	//Fvector2	p0,p1;
	u32			Offset = 0;

    u_setrt( rt_half_depth,0,0,0/*HW.pBaseZB*/ );
   	FLOAT ColorRGBA[4] = {0.0f, 0.0f, 0.0f, 0.0f};
    HW.pContext->ClearRenderTargetView(rt_half_depth->pRT, ColorRGBA);
	u32 w = Device.dwWidth;
	u32 h = Device.dwHeight;

	if (RImplementation.o.ssao_half_data)
	{
		set_viewport(HW.pDevice, Device.dwWidth/2, Device.dwHeight/2);
		w /= 2;
		h /= 2;
	}

	RCache.set_Stencil	(FALSE);

	{
		Fmatrix		m_v2w;			m_v2w.invert				(Device.mView		);

		// Fill VB
		float	scale_X				= float(w)	/ float(TEX_jitter);
		float	scale_Y				= float(h)  / float(TEX_jitter);

		// Fill vertex buffer
		FVF::TL* pv					= (FVF::TL*)	RCache.Vertex.Lock	(4,g_combine->vb_stride,Offset);
		pv->set						( -1,  1, 0, 1, 0,		0,	scale_Y	);	pv++;
		pv->set						( -1, -1, 0, 0, 0,		0,		  0	);	pv++;
		pv->set						(  1,  1, 1, 1, 0, scale_X,	scale_Y	);	pv++;
		pv->set						(  1, -1, 1, 0, 0, scale_X,		  0	);	pv++;
		RCache.Vertex.Unlock		(4,g_combine->vb_stride);

		// Draw
		RCache.set_Element			(s_ssao->E[1]	);
		RCache.set_Geometry			(g_combine		);
		RCache.set_c				("m_v2w",			m_v2w	);

		RCache.Render				(D3DPT_TRIANGLELIST,Offset,0,4,0,2);
	}

	if (RImplementation.o.ssao_half_data)
		set_viewport(HW.pDevice, Device.dwWidth, Device.dwHeight);
}
Beispiel #7
0
void ui_create_window (float x1, float y1, float x2, float y2)
{

	set_viewport (x1, y1, x2, y2);

	ui_set_origin (x1, y1);

	//ui_draw_area (0, 0, x2 - x1, y2 - y1, UI_OBJECT_STATE_OFF);

	set_viewport (x1 + 1, y1 + 1, x2 - 1, y2 - 1);

	ui_set_origin (x1 + 1, y1 + 1);
}
Beispiel #8
0
int check_ui_object_clipped (ui_object *obj)
{

	int
		flag;

	ui_object
		*parent;

	float
		x1,
		x2,
		y1,
		y2,
		x_min,
		y_min,
		x_max,
		y_max,
		old_vp_x1,
		old_vp_y1,
		old_vp_x2,
		old_vp_y2;

	old_vp_x1 = active_viewport.x_min;
	old_vp_y1 = active_viewport.y_min;
	old_vp_x2 = active_viewport.x_max;
	old_vp_y2 = active_viewport.y_max;

	parent = get_ui_object_parent (obj);

	ASSERT (parent);

	x1 = get_ui_object_x (parent);
	y1 = get_ui_object_y (parent);
	x2 = x1 + get_ui_object_x_size (parent);
	y2 = y1 + get_ui_object_y_size (parent);

	x_min = get_ui_object_x (obj);
	y_min = get_ui_object_y (obj);
	x_max = x_min + get_ui_object_x_size (obj);
	y_max = y_min + get_ui_object_y_size (obj);
	
	set_viewport (x1, y1, x2, y2);

	flag = ui_clip_area (&x_min, &y_min, &x_max, &y_max);

	set_viewport (old_vp_x1, old_vp_y1, old_vp_x2, old_vp_y2);

	return flag;
}
	LLDSPEC	void gdisp_lld_read_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		write_index(g, 0x2E);
		setreadmode(g);
		dummy_read(g);
	}
Beispiel #10
0
	LLDSPEC	void gdisp_lld_write_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		#if !GDISP_HARDWARE_STREAM_POS
			set_cursor(g);
		#endif
	}
Beispiel #11
0
	LLDSPEC	void gdisp_lld_read_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		setreadmode(g);
		dummy_read(g);
	}
Beispiel #12
0
/**
 * @brief   Fill an area with a color.
 * @note    Optional - The high level driver can emulate using software.
 *
 * @param[in] x, y     The start filled area
 * @param[in] cx, cy   The width and height to be filled
 * @param[in] color    The color of the fill
 *
 * @notapi
 */
void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
    unsigned i, area;

#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
    if (x < GDISP.clipx0) {
        cx -= GDISP.clipx0 - x;
        x = GDISP.clipx0;
    }
    if (y < GDISP.clipy0) {
        cy -= GDISP.clipy0 - y;
        y = GDISP.clipy0;
    }
    if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
    if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
    if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
#endif

    area = cx*cy;
    acquire_bus();
    set_viewport(x, y, cx, cy);
    stream_start();
    for(i = 0; i < area; i++)
        write_data(color);
    stream_stop();
    reset_viewport();
    release_bus();
}
Beispiel #13
0
	/**
	 * @brief   Fill an area with a bitmap.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] x, y     The start filled area
	 * @param[in] cx, cy   The width and height to be filled
	 * @param[in] srcx, srcy   The bitmap position to start the fill from
	 * @param[in] srccx    The width of a line in the bitmap.
	 * @param[in] buffer   The pixels to use to fill the area.
	 *
	 * @notapi
	 */
	void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
		coord_t endx, endy;
		unsigned lg;

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (srcx+cx > srccx)		cx = srccx - srcx;
			if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		acquire_bus();
		set_viewport(x, y, cx, cy);
		stream_start();

		endx = srcx + cx;
		endy = y + cy;
		lg = srccx - cx;
		buffer += srcx + srcy * srccx;
		for(; y < endy; y++, buffer += lg)
			for(x=srcx; x < endx; x++)
				write_data(*buffer++);
		stream_stop();
		reset_viewport();
		release_bus();
	}
Beispiel #14
0
static void gl_update_resize(gl_t *gl)
{
#ifdef HAVE_FBO
   if (!gl->render_to_tex)
      set_viewport(gl, gl->win_width, gl->win_height, false, true);
   else
   {
      gl_check_fbo_dimensions(gl);

      // Go back to what we're supposed to do, render to FBO #0 :D
      gl_start_frame_fbo(gl);
   }
#else
   set_viewport(gl, gl->win_width, gl->win_height, false, true);
#endif
}
Beispiel #15
0
void set_2d_active_environment (env_2d *env)
{
	ASSERT (env);

	active_2d_environment = env;

	set_viewport (env->vp.x_min, env->vp.y_min, env->vp.x_max, env->vp.y_max);
}
Beispiel #16
0
void Shex::loop() {
	SDL_Event e;
	bool quit = false;
	while(1) {
		// process events:
		while(SDL_WaitEvent(&e) != 0) {
			if(e.type == SDL_QUIT) {
				quit = true;
			}
			if(e.type == SDL_WINDOWEVENT &&
			(e.window.event ==SDL_WINDOWEVENT_RESIZED ||
			e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) {
				winw = e.window.data1;
				winh = e.window.data2;
				set_viewport();
			}
			if(e.type == SDL_MOUSEWHEEL) {
				if(e.wheel.y < 0) {
					doffset += 16;
				} else {
					if(doffset < 16) {
						doffset = 0;
					} else {
						doffset -= 16;
					}
				}
				load_data_file();
//				std::cout << e.wheel.y << std::endl;
			}
			if(e.type == SDL_KEYDOWN) {
				switch(e.key.keysym.sym) {
				case SDLK_HOME:
					doffset = 0;
					load_data_file();
					break;
				case SDLK_END:
					doffset = (dfsize - dfsize % 16);
					load_data_file();
					break;
				case SDLK_PAGEUP:
					doffset = (doffset < 400)? 0:
							doffset - 400;
					load_data_file();
					break;
				case SDLK_PAGEDOWN:
					doffset += 400;
					load_data_file();
					break;
				}
			}
			if(quit) break;
			draw();
		}
		if(quit) break;
	}
	SDL_GL_DeleteContext(glcontext);
	SDL_Quit();
}
Beispiel #17
0
void set_2d_viewport (env_2d *env, const float x_min, const float y_min, const float x_max, const float y_max)
{
	float
		x_translate,
		y_translate,
		x_scale,
		y_scale;

	ASSERT (env);

	env->vp.x_min = x_min;
	env->vp.y_min = y_min;
	env->vp.x_max = x_max;
	env->vp.y_max = y_max;

	//
	// set viewport origin (centre of viewport)
	//

	x_translate = (env->vp.x_min + env->vp.x_max) / 2.0;
	y_translate = (env->vp.y_min + env->vp.y_max) / 2.0;

	env->viewport_translation[2][0] = x_translate;
	env->viewport_translation[2][1] = y_translate;

	env->inverse_viewport_translation[2][0] = -x_translate;
	env->inverse_viewport_translation[2][1] = -y_translate;

	//
	// calc window to viewport scaling
	//

	x_scale = (env->vp.x_max - env->vp.x_min) / (env->window_x_max - env->window_x_min);
	y_scale = (env->vp.y_max - env->vp.y_min) / (env->window_y_max - env->window_y_min);

	env->window_scaling[0][0] = x_scale;
	env->window_scaling[1][1] = y_scale;

	env->inverse_window_scaling[0][0] = 1.0 / x_scale;
	env->inverse_window_scaling[1][1] = 1.0 / y_scale;

	//
	// flags
	//

	env->composite_transformation_matrix_valid = FALSE;
	env->inverse_composite_transformation_matrix_valid = FALSE;

	//
	// set graphics system viewport
	//

	if (env == active_2d_environment)
	{
		set_viewport (env->vp.x_min, env->vp.y_min, env->vp.x_max, env->vp.y_max);
	}
}
Beispiel #18
0
static void gl_render_msg(gl_t *gl, const char *msg)
{
   if (!gl->font)
      return;

   GLfloat font_vertex[8]; 
   GLfloat font_vertex_dark[8]; 
   GLfloat font_tex_coords[8];

   // Deactivate custom shaders. Enable the font texture.
   gl_shader_use(0);
   set_viewport(gl, gl->win_width, gl->win_height, false, false);
   glBindTexture(GL_TEXTURE_2D, gl->font_tex);
   glTexCoordPointer(2, GL_FLOAT, 0, font_tex_coords);

   // Need blending. 
   // Using fixed function pipeline here since we cannot guarantee presence of shaders (would be kinda overkill anyways).
   glEnable(GL_BLEND);

   struct font_output_list out;

   // If we get the same message, there's obviously no need to render fonts again ...
   if (strcmp(gl->font_last_msg, msg) != 0)
   {
      font_renderer_msg(gl->font, msg, &out);
      struct font_output *head = out.head;

      struct font_rect geom;
      calculate_msg_geometry(head, &geom);
      adjust_power_of_two(gl, &geom);
      blit_fonts(gl, head, &geom);

      font_renderer_free_output(&out);
      strlcpy(gl->font_last_msg, msg, sizeof(gl->font_last_msg));

      gl->font_last_width = geom.width;
      gl->font_last_height = geom.height;
   }
   calculate_font_coords(gl, font_vertex, font_vertex_dark, font_tex_coords);
   
   glVertexPointer(2, GL_FLOAT, 0, font_vertex_dark);
   glColorPointer(4, GL_FLOAT, 0, gl->font_color_dark);
   glDrawArrays(GL_QUADS, 0, 4);
   glVertexPointer(2, GL_FLOAT, 0, font_vertex);
   glColorPointer(4, GL_FLOAT, 0, gl->font_color);
   glDrawArrays(GL_QUADS, 0, 4);

   // Go back to old rendering path.
   glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
   glVertexPointer(2, GL_FLOAT, 0, vertexes_flipped);
   glColorPointer(4, GL_FLOAT, 0, white_color);
   glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);

   glDisable(GL_BLEND);
   set_projection(gl, true);
}
Beispiel #19
0
	LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
		uint16_t	c;

		c = gdispColor2Native(g->p.color);
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		dma_with_noinc(g, &c, g->p.cx*g->p.cy);
		release_bus(g);
	}
Beispiel #20
0
  void Video::set_3d_view(const Camera &camera, const std::pair<Point2i, Point2i> &viewport) {
    m_3d = true;

    const Matrix4f view = camera.get_view_matrix();
    set_view_matrix(view);

    const Matrix4f projection = camera.get_projection_matrix(viewport);
    set_projection_matrix(projection);

    set_viewport(viewport);
  }
Beispiel #21
0
static void gl_start_frame_fbo(gl_t *gl)
{
   glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
   pglBindFramebuffer(GL_FRAMEBUFFER, gl->fbo[0]);
   gl->render_to_tex = true;
   set_viewport(gl, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true, false);

   // Need to preserve the "flipped" state when in FBO as well to have 
   // consistent texture coordinates.
   // We will "flip" it in place on last pass.
   if (gl->render_to_tex)
      glVertexPointer(2, GL_FLOAT, 0, vertexes);
}
Beispiel #22
0
	LLDSPEC void gdisp_lld_fill_area(GDisplay* g) {
		#if GDISP_NO_DMA_FROM_STACK
			static LLDCOLOR_TYPE	c;
		#else
			LLDCOLOR_TYPE	c;
		#endif

		c = gdispColor2Native(g->p.color);
		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);	
		dma_with_noinc(g, &c, g->p.cx * g->p.cy);
		release_bus(g);
	}
Beispiel #23
0
static void display_messages (float x_org, float y_org)
{
	float
		x_min,
		y_min,
		x_max,
		y_max,
		y_line1,
		y_line2,
		y_line3,
		y_line4;

	if (!electrical_system_active())
		return;

	x_min = x_org;
	y_min = y_org;
	x_max = x_org + VIEWPORT_WIDTH - 0.001;
	y_max = y_org + VIEWPORT_HEIGHT - 0.001;

	set_viewport (x_min, y_min, x_max, y_max);

	y_line1 = y_org;
	y_line2 = y_org + 10.0;
	y_line3 = y_org + 20.0;
	y_line4 = y_org + 30.0;

	set_mono_font_type (MONO_FONT_TYPE_5X9);

	set_mono_font_colour (text_colour);

	set_mono_font_position (x_min, y_line1);

	print_mono_font_string (line1);

	set_mono_font_position (x_min, y_line2);

	print_mono_font_string (line2);

	set_mono_font_position (x_min, y_line3);

	print_mono_font_string (line3);

	set_mono_font_position (x_min, y_line4);

	print_mono_font_string (line4);
}
Beispiel #24
0
	LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
		pixel_t		*buffer;
		coord_t		ycnt;

		buffer = (pixel_t *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;

		acquire_bus(g);
		set_viewport(g);
		set_cursor(g);
		if (g->p.x2 == g->p.cx) {
			dma_with_inc(g, buffer, g->p.cx*g->p.cy);
		} else {
			for (ycnt = g->p.cy; ycnt; ycnt--, buffer += g->p.x2)
				dma_with_inc(g, buffer, g->p.cy);
		}
		release_bus(g);
	}
Beispiel #25
0
/*
Main rendering function. Note how it's essentially the same as the
ones you were writing in OpenGL! We start by clearing the buffer,
render some stuff, then swap the buffers. All that's different is
some slightly different matrix access.

*/
void Renderer::RenderScene()
{
	set_viewport();
	clear_buffer();

	drawSkybox();

	//fillBuffers();
	//drawPointLights();
	//combineBuffers();
	
	simpleLighting();
	
	swap_buffers();

	//std::cout << "Not crashed!!" << std::endl;
}
	void GL3GraphicContextProvider::set_viewport(int index, const Rectf &viewport)
	{
		if (glViewportIndexedf)
		{
			OpenGL::set_active(this);
			glViewportIndexedf(index,
				GLfloat(viewport.left),
				GLfloat(viewport.top),
				GLfloat(viewport.right - viewport.left),
				GLfloat(viewport.bottom - viewport.top));
		}
		else
		{
			if (index == 0)
				set_viewport(viewport);
		}
	}
Beispiel #27
0
void Renderer::renderInitScreen()
{
	this->SetCurrentShader(*basicVert, *basicFrag);
	
	Matrix4 aProjMatrix = Matrix4::orthographic(-1, 1, -1, 1, 0, 1);
	viewMatrix = Matrix4::identity();
	modelMatrix = Matrix4::identity();
	
	set_viewport();
	clear_buffer();

	cellGcmSetDepthTestEnable(CELL_GCM_FALSE);
	//cellGcmSetDepthFunc(CELL_GCM_LESS);

	currentVert->UpdateShaderMatrices(modelMatrix, viewMatrix, aProjMatrix);
	SetTextureSampler(currentFrag->GetParameter("texture"), initMesh->GetDefaultTexture());
	initMesh->Draw(*basicVert, *basicFrag);
	swap_buffers();
}
Beispiel #28
0
  void Video::set_2d_view(const std::pair<Point2f, Point2f> &camera2d, const std::pair<Point2i, Point2i> &viewport, const bool &fix_aspect_ratio) {
    m_3d = false;

    set_viewport(calculate_viewport(camera2d, viewport, fix_aspect_ratio));

    const Matrix4f view = Matrix4f::Identity();
    set_view_matrix(view);

    const std::pair<Point2i, Point2i> &vp = get_viewport();
    Point2f offset = get_pixel_offset();
    offset.x *= (camera2d.second.x - camera2d.first.x) / (vp.second.x - vp.first.x);
    offset.y *= (camera2d.second.y - camera2d.first.y) / (vp.second.y - vp.first.y);

    const Matrix4f projection = Matrix4f::Orthographic(camera2d.first.x + offset.x,
                                                       camera2d.second.x + offset.x,
                                                       camera2d.second.y + offset.y,
                                                       camera2d.first.y + offset.y,
                                                       ZENI_2D_NEAR, ZENI_2D_FAR);
    set_projection_matrix(projection);
  }
Beispiel #29
0
int Shex::init() {
	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		std::cerr << "There was an error initializing SDL2: " <<
			SDL_GetError() << std::endl;
		return 1;
	}

	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
						SDL_GL_CONTEXT_PROFILE_CORE);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, OPENGL_MAJOR_VERSION);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, OPENGL_MINOR_VERSION);

	winw = WIN_WIDTH;
	winh = WIN_HEIGHT;
	win = SDL_CreateWindow("shex",
		SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
		winw, winh, SDL_WINDOW_OPENGL);
	if(win == NULL) {
		std::cerr << "There was an error creating the window: " <<
			SDL_GetError() << std::endl;
		return 1;
	}

	glcontext = SDL_GL_CreateContext(win);
	if(glcontext == NULL) {
		std::cerr << "There was an error creating OpenGL context: " <<
			SDL_GetError() << std::endl;
		return 1;
	}

	glewExperimental = GL_TRUE;
	glewInit();
	SDL_GL_MakeCurrent(win, glcontext);
	if(init_gl()) {
		return 1;
	}
	set_viewport();
	return 0;
}
Beispiel #30
0
void Viewport::resize(int width, int height) 
{
    if (!_dynamic_aspect) {
        
        glDisable(GL_SCISSOR_TEST);
        // Clear once to set the letterbox color;
        vec4 lb_color = config.letterbox_color();
        glClearColor(lb_color.r, lb_color.g, lb_color.b, lb_color.a);
        glClear(GL_COLOR_BUFFER_BIT);

        glEnable(GL_SCISSOR_TEST);

        float window_aspect = float(width)/float(height);

        int w, h;

        if (_aspect < window_aspect) {
            h = height;
            w = (int)(height * _aspect);
        } else {
            w = width;
            h = (int)(width / _aspect);
        }

        _offset = ivec2((width-w)/2, (height-h)/2);
        _size = ivec2(w,h);
    } else {
        _aspect = float(width)/float(height);
        _offset = ivec2(0,0);
        _size = ivec2(width,height);
    }

    set_viewport();

    vec4 clear_color = config.clear_color();
    glClearColor(clear_color.r, clear_color.g, clear_color.b, clear_color.a);
}