Skip to content

Commit

Permalink
Blending and viewports
Browse files Browse the repository at this point in the history
  • Loading branch information
phire committed Nov 16, 2010
1 parent 8311d8a commit 473abbd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions samples/rsxTest/include/rsxutil.h
@@ -1,5 +1,8 @@
#pragma once

#include <sysutil/video.h>
#include <rsx/gcm.h>

extern u32 *buffer[2];
extern gcmContextData *context;
extern VideoResolution res;
Expand Down
28 changes: 24 additions & 4 deletions samples/rsxTest/source/main.c
Expand Up @@ -6,10 +6,8 @@
#include <unistd.h>
#include <math.h>

#include <sysutil/video.h>
#include <rsx/gcm.h>
#include <rsx/reality.h>
#include <rsx/commands.h>
#include <rsx/nv40.h>

#include <io/pad.h>

Expand All @@ -18,6 +16,7 @@
#include "ball.bin.h"
#include "texture.h"
#include "rsxutil.h"
#include "nvshader.h"

int currentBuffer = 0;
realityTexture *ball; // Texture.
Expand All @@ -26,17 +25,38 @@ void drawFrame(int buffer, long frame) {

setupRenderTarget(buffer);

realityViewportTranslate(context, 0.0, 0.0, 0.0, 0.0);
realityViewportScale(context, 1.0, 1.0, 1.0, 0.0);

realityZControl(context, 0, 1, 1); // disable viewport culling

// Enable alpha blending.
realityBlendFunc(context,
NV30_3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA |
NV30_3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA |
NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO);
realityBlendEquation(context, NV40_3D_BLEND_EQUATION_RGB_FUNC_ADD |
NV40_3D_BLEND_EQUATION_ALPHA_FUNC_ADD);
realityBlendEnable(context, 1);

realityViewport(context, res.width, res.height);

// Just because we can only set the clear color, dosen't mean it has to be boring
double cycle = (frame % 200)/100.0;
uint8_t color = (sin(cycle*M_PI) + 1.0) * 127 ;

// set the clear color
realitySetClearColor(context, color << 8 | color << 16); // This is the most Hidious colour ever.
realitySetClearColor(context, color << 8 | color << 16);
// and the depth clear value
realitySetClearDepthValue(context, 0xffff);
// Clear the buffers
realityClearBuffers(context, REALITY_CLEAR_BUFFERS_COLOR_R |
REALITY_CLEAR_BUFFERS_COLOR_G |
REALITY_CLEAR_BUFFERS_COLOR_B |
REALITY_CLEAR_BUFFERS_DEPTH);


}

void unload_modules() {
Expand Down
4 changes: 4 additions & 0 deletions samples/rsxTest/source/rsxutil.c
Expand Up @@ -10,6 +10,7 @@
#include <rsx/commands.h>

#include "rsxutil.h"
#include "nvshader.h"

gcmContextData *context; // Context to keep track of the RSX buffer.

Expand Down Expand Up @@ -74,6 +75,9 @@ void init_screen() {

assert(realityAddressToOffset(depth_buffer, &depth_offset) == 0);

// load fragment shader


gcmResetFlipStatus();
flip(1);
}
Expand Down

0 comments on commit 473abbd

Please sign in to comment.