menu

Volume menggunakan OpenGL 2D tekstur 3D

# include & amp; amp; lt; windows.h & amp; Amp; gt; “Glut.h” # include
“GL glu.h” #include
“GL gl.h”

# include # include “GL glew.h”
# include & amp; amp; lt; stdio.h & amp; Amp; gt;
meliputi & amp; Amp; lt; sys / stat.h & amp; amp; gt;
meliputi & amp; Amp; lt; math.h & amp; Amp; gt;

TOTAL_SHADERS 3 # define #define TEXTURE_COUNT 6

texture_ıd_ penomoran {TEMP_TEX_ID = 0 /> DIR_TEX_ID, VOL_TEX_ID,

FRAME_COLOR_TEX_ID_1, LUT_TEX_ID FRAME_COLOR_TEX_ID_2

enum data_type_ {/> UNSIGNED_ONE_BYT = 0,

SIGNED_ONE_BYTE, UNSIGNED_TWO_BYT untuk,



Aku MAIN_RENDER_PROGRA}

penomoran;

Struktur hurange_color_t {public int

m_nhurange saya; // />

jumlah,.

SHADER_ATTRIBUTE_LOC struct {int nfrontfa;
nfrontfacetex int;
ncolormap int;
nvolumetextur int;
ndepth int;
nstepsiz int;
ntemporarytextur int;
ndirectiontextur int;
ndatarang int;
antar NWC; />
nrend int;
nslop int;
nıntercept int;
nrange int saya; }
;

struct {volume_t

publik // Anggota:

m_ppixels void *; /> // Inter m_nwidth M_nheight int
M_ndepth dari m_nbytesperpixel antar;
M_nm // int byte per pixel; // Int m_nmax
volume minimum; // Nilai maksimum antar m_ndatatyp
Volume; />

m_fz nilai float

Umum:

// struktur volume_t Bangunan () />
// upaya { m_ppixels = 0; // /> M_nwidth Kosong = 0 m_nheight = 0; /> M_ndepth = 0 m_nbytesperpixel = 1 ;; /> M_nm adalah = 0 M_nmax = 0 m_ndatatyp = 0;
m_fx = 1.0f;
m_fy = 1.0f;
m_fz = 1.0f;

}};

m_stlookup volume_t; /> SHADER_ATTRIBUTE_LOC stattribloc

GLuint progobj [TOTAL_SHADERS];
GLuint textureıd [TEXTURE_COUNT];

data_type_ untuk ///////////// ////// eDataType = UNSIGNED_ONE_BYT untuk;
DCM_WIDTH const int = 256;
DCM_HEIGHT const int = 256;
DCM_DEPTH const int = 96;
szfil const char * = “F: head256x256x109”;

/////////////////// DEFAULT_WINDOW_WIDTH const int = 775;
DEFAULT_WINDOW_CENT const int = 453;
minimum // Gambar dan amp; amp; . Hi maksimum kisaran HURANGE_M
const int = -1.024;
HURANGE_MAX const int = 5119;

Grup hurangecol = 5; // Define Ukuran kisaran 4 pentingnya SHARPNESS_ARRAY_SIZ A = />

RED const int = 0;
#define GREEN = 1;
#define BIRU = 2;
ALPHA const int = 3;

m_nminvalu int = 0;
m_nmaxvalu int = 255;
m_llutwidth int = 0;
nımgwidth int;
nımgheight int;
m_nwinheight int;
m_nwinwidth int;
m_nmainhurange int saya = 0;
m_nsharpness int [SHARPNESS_ARRAY_SIZ A];
mengapung * m_prgbalut = 0;
hurange_color_t m_sthurangecol yang [HURANGE_COLOR_ARRAY_SIZ A];
GLuint m_fbo; /> GLuint m_renderdepthbuff adalah GLuint m_nrenderinggeometry;
GLuint m_vbo; /> GLuint m_nbboxvbo Geometry [72]; // VBO bukit pertanian GLfloat m_fcolors
[72];
// VBO warna Grup GLfloat m_fboundingboxcolors [72];

int getsizeof (data_type_ untuk etype_ a) {beralih

(etype_ dari) /> {

Kasus UNSIGNED_ONE_BYTE: pulang sizeof (unsigned char) SIGNED_ONE_BYT ke:
pulang sizeof (char);
Jika UNSIGNED_TWO_BYT ke:
sizeof kembali (unsigned short);
SIGNED_TWO_BYT ke:
sizeof kembali (pendek);

} return 1; }

int getmaxvalu (dari) />

GLuint gettextureıd (texture_ıd_ untuk etexıd_ a)

{textureıd [static_cast & amp; Pengembalian amp; lt; int & amp; amp; gt; (Etexıd_ a)]; }

settextureıd valid (texture_ıd_ untuk etexıd_ dari utextureıd_ GLuint) /> textureıd [static_cast & amp; amp

setprogramıd valid (program_type_ untuk eprogramıd_ dari nprogıd_ GLuint)

{progobj [static_cast & amp; amp; lt; int & amp; amp; gt; (Eprogramıd_ a)] = nprogıd_ dari; }

GLuint getprogramıd (program_type_ untuk eprogramıd_ a)

{progobj [static_cast & amp; Pengembalian amp; lt; int & amp; amp; gt; (Eprogramıd_ a)];
}

setaspectedortho void (int noriginx_ dari noriginy_ int, int nwidth_ dari nheight_ int, float frange_) />
GLfloat {

glViewport (noriginx_ dari noriginy_ dari nwidth_ dari nheight_ a);

glMatrixMode // Ganti Proyeksi matriks (GL_PROJECTIO dunia);
glLoadIdentity ();

A = 12,0 + frange_ fzrang mengapung;
jika (nwidth_ & amp; amp; lt; = nheight_ a)

{fwindowheight = frange_ yang / faspectratio mengambang;
glOrtho (-frange_ dari frange_ dari -fwindowheight, fwindowheight, -fzrang untuk, fzrang A); />
/>
glOrtho (-fwindowwidth, fwindowwidth, -frange_ dari frange_ dari -fzrang untuk, fzrang A);

} /> glMatrixMode yang modelview matriks (GL_MODELVIEW)
glLoadIdentity ();

}

kekosongan membentuk kembali (int nwidth_ dari nheight_ int) {

m_nwinheight = nheight_ dari;
m_nwinwidth = nwidth_ dari;
jika (a == 0 nheight_)

{nheight_ = 1; />
} // Setaspectedortho (0, 0, nwidth_ dari nheight_ adalah 0.75f)

GLuint createprogra I (szvertexshader_ char *, char * szfragmentshader_ a)

{GLuint nProgram = 0; //
Program Tahan adalah GLuint nvertex = 0; /> GLuint nfragment = 0
/>
{/> nvertex = glcreateshad The (yang GL_VERTEX_SHAD)
eğer; szvertexshader_ untuk pcvv = const arang
glshadersour oleh (nvertex, 1, & amp; amp; amp; pcvv, NULL); /> // vertex shader desain
glcompileshad adalah (nvertex)
{ //

fragmen shader nfragment = The glcreateshad (yang GL_FRAGMENT_SHAD) untuk membuat; szfragmentshader_ dari /> pcff = const arang
glshadersour oleh (nfragment, 1, & amp; amp; amp; pcff NULL ); //

Fragment shader glcompileshad adalah (nfragment) untuk mengkompilasi;
GLenum glgeterr error = ();
batubara [2048] log;
ACL int = 0;
glgetprogramınfolog (nProgram 2048 dan amp; ACL log); Shader

Program ini glattachshad (nProgram, nfragment) ke //; />
} /> Gllinkprogra I (nProgram)

jika (nvertex & amp; gt; 0)

{gldetachshad adalah (nProgram, nvertex);
gldeleteshad adalah (nvertex); />
}

gldetachshad (nProgram, nfragment) gldeleteshad adalah (nfragment); }

Kesalahan = glgeterr adalah GLenum ();
batubara [2048] log;
ACL int = 0;
glgetprogramınfolog (nProgram 2048 dan amp; ACL log); // Kembalikan program kembali

Saya nProgram; }

szvertexshad [char] = />

“) Rn utama Void (” “”

Rn “rn {” /> “rn gl_frontcol R = gl_col The;” /> <
“rn = gl_positio yang ftransform ();” />

szfragmentshaderfront [char] = />

perubahan vec4 “posisi rn
,”

” rn gl_fragcol R = adalah Texture2D (FrontFace, texcordinate.xy), “
” rn} “;

szfragmentshaderdirectio char [] = /> “
rn sampler2d frontfacetex seragam,” “berbeda RNA texcordinat untuk vec4;” />

“rn void main () “/> ” rn} “;

// = 0 lakukan;
// kemiringan = 1.0;
// intercept = 0,0; /> // Wc = 500

szfragmentshader Romain [char] = />

Sampler2d peta ngjyrash; “/>” R seragam




“rn mengapung seragam Perang;” /> Rn lereng seragam, “mengubah posisi rn vec4;” “
” mengambang />




/>
“rn {”


“.. A + = (. 1-dst A) * rn src menyebabkan;” />
“Rn”
“rn}” /> void main () “/>



“R mengambang;” />
data;”







“rn {”
” rn {“/> ” “/> ” R “/>
” rn {“ ” rn {“/>
” R map.y = map.y / 32.0f; . “/> ” R N Alpha A = ((data – min) / W).; “
” R} “/> ” rn {“/> ” R} “/> ” R color.rgb = color.rgb; “/>
” Rn “” rn (flvolcoord.x & amp; lt; = 1.0f) & amp; amp; amp; & amp; amp; amp; (flvolcoord.y & amp; lt; = 1.0f) & amp; amp; amp; & amp; amp ; amp; (flvolcoord.z ​​& amp; lt; = 1.0f)) “
” rn {“/> ” rn “/> ” R} “/> ” rn} “/> ” rn {“/> ” R}} // akhir rel siklus molding “/> “); “.
” R n = flresultval adalah gl_fragcol; // Float4 (0,0,1,1); “/> ” rn} “;

batal loadshaders () />

Program setprogramıd (DIRECTION_PROGRA saya, saya createprogra (szvertexshad adalah, szfragmentshaderdirectio dunia));
stattribloc.nfrontfacetex = glgetuniformlocatio ini (getprogramıd (DIRECTION_PROGRA I), “frontfacetex”);

program utama
// setprogramıd (MAIN_RENDER_PROGRA saya, createprogra I (szvertexshad adalah, szfragmentshader DOMAIN));
stattribloc.ncolormap = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “peta warna”);
stattribloc.nvolumetextur A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “volumetextur untuk”);
stattribloc .ndepth = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “kedalaman”);
stattribloc.nstepsiz A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “stepsize”);
stattribloc.ntemporarytextur A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I) ” temporarytextur untuk “); /> stattribloc.ndirectiontextur A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I) stattribloc.ndatarang A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “datarang untuk”);
stattribloc.nwc = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “WC”);
stattribloc.nw R = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “War”);
stattribloc.nrend R = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “pintu”);
stattribloc.nslop A = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), “kemiringan”);
stattribloc.nıntercept = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA) di “persimpangan”);
saya stattribloc.nrange = glgetuniformlocatio ini (getprogramıd (MAIN_RENDER_PROGRA I), dan “Ranger”);

gluseprogra I (getprogramıd (MAIN_RENDER_PROGRA I));

gluniform1 yang (stattribloc.ntemporarytextur pada, 0);
gluniform1 dari (stattribloc.ncolormap, 1);
gluniform1 yang (stattribloc.nvolumetextur untuk, 2);
gluniform1 yang (stattribloc.ndirectiontextur, 3A);

// Program Akhir setprogramıd (FINAL_DISPLAY_PROGRA I, createprogra (szvertexshad adalah, szfragmentshaderfront)) lakukan;
stattribloc.nfrontfa = glgetuniformlocatio oleh (getprogramıd (FINAL_DISPLAY_PROGRA I), “FrontFace”);

gluseprogra I (getprogramıd (FINAL_DISPLAY_PROGRA I));
gluniform1 yang (stattribloc.nfrontfa oleh, 0);

gluseprogra (0); }

batal createframebuff adalah () />

glgenframebuffersext (1, & amp; amp; amp; m_fbo);
glbindframebufferext (GL_FRAMEBUFFER_EXT, m_fbo);

glgenrenderbuffersext (1, & amp; amp; amp; m_renderdepthbuff The);
glbindrenderbufferext (GL_RENDERBUFFER_EXT adalah m_renderdepthbuff);

glrenderbufferstorageext (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, m_nwinwidth, m_nwinheight);


glframebufferrenderbufferext (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT adalah m_renderdepthbuff);

glbindframebufferext (GL_FRAMEBUFFER_EXT, 0);

}

GLuint create2dtextur (int nwidth_ dari nheight_ int, bool boffscreen_ a)

{GLuint nımg;

glgentextures (1, & amp; amp; amp; nımg);
glbindtextur ke (GL_TEXTURE_2D, nımg);
glpixelstoref (GL_UNPACK_ALIGNMENT, 1);
glpixelstoref (GL_PACK_ALIGNMENT, 1);
glpixelstoref (GL_UNPACK_ROW_LENGTH, nwidth_ a);
glpixelstoref (GL_PACK_ROW_LENGTH, nwidth_ a);
gltexparameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDG A);
gltexparameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDG A);
gltexparameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILT itu GL_LINE);
gltexparameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILT itu GL_LINE);

(boffscreen_) bahwa jika />
{

Kembali nımg }

Kesenjangan createtexturesforraycasting (nwidth_ int, int nheight_ a) {

settextureıd (TEMP_TEX_ID, create2dtextur ke (nwidth_ dari nheight_ untuk), true);
settextureıd (DIR_TEX_ID, create2dtextur ke (nwidth_ dari nheight_ adalah, true));
settextureıd (FRAME_COLOR_TEX_ID_1, create2dtextur ke (nwidth_ dari nheight_ adalah, false));
settextureıd (FRAME_COLOR_TEX_ID_2, create2dtextur ke (nwidth_ dari nheight_ adalah, false)); }

ruang createvbo (fdepth_ float, fwidth_ dari fheight_ mengapung float) // //

{KUP v6– v5 // / | / |
// v1 – v0 |
// | | | |
// | | V7 – | – | v4
// | / | /
// v2 – v3

mengambang fdimx, fdimy, fdimz;

fdimx = fwidth_ dari / 2.0; /> Fdimy = fheight_ dari / 2.0 Fdimz = fdepth_ dari / 2.0

for (int i = 0; i & amp; lt; 72; i ++) {/>

// m_fcolors depan [0] = 1; [1] = 1 m_fcolors; [2] = 0 m_fcolors;
m_fvertices V0 // [0] = fdimx; m_fvertices [1] = fdimy; m_fvertices [2] = fdimz;

m_fcolors [3] = 0; [4] 1 = m_fcolors; [5] = 0 m_fcolors; //
V1 m_fvertices [3] = -fdimx; m_fvertices [4] = fdimy; m_fvertices [5] = fdimz;

m_fcolors [6] = 0; [7] = 0 m_fcolors; [8] = 0 m_fcolors; //
M_fvertices V2 [6] = -fdimx; m_fvertices [7] = -fdimy; m_fvertices [8] = fdimz;

m_fcolors [9] = 1; [10] = 0 m_fcolors; [11] = 0 m_fcolors; //
V3 m_fvertices [9] = fdimx; m_fvertices [10] = -fdimy; m_fvertices [11] = fdimz;

m_fcolors Wajah Kanan // [12] = 1; [13] = 1 m_fcolors; [14] = 0 m_fcolors; // /> Von m_fvertices

m_fcolors [15] = 1; [16] = 0 m_fcolors; [17] = 0 m_fcolors; //
V3 m_fvertices [15] = fdimx; m_fvertices [16] = -fdimy; m_fvertices [17] = fdimz;

m_fcolors [18] = 1; [19] = 0 m_fcolors; [20] = 1 m_fcolors; // /> M_fvertices V4

m_fcolors [21] = 1; [22] 1 = m_fcolors; [23] = 1 m_fcolors; //
V5 m_fvertices [21] = fdimx; m_fvertices [22] = fdimy; m_fvertices [23] = -fdimz;

// Lebih m_fcolors Wajah [24] = 1; [25] = 1 m_fcolors; [26] = 0 m_fcolors;
m_fvertices V0 // [24] = fdimx; m_fvertices [25] = fdimy; m_fvertices [26] = fdimz;

m_fcolors [27] = 1; [28] = 1 m_fcolors; [29] = 1 m_fcolors; //
V5 m_fvertices [27] = fdimx; m_fvertices [28] = fdimy; m_fvertices [29] = -fdimz;

m_fcolors [30] = 0; [31] 1 = m_fcolors; [32] = 1 m_fcolors; //
V6 m_fvertices [30] = -fdimx; m_fvertices [31] = fdimy; m_fvertices [32] = -fdimz;

m_fcolors [33] = 0; [34] 1 = m_fcolors; [35] = 0 m_fcolors; //
V1 m_fvertices [33] = -fdimx; m_fvertices [34] = fdimy; m_fvertices [35] = fdimz;

// wajah m_fcolors Kiri [36] = 0; [37] = 1 m_fcolors; [38] = 0 m_fcolors; //
V1 m_fvertices [36] = -fdimx; m_fvertices [37] = fdimy; m_fvertices [38] = fdimz;

m_fcolors [39] = 0; [40] = 1 m_fcolors; [41] = 1 m_fcolors; //
V6 m_fvertices [39] = -fdimx; m_fvertices [40] = fdimy; m_fvertices [41] = -fdimz;

m_fcolors [42] = 0; [43] = 0 m_fcolors; [44] = 1 m_fcolors; //
V7 m_fvertices [42] = -fdimx; m_fvertices [43] = -fdimy; m_fvertices [44] = -fdimz;

m_fcolors [45] = 0; [46] = 0 m_fcolors; [47] = 0 m_fcolors; // /> M_fvertices V2

// Old m_fcolors Wajah [48] = 0; [49] = 0 m_fcolors; [50] = 1 m_fcolors; //
V7 m_fvertices [48] = -fdimx; m_fvertices [49] = -fdimy; m_fvertices [50] = -fdimz;

m_fcolors [51] = 1; [52] = 0 m_fcolors; [53] = 1 m_fcolors; // /> M_fvertices V4

m_fcolors [54] = 1; [55] = 0 m_fcolors; [56] = 0 m_fcolors; //
V3 m_fvertices [54] = fdimx; m_fvertices [55] = -fdimy; m_fvertices [56] = fdimz;

m_fcolors [57] = 0; [58] = 0 m_fcolors; [59] = 0 m_fcolors; // /> M_fvertices V2

Wajah // Kembali m_fvertices [60] = fdimx; m_fvertices [61] = -fdimy; m_fvertices [62] = -fdimz;
m_fcolors [60] = 1 ;; [61] = 0 m_fcolors; [62] = 1 m_fcolors; // V4

m_fcolors [63] = 0; [64] = 0 m_fcolors; [65] = 1 m_fcolors; //
V7 m_fvertices [63] = -fdimx; m_fvertices [64] = -fdimy; m_fvertices [65] = -fdimz;

m_fcolors [66] = 0; [67] = 1 m_fcolors; [68] = 1 m_fcolors; //
V6 m_fvertices [66] = -fdimx; m_fvertices [67] = fdimy; m_fvertices [68] = -fdimz;

m_fcolors [69] = 1; [70] = 1 m_fcolors; [71] = 1 m_fcolors; //
V5 m_fvertices [69] = fdimx; m_fvertices [70] = fdimy; m_fvertices [71] = -fdimz;

glgenbuffersarb (1, & amp; amp; amp; m_vbo);
glbindbufferarb (GL_ARRAY_BUFFER_ARB, m_vbo);
glbufferdataarb (GL_ARRAY_BUFFER_ARB, ukuran (m_fvertices) + sizeof (m_fcolors), 0, GL_STATIC_DRAW_ARB);
glbuffersubdataarb (GL_ARRAY_BUFFER_ARB 0, ukuran (m_fvertices) m_fvertices); (,) Sizeof (m_fcolors) GL_ARRAY_BUFFER_ARB, ukuran (m_fvertices m_fcolors) /> // /> glbuffersubdataarb
// copy normals setelah warna

glgenbuffersarb (1, & amp; amp; amp; m_nbboxvbo);
glbindbufferarb (GL_ARRAY_BUFFER_ARB, m_nbboxvbo);
glbufferdataarb (GL_ARRAY_BUFFER_ARB, ukuran (m_fvertices) + sizeof (m_fboundingboxcolors), 0, GL_STATIC_DRAW_ARB);
glbuffersubdataarb (GL_ARRAY_BUFFER_ARB 0, ukuran (m_fvertices) m_fvertices); (,) Sizeof (m_fboundingboxcolors) GL_ARRAY_BUFFER_ARB, ukuran (m_fvertices m_fboundingboxcolors) /> // /> glbuffersubdataarb
Glbindbufferarb (GL_ARRAY_BUFFER_ARB, m_vbo) setelah

ruang drawrenderinggeometry () {color

copy;

/> glenableclientstat ke (GL_COLOR_ARRAY)
glenableclientstat ke (GL_VERTEX_ARRAY);

/ / menggambar sebelum /> (3 GL_FLOAT, 0, (void *) (sizeof (m_fvertices)))
glvertexpoint (3, GL_FLOAT, 0, 0);

glDrawArrays (GL_QUADS, 0, 24);

gldisableclientstat ke (GL_VERTEX_ARRAY); // Top gldisableclientstat sebuah />

// /
benar berperilaku // Setelah terhubung, 0 Setelah menggunakan identitas
// layar, urutan akhir operasi yang normal />

}

generaterenderinggeometrylist valid () />
{
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glRotatef (180.0f, 0.0f, 0.0f, 1.0f); /> //// GlRotatef (135.0f, 0.0f, 1.0f, 0.0f) // GlRotatef (-90.0f, 1.0f, 0.0f, 0.0f) drawrenderinggeometry ();
glEndList (); }

attachfbo void (int ntexıd_ dari) /> {

kualitas
FBO // insert adalah glbindframebufferext (GL_FRAMEBUFFER_EXT, m_fbo) ditentukan glframebuffertexture2dext (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, ntexıd_, 0);
GLenum status = glcheckframebufferstatusext (GL_FRAMEBUFFER_EXT);!
jika (status = GL_FRAMEBUFFER_COMPLETE_EXT) />


ruang createrayınitiationtextur () {

glbindtextur ke (GL_TEXTURE_2D, gettextureıd (TEMP_TEX_ID));
// untuk melampirkan untuk mengidentifikasi kualitas FBO
identitas attachfbo (gettextureıd (TEMP_TEX_ID));
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// kubus glCallList (m_nrenderinggeometry) lakukan;
glbindtextur ke (GL_TEXTURE_2D, 0); />


createdirectiontextur void () {

// siap sehingga kualitas pertama texturingunit 0 Binder // /> gluniform1 yang
glactivetextur ke (GL_TEXTURE0);
glbindtextur ke (GL_TEXTURE_2D, gettextureıd (TEMP_TEX_ID));
attachfbo (gettextureıd (DIR_TEX_ID));
// glbindframebufferext (GL_FRAMEBUFFER_EXT, 0);

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCallList (m_nrenderinggeometry);

}

void * ReadFile (LPCTSTR lpfilename_ dari data_type_ untuk etype_)

{P Foto *;
errno_t err = fopen_s (& amp; amp; amp; FP, lpfilename_, “RBI”);
(0 = tersandung!) {if

return false;
}
size_t size = DCM_WIDTH DCM_HEIGHT * * * getsizeof DCM_DEPTH (etype_ a);

char * chbuff = Char baru [Anda];! /> Jika (chbuff adalah)


fread_s ((void *) chbuff, dimensi, getsizeof (etype_), yang DCM_WIDTH * DCM_HEIGHT * DCM_DEPTH, FP);
fclose (FP);
kembali (void *) chbuff; }

GLuint create3dtextur (void * Pixels_ dari data_type_ untuk edatatype_) />
GLuint {
jika

{// Set Tekstur

kunci (edatatype_) parameter /> {

unsigned char * TempDir = unsigned char baru [256 * 256];
MEMS (TempDir 255 256 * 256);
// untuk (int ntempgridloc = 0; ntempgridloc & amp; Gamble lt; ntotal2dtex, ntempgridloc ++) />
{glactivetexturearb (GL_TEXTURE0_ARB) Glgentextures (; amp; ntextureıd 1, & amp; amp) glbindtextur ke (GL_TEXTURE_2D, ntextureıd);
glpixelstoref (GL_UNPACK_ALIGNMENT, 1);
glpixelstoref (GL_PACK_ALIGNMENT, 1);
glpixelstoref (GL_UNPACK_ROW_LENGTH (GLfloat) DCM_WIDTH);
glpixelstoref (GL_PACK_ROW_LENGTH (GLfloat) DCM_WIDTH);

gltexparameter yang (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDG A);
gltexparameter yang (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDG A);
gltexparameter yang (GL_TEXTURE_2D, GL_TEXTURE_WRAP_ adalah, GL_CLAMP_TO_EDG A);
gltexparameter yang (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILT itu GL_LINE);
gltexparameter yang (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILT itu GL_LINE);

glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINAN, yang nmax2dtexsiz untuk, 3072, /> 0 GL_LUMINAN, yang GL_UNSIGNED_BYT ke NULL

* byte tempvol = (byte *) Pixels_ dari;

(ntempy int = 0; ntempy & amp; lt; 12; ntempy ++) {

(ntempx int = 0; ntempx & amp; lt; 8; ntempx + +) />
{
gltexsubımage2d (GL_TEXTURE_2D, 0, (DCM_WIDTH * ntempx) /> DCM_WIDTH, DCM_HEIGHT, GL_LUMINAN, yang GL_UNSIGNED_BYT untuk, tempvol
Tempvol + = (DCM_WIDTH * DCM_HEIGHT)

break; }

default: {/>


istirahat; ntextureıd kembali

}}}; }

Renderoffscre Boolean () {

fmaxtexturedimensio yang = static_cast & amp; mengambang amp; lt; Mengapung & amp; amp; gt; (Max (max (DCM_WIDTH, DCM_HEIGHT), DCM_DEPTH));

int nswaplogic [2];
nswaplogic [0] = gettextureıd (FRAME_COLOR_TEX_ID_1);
nswaplogic [1] = gettextureıd (FRAME_COLOR_TEX_ID_2);

ncurrentsurfa int = 0;
mengambang fldepth = 0.0f;
fdiagonal = 1.732f * fmaxtexturedimensio mengapung;
glclearcol adalah (0,0, 0,0, 0,0, 0,0);
glcleardepth (0);
gldepthfunc (GL_GREAT Depan | GL_EQUAL);

Hapus // />
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
attachfbo (nswaplogic [1]);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Lampung A = fdiagonal m_fstepsiz;

// fstepsiz A = m_fstepsiz ke float / (9.0f * fmaxtexturedimensio dunia);
// mengambang fstepsiz a = 1.0f / 512;
fstepsiz a = 1.0f / mengambang (fmaxtexturedimensio dunia);

gluseprogra I (getprogramıd (MAIN_RENDER_PROGRA I));
gluniform1f (stattribloc.nstepsiz untuk, fstepsiz A); src=”https://pixel.wp.com/b.gif?host=bytecrunchers.wordpress.com&blog=35471545&post=956&subd=bytecrunchers&ref=&feed=1″ width = “1” height = “1” />

Leave a Reply

Your email address will not be published. Required fields are marked *