📄 line.cpp
字号:
/*******************************************************************************
*
* ViP model for FIMGSE
* version 1.0
*
* Line.c
*
* by cheolkyoo.kim
* Graphics IP Team in AP, Mobile Solution Development,
* System LSI Division, Semiconductor Business,
* Samsung Electronics
*
* Copyright (c) 2005 FIMG team
*
* All rights reserved. No part of this program may be reproduced, stored
* in a retrieval system, or tranmitted, in any form or by any means,
* electronic, mechanical, photocopying, recording, or otherwise, without
* the prior written permission of the author.
*
* 2005. 3. 22 by cheolkyoo.kim
*
* Description
*
* $RCSfile: $
* $Revision: $
* $Author: $
* $Date: $
* $Locker: $
*
* $Source: $
* $State: $
* $Log: $
******************************************************************************/
/****************************************************************************
* INCLUDES
****************************************************************************/
#if TARGET_PLATFORM == FPGA_BOARD
#include "Fimg3DTest.h"
#endif
#include "mvp_v2o.vsa.h"
#include "mov_v2o.psa.h"
/****************************************************************************
* DEFINES
****************************************************************************/
#if 0
int Line(void)
{
float attributes[] =
{
// x y z r g b a
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.800000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.138919f, 0.787846f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.273616f, 0.751754f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.400000f, 0.692820f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.514230f, 0.612836f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.612836f, 0.514230f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.692820f, 0.400000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.751754f, 0.273616f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.787846f, 0.138919f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.800000f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.787846f, -0.138919f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.751754f, -0.273616f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.692820f, -0.400000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.612836f, -0.514230f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.514230f, -0.612836f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.400000f, -0.692820f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.273616f, -0.751754f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.138919f, -0.787846f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, -0.800000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.138919f, -0.787846f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.273616f, -0.751754f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.400000f, -0.692820f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.514230f, -0.612836f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.612836f, -0.514230f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.692820f, -0.400000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.751754f, -0.273616f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.787846f, -0.138919f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.800000f, -0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.787846f, 0.138919f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.751754f, 0.273616f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.692820f, 0.400000f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.612836f, 0.514230f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.514230f, 0.612836f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.400000f, 0.692820f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.273616f, 0.751754f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
0.0f, 0.0f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f,
-0.138919f, 0.787846f, 0.5f, 0.75f, 0.75f, 0.75f, 1.0f
};
if (fglLoadVShader(mvp_v2o_vsa) != FGL_ERR_NO_ERROR) {
return ERROR;
}
if (fglLoadPShader(mov_v2o_psa) != FGL_ERR_NO_ERROR) {
return ERROR;
}
drvsys_clear_buf((unsigned int*)(FIMG_COLOR_BUFFER), CLEAR_SCREEN_SIZE, 0x00000000);
fglSysPollingMask(0x20000000, 0x0, FGL_PIPESTATE_ALL); // Pipeline status
Matrix4 matMV, matProj, matMVP;
/* Build projection matrix once. */
matProj.SetAsPerspectiveMatrix(45, 0.75, 1.0, 20.0);
/*
// Vertex Shader SFR set
WRITEREG(FGVS_ATTRIB_NUM, 0x00020002); // Attribute counter of VS input & output
WRITEREG(FGVS_CONFIG, 0x00000001); // Configuration register
// Pixel Shader SFR set
WRITEREG(FGPS_EXE_MODE, 0x00000000); // Pixel shader execution mode control register
WRITEREG(FGPS_PC_COPY, 0x00000001); // Copy PSPCS_ADDR value to program counter
WRITEREG(FGPS_ATTRIB_NUM, 0x00000001); // Number of attribute of current context
fglSysPollingMask(FGPS_INBUF_STATUS, 0x0, 0x1); // Status signal of pixel shader input buffer
WRITEREG(FGPS_EXE_MODE, 0x00000001); // Pixel shader execution mode control register
*/
fglVSSetAttribNum(2);
fglPSSetAttributeNum(1);
// Line test main
{
matMV.Translate(0, 0, -4.5);
/*
makeRotateMatrix(fXAng, 1, 0, 0, rotateMatrix);
makeRotateMatrix(fYAng, 0, 1, 0, rotateMatrix1);
multMatrix(rotateMatrix, rotateMatrix, rotateMatrix1);
multMatrix(modelMatrix, translateMatrix, rotateMatrix);
*/
// modelViewProj = projectionMatrix * modelViewMatrix
matMVP = matProj * matMV;
//unsigned int pShaderParam = FGVS_CFLOAT_SADDR;
//matMVP.WriteMatrix4(pShaderParam);
fglWriteVertexShaderConstFloat(0, 16, matMVP.m[0]);
// Line Width set
fglSetLineWidth(1.0f);
// Primitive Engine SRF Set
FGL_Vertex Vtx;
Vtx.prim = FGL_PRIM_LINES;
Vtx.enablePointSize = FGL_FALSE;
Vtx.numVSOut = 1;
Vtx.shadeModel = FGL_SHADING_SMOOTH;
Vtx.colorAttribIdx = 0;
fglSetVertex(&Vtx); // Vertex context register
// Host Interface SFR Set
FGL_HInterface HInterface;
HInterface.enableAutoInc = FGL_TRUE;
HInterface.enableVtxBuffer = FGL_FALSE;
HInterface.enableVtxCache = FGL_FALSE;
HInterface.idxType = FGL_INDEX_DATA_UINT;
HInterface.numVSOut = 2;
fglSetHInterface(&HInterface);
FGL_Attribute HIAttr;
HIAttr.bEndFlag = FGL_FALSE;
HIAttr.type = FGL_ATTRIB_DATA_FLOAT;
HIAttr.numComp = 3;
HIAttr.srcW = FGL_ATTRIB_ORDER_4TH;
HIAttr.srcZ = FGL_ATTRIB_ORDER_3RD;
HIAttr.srcY = FGL_ATTRIB_ORDER_2ND;
HIAttr.srcX = FGL_ATTRIB_ORDER_1ST;
fglSetAttribute(0, &HIAttr);
HIAttr.bEndFlag = FGL_TRUE;
HIAttr.numComp = 4;
fglSetAttribute(1, &HIAttr);
unsigned int nNumOfData = sizeof(attributes)/sizeof(float);
unsigned int nNumOfVertices = nNumOfData/7;
unsigned int uiDummy = 0xFFFFFFFF;
fglSendToFIFO(4, &nNumOfVertices);
fglSendToFIFO(4, &uiDummy);
fglSysTransferToPort(
(unsigned int *)attributes,
/*(volatile unsigned int *)(FGHI_FIFO_ENTRY),*/
nNumOfData
);
fglFlush(FGL_PIPESTATE_ALL); // Pipeline statuss
//fglSysCacheFlush();
fglClearCache(FGL_CACHECTL_FLUSH_ZCACHE | FGL_CACHECTL_FLUSH_CCACHE);
fglSysDelay(50);
}
/*
if(m_SwapBackBuffer == FALSE)
{
fglSwapBuffer(0);
drvsys_clear_buf((unsigned int*)(m_FrontFBAddr), CLEAR_SCREEN_SIZE, 0x0);
fglSetColorBufBaseAddr(m_FrontFBAddr);
m_SwapBackBuffer = TRUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -